Describe the bug
After the upgrade from springdoc 3.0.2 to 3.0.3 we've noticed that
val anyName: Any? = null,
gets generated as
"anyName" : {
"type" : "null"
}
This causes problems with the openapi generator as it then thinks that the type can only be null and tries to generate a Null type etc.
Under springdoc 3.0.2 the same code generated:
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
type not to just be "null".
- Provide with a sample code (HelloController) or Test that reproduces the problem
@RestController
class IssuesController {
@GetMapping("/")
fun greet(greeting: Greeting): String = greeting.anyName?.toString() ?: "Hello World"
}
data class Greeting(
val anyName: Any? = null,
)
Expected behavior
Note that if the field is defined as
val stringName: String? = null,
then the generated code is
"type" : [ "string", "null" ]
I think it is therefore because Any doesn't have a type and therefore null just gets inserted instead. I guess one option is to remove the null if it is the only type found?
Additional context
Looks to be a side effect of #3256.
Describe the bug
After the upgrade from springdoc 3.0.2 to 3.0.3 we've noticed that
gets generated as
This causes problems with the openapi generator as it then thinks that the
typecan only be null and tries to generate aNulltype etc.Under springdoc 3.0.2 the same code generated:
"anyName" : { }To Reproduce
typenot to just be"null".Expected behavior
Note that if the field is defined as
then the generated code is
I think it is therefore because
Anydoesn't have a type and thereforenulljust gets inserted instead. I guess one option is to remove thenullif it is the onlytypefound?Additional context
Looks to be a side effect of #3256.