Skip to content

springdoc-openapi-starter-webmvc-ui 2.8.3 does not generate "required" properties #2871

Closed

Description

@gertjanschouten

Since upgrading to springdoc-openapi-starter-webmvc-ui 2.8.3 (in combination with spring boot 3.4.1), properties are no longer marked as "required" in the generated openapi spec. All properties are still there, it's just that the entire "requires" list of required properties is no longer there.

For example, in 2.7.0, you would get this:

      "MyObject": {
        "type": "object",
        "properties": {
          "property1": {
            "type": "string"
          },
          "property2": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "property1"
        ]
      }

Then, in 2.8.3, it becomes this:

      "MyObject": {
        "type": "object",
        "properties": {
          "property1": {
            "type": "string"
          },
          "property2": {
            "type": "string",
            "format": "uuid"
          }
        }
      }

We had to revert to 2.7.0 for the time being.

Activity

  1. Mattias-Sehlstedt commented on Jan 21, 2025

    @Mattias-Sehlstedt
    Contributor

    Could you provide an example of how the model looks in code?

  2. gertjanschouten commented on Jan 22, 2025

    @gertjanschouten
    Author
    data class MyObject(
      val property1: String,
      val property2: UUID?
    )

    So basically, it relies on Kotlin's nullable syntax. Sorry, I didn't mention this before, I forgot :) This always used to work up until 2.7.0

  3. Mattias-Sehlstedt commented on Jan 22, 2025

    @Mattias-Sehlstedt
    Contributor

    Thanks for the added details. I have unfortunately myself only used Java together with explicit annotations that state whether a field is required or not.

    But hopefully the additional details that you have provided should be enough for someone to investigate the issue.

  4. bnasslahsen commented on Jan 24, 2025

    @bnasslahsen
    Collaborator

    @gertjanschouten,

    Not reproducible.
    Feel free to provide a Minimal, Reproducible Example - with HelloController that reproduces the problem.

    This ticket will be closed, but can be reopened if your provide the reproducible sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions