-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Support all styles of Open API/swagger parameter serialization #6906
Comments
I don't think either of the two OpenAPI toolchains we document and test against - NSwag or Swashbuckle - support the OpenAPI v3 spec. The v2 spec does not have a way to represent query string serialization format. Even if AspNetCore \ MVC added support for specifying the serialization format, your Swagger document wouldn't have a way to represent it. |
Under Array and Multi-Value Parameters you can see the v2 alternative of ”collection” style. Csv is the default but aspnet uses ”multi” with ampersands. Why? |
NSwag already supports most of the OpenAPI 3 features, see RicoSuter/NSwag#945 |
It would make sense to add this so that the model binder acts on it and the spec generators can read it via api explorer |
At the moment I think you have to customize the model binder and implement a custom nswag operation processor which correctly transforms the parameters... |
Btw, jQuery's param() method serializes arrays with square brackets by default (see examples below for versions >=1.4), which does not work with AspNetCore.
It would be great if AspNetCore supported that format as well. Note that it works fine in the old Web API for .Net Framework. |
Thanks for contacting us, @MikaelUmaN. |
Is your feature request related to a problem? Please describe.
I would like to be able to choose what style to use for array parameters (and complex parameters in general) in Web Api methods.
https://swagger.io/docs/specification/serialization/
I want to be able to have comma-separated values, rather than ampersand concatenated. This prevents some APIs from becoming way to verbose and not user-friendly.
Describe the solution you'd like
Support for global conventions to use when serializing.
Support for local overrides of that convention via attribute annotations:
[FromQuery(style=form,explode=false)] int[] userIds
Then I can call the method using a URL containing: userIds=1,2,3
Above is for v3. For v2 the collectionFormat should be able to be declared for lists and arrays.
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: