[Bug]: Breaking: Writes default values for exclusiveMaximum/exclusiveMinimum to openapi.json
bkoelman opened this issue · 2 comments
Describe the bug
@jgarciadelanoceda Thanks for implementing #2958! I gave it a try today on our codebase using the MyGet feed.
Unfortunately, I'm getting test failures on openapi.json
files that don't use [Range]
. This is because exclusiveMinimum
and exclusiveMaximum
are being written even when set to false
, or not set at all. In those cases, they should be omitted from the output openapi.json
, because the default is already false
in OpenAPI (and also in .NET).
Expected behavior
No "exclusiveMaximum": false, "exclusiveMinimum": false
when not using [Range]
or the Exclusive* properties on [Range]
are set to false
.
Actual behavior
The fragment "exclusiveMaximum": false, "exclusiveMinimum": false
is written to output openapi.json
, causing our assertions on the file contents to fail.
Steps to reproduce
No response
Exception(s) (if any)
No response
Swashbuckle.AspNetCore version
latest master (2db53de)
.NET Version
.NET 8
Anything else?
No response
Seeing the issue it seems a breaking change that we are setting the ExclusiveMinimum and ExclusiveMaximum when the values is set to false.
Because in OpenApi the type is a nullable, that we are always setting to wathever value that it's.. But the documentation is well written even if the value is false.
It's just that right now is more explicit the behaviour. I have seen that is not possible to set those values when the attribute is not on the property so I'll write a PR to just put them when they are set to true(In the case they are set to false they will behave the same way that they are doing right now)
It's working great now, thanks!