Skip to content
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

API versioning using custom header #6485

Open
keithotto opened this issue Oct 7, 2020 · 8 comments
Open

API versioning using custom header #6485

keithotto opened this issue Oct 7, 2020 · 8 comments

Comments

@keithotto
Copy link

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.

@chunghha
Copy link

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.

nestjs/swagger#1497

@ohroy
Copy link

ohroy commented Oct 22, 2021

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

@bhrigushr
Copy link

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

@priyankinfinnov
Copy link

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

@pbrennand-francis
Copy link

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

@MNorgren
Copy link

MNorgren commented Feb 7, 2024

Bump - This would be a great feature

@superkeil
Copy link

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
Copy link

same for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants