OData query parameters in Swagger UI in Web API project for .NET 6 (core)? #602
Replies: 1 comment
|
Yes, the API Explorer package you found is the route to take. OData 8 support was added in API Versioning 6.0, including query-option discovery for OpenAPI. The maintainer covers the packages and setup in this issue, in the April 9, 2022 reply. The relevant package is services.AddApiVersioning()
.AddMvc()
.AddApiExplorer()
.AddOData()
.AddODataApiExplorer();That's the explorer registration, rather than a complete OData/Swagger configuration. You still need your EDM, routes and Swashbuckle setup. The explorer can derive query parameters from OData query attributes and conventions, so you don't have to hard-code the same list on every operation. For an existing .NET 6 app, use package versions that target .NET 6; the latest documentation examples now target newer frameworks. The query-options documentation links to the current docs and explains how to customize which options are exposed. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
Is it possible in version 8 to show the OData query parameters in the Swagger UI for a Web API project in .NET 6 (core)?
This used to be possible using the Api Explorer in previous versions.
There's a new Asp package for the Api Explorer (which I found on the versioning Github repo), except it's still in beta for OData 8.
The only possible solution I've found so far is using this ugly hack, which adds the parameters in a static way:
https://stackoverflow.com/questions/41973356/is-there-a-way-to-get-swashbuckle-to-add-odata-parameters-to-web-api-2-iqueryabl
Is there any way to dynamically add the OData query parameters in the Swagger UI for .NET 6 in a Web API project?
All reactions