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

Multiple API versions or API Definitions in single server #197

Open
mandeepji opened this issue Feb 11, 2022 · 5 comments
Open

Multiple API versions or API Definitions in single server #197

mandeepji opened this issue Feb 11, 2022 · 5 comments

Comments

@mandeepji
Copy link

Hi,
How can I support multiple versions (definitions) of APIs from single server?

Problem Statement:
Product has to support multiple versions (latest & backward compatible) at different paths like:
/v1/...
/v2/...
And have different swagger.yaml for each version.

Multiple versions could be using path variable (/{version}/...) but makes difficult to generate version specific output.

@ubogdan
Copy link
Contributor

ubogdan commented Apr 22, 2022

@mandeepji you can take a look at the following example.

@solamiku
Copy link

solamiku commented Jul 21, 2022

@mandeepji you can take a look at the following example.
@ubogdan
Hi,
I fllow the example: https:/swaggo/gin-swagger/tree/master/example/multiple, and found a bug below:
First i visit the v1 api document at: http://localhost:8080/swagger/v1/index.html
and then visit the v2 api document at http://localhost:8080/swagger/v2/index.html and get the true response all.
But last when i back to the v1 api document the *.css and *.js can not found.

@fzdy1914
Copy link
Contributor

fzdy1914 commented Jul 28, 2022

@ubogdan
Hi,
I fllow the example: https:/swaggo/gin-swagger/tree/master/example/multiple, and found a bug below:
First i visit the v1 api document at: http://localhost:8080/swagger/v1/index.html
and then visit the v2 api document at http://localhost:8080/swagger/v2/index.html and get the true response all.
But last when i back to the v1 api document the *.css and *.js can not found.

Hi, I faced the same issue

Reason, swaggerFiles.Handler is one single instance and patching the Prefix twice will end up making the request from first prefix invalid.

One ugly workaround is to use lower level of gin-swagger. For swaggerfiles.Handler, one from "github.com/swaggo/gin-swagger/swaggerFiles", one from "github.com/swaggo/files".

Updated: Use swaggerFiles.NewHandler() instead of swaggerFiles.Handler .

@ubogdan
Copy link
Contributor

ubogdan commented Aug 2, 2022

@fzdy1914, Would you mind updating the gin-swagger code base, please? I'm pretty busy this week.

@fzdy1914
Copy link
Contributor

fzdy1914 commented Aug 3, 2022

@fzdy1914, Would you mind updating the gin-swagger code base, please? I'm pretty busy this week.

@ubogdan Can check #224.

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

No branches or pull requests

4 participants