fix: treat number example as number and not string#5062
fix: treat number example as number and not string#5062Mattias-Sehlstedt wants to merge 2 commits intoswagger-api:masterfrom
Conversation
cf98b96 to
4e11031
Compare
|
Edit: I have added test As raised in a comment on the issue this does not entirely corrects for the issue. This fix only corrects the behavior when the user explicitly states a type in the private record ExampleDto(
@Schema(example = "10.00") BigDecimal value) {
})"ExampleDto": {
"type": "object",
"properties": {
"exampleDec": {
"type": "number",
"example": "10.00" <--
}
}
}The issue is that the example calculator currently does not have access to the field type. So if it sees "5" as an example, it can not properly derive whether it is a number and should be |
f47f42e to
6075b4f
Compare
…ed on the field type
6075b4f to
ec2b7a9
Compare
Pull Request
Thank you for contributing to swagger-core!
Please fill out the following information to help us review your PR efficiently.
Description
Restores part of the schema example construction that was lost with PR #5046 and the change of this line.
The behavior that has been reintroduced is that an example for a number schema (
number/integer) retains the old behavior of using theJsonNodeas the example value, rather than using itsString-representation. This will in turn lead to the example being a number in the specification.This is of importance since the example value should align with the type defined in the schema.
Fixes: #5061
Type of Change
Checklist
Screenshots / Additional Context