You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From @Schema(allowableValues = …) on fields/methods, derive its "const"/"enum".
From @Schema(defaultValue = …) on fields/methods, derive its "default".
The outputted JSON always treats them as Strings, and does not consider the actual type of the property.
Instead of "const" : "true", I would have expected this to be "const" : true (i.e. not a String value). The same happens for any other primitive types.
The text was updated successfully, but these errors were encountered:
Yeah, that's the downside of the Swagger annotation providing everything as String values.
We could add extra smarts to cover some straightforward scenarios such as this one, but to be honest, I'd expect something like the jakarta @AssertTrue validation annotation to be present in this case, which allows enforcement and can be picked up without having to parse a String.
I'm open to a PR though, if you deem it worthwhile.
I fully agree, that the schema currently being generated there is invalid. The issue can be avoided by not using the @Schema(allowableValues = "true") in such a case and/or a fix is required here.
I raised #456 to add support for Jakarta @AssertTrue and @AssertFalse.
Maybe I'll come back around in the future to try and raise a PR to add some support for primitive types in @Schema(allowableValues = "true"). But adding support for Jakarta @AssertTrue and @AssertFalse does actually solve my immediate issue. So that's good enough for me for now. 🙂
For the following Swagger 2 module properties:
The outputted JSON always treats them as Strings, and does not consider the actual type of the property.
For example, if I have the following:
This would produce a schema like:
Instead of
"const" : "true"
, I would have expected this to be"const" : true
(i.e. not a String value). The same happens for any other primitive types.The text was updated successfully, but these errors were encountered: