API versioning using custom header
Q&A (please complete the following information)
- OS: Windows
- Browser: Chrome
- Version: [e.g. 22]
- Method of installation: nuget (packaged with Swashbuckle.AspNetCore)
- Swagger-UI version: 3.32.5
- Swagger/OpenAPI version: OpenAPI 3.0
How can we help?
I can't find any information on this for supporting multiple versions of an API. If I want to version my API using a custom header (ie. x-api-version), is it possible to get the "Try it Out" feature of Swagger-UI to pass the correct version header and number based on the selected definition?
I already have my server outputting the two separate swagger.json files for the versions. And I can select between them in the UI and see the correct documentation. But I can't see how to send the version number with the try it out requests.
I assume I will have to use the requestInterceptor but I couldn't find any documentation on how to retrieve the currently selected api definition so I know which version number to add to the header.
As this package used with NestJS, I have same question. How multi versioning on customer header (my case, "version") can be supported by this package.
https://github.com/nestjs/swagger/issues/1497
I need this too, or is any way to get current api version name in js then I can do it self?
@chunghha @rozbo did you find a way to get it working? Or you have found a way to solve this issue.
I am stuck with the same issue, @chunghha @rozbo did you find any fix or alternative for this?
I'd also appreciate a fix or workaround for this if anyone has one.
Bump - This would be a great feature
I already have my server outputting the two separate swagger.json files for the versions. And I can select between them in the UI and see the correct documentation.
Hi @keithotto
how did you manage that ?