swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

API versioning using custom header

Open keithotto opened this issue 5 years ago • 8 comments

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.

keithotto avatar Oct 07 '20 19:10 keithotto

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

chunghha avatar Aug 16 '21 07:08 chunghha

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

ohroy avatar Oct 22 '21 09:10 ohroy

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

bhrigushr avatar Aug 03 '22 06:08 bhrigushr

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

priyankinfinnov avatar Aug 10 '22 09:08 priyankinfinnov

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

pbrennand-francis avatar Sep 09 '22 02:09 pbrennand-francis

Bump - This would be a great feature

MNorgren avatar Feb 07 '24 19:02 MNorgren

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 ?

superkeil avatar May 06 '24 19:05 superkeil