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

[Feature request]: Support new .NET 8 Model State attributes #2957

Closed
bkoelman opened this issue Jun 20, 2024 · 4 comments · Fixed by #2958
Closed

[Feature request]: Support new .NET 8 Model State attributes #2957

bkoelman opened this issue Jun 20, 2024 · 4 comments · Fixed by #2958
Labels
feature suggestion help-wanted A change up for grabs for contributions from the community

Comments

@bkoelman
Copy link
Contributor

Is your feature request related to a specific problem? Or an existing feature?

Support for [Length] was recently added in #2882. There are more Model State attributes in .NET 8 that Swashbuckle could potentially support:

ASP.NET .NET Types OpenAPI
[Base64String] string "format": "byte"
[Range(..., MinimumIsExclusive = true, MaximumIsExclusive = true)] int, double, IComparable "exclusiveMinimum": true, "exclusiveMaximum": true
[AllowedValues] any (uses object.Equals) anyOf maybe?
[DeniedValues] any (uses object.Equals) pattern maybe? (tricky to get the escaping right)

Describe the solution you'd like

Please take the entries in the table above into consideration.

Additional context

No response

@martincostello martincostello added the help-wanted A change up for grabs for contributions from the community label Jun 20, 2024
@jgarciadelanoceda
Copy link
Contributor

I am working on it :)

@jgarciadelanoceda
Copy link
Contributor

jgarciadelanoceda commented Jun 20, 2024

I have doubts regarding AllowedValues.
I think that in the Spec we can see that for AllowedValues this is done with the enum keyWord:
https://swagger.io/docs/specification/describing-parameters/

The DeniedValues could be done with a Regex but I prefer waiting for it to be a built in function, on the OpenApi spec

@bkoelman
Copy link
Contributor Author

That's understandable. It highly depends on how the popular client generators and SwaggerUI interpret these constructs. Enum values aren't quoted in the spec, so I wonder how strings containing whitespace would work.

I'm fine with leaving them out, I just listed them for completeness.

@jgarciadelanoceda
Copy link
Contributor

Ok then so I am removing the draft from the PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature suggestion help-wanted A change up for grabs for contributions from the community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants