gin-swagger
gin-swagger copied to clipboard
Multiple API versions or API Definitions in single server
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:
Multiple versions could be using path variable (
@mandeepji you can take a look at the following example.
@mandeepji you can take a look at the following example. @ubogdan Hi, I fllow the example: https://github.com/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.
@ubogdan Hi, I fllow the example: https://github.com/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
.
@fzdy1914, Would you mind updating the gin-swagger code base, please? I'm pretty busy this week.
@fzdy1914, Would you mind updating the gin-swagger code base, please? I'm pretty busy this week.
@ubogdan Can check https://github.com/swaggo/gin-swagger/pull/224.