swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
25.98k stars 8.85k forks source link

API versioning using custom header #6485

Open keithotto opened 3 years ago

keithotto commented 3 years ago

Q&A (please complete the following information)

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.

chunghha commented 2 years ago

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

ohroy commented 2 years ago

I need this too, or is any way to get current api version name in js then I can do it self?

bhrigushr commented 1 year ago

@chunghha @rozbo did you find a way to get it working? Or you have found a way to solve this issue.

priyankinfinnov commented 1 year ago

I am stuck with the same issue, @chunghha @rozbo did you find any fix or alternative for this?

pbrennand-francis commented 1 year ago

I'd also appreciate a fix or workaround for this if anyone has one.

MNorgren commented 4 months ago

Bump - This would be a great feature

superkeil commented 1 month ago

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 ?

kosiakMD commented 3 weeks ago

same for me