Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Breaking: Writes default values for exclusiveMaximum/exclusiveMinimum to openapi.json #2959

Closed
bkoelman opened this issue Jun 21, 2024 · 2 comments · Fixed by #2960
Closed
Labels
Milestone

Comments

@bkoelman
Copy link
Contributor

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

@bkoelman bkoelman added the bug label Jun 21, 2024
@martincostello martincostello added this to the v6.7.0 milestone Jun 21, 2024
@jgarciadelanoceda
Copy link
Contributor

jgarciadelanoceda commented Jun 21, 2024

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)

@bkoelman
Copy link
Contributor Author

It's working great now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants