Skip to content

Description disappears from the generated json after upgrade to 3.0.3 #3274

@petergphillips

Description

@petergphillips

Describe the bug
After the upgrade from springdoc 3.0.2 to 3.0.3 we've noticed that

  @field:Schema(description = "The object of the person to greet")
  val objectName: SomeObject? = null,

gets generated as

          "objectName" : {
            "oneOf" : [ {
              "$ref" : "#/components/schemas/SomeObject"
            }, {
              "type" : "null"
            } ]
          }

and the description is then not set at all.

Under springdoc 3.0.2 the same code generated:

          "objectName" : {
            "$ref" : "#/components/schemas/SomeObject",
            "description" : "The object of the person to greet"
          }

To Reproduce

  • What version of spring-boot you are using? 4.0.5
  • What version of kotlin are you using? 2.3.20
  • What modules and versions of springdoc-openapi are you using? 3.0.3
  • What is the actual and the expected result using OpenAPI Description (yml or json)? See above for actual and also the generated code in 3.0.2. I would expect the description to be still set.
  • Provide with a sample code (HelloController) or Test that reproduces the problem
@RestController
class IssuesController {
  @GetMapping("/")
  fun greet(greeting: Greeting): String = greeting.objectName?.toString() ?: "Hello World"
}

data class Greeting(
  @field:Schema(description = "The object of the person to greet")
  val objectName: SomeObject? = null,
)
data class SomeObject(val someProperty: String)

Expected behavior
The description is generated and not missing.

Note that if the field is defined as

  val stringName: String? = null,

then the generated code is

          "stringName" : {
            "type" : [ "string", "null" ],
            "description" : "The name of the person to greet"
          },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions