gofiber / swagger

🧬 fiber middleware to automatically generate RESTful API documentation with Swagger
MIT License
416 stars 31 forks source link

Failed to load API definition #61

Closed heath140 closed 1 year ago

heath140 commented 1 year ago

I'm having an issue where I cannot get the swagger API definition file to load in a K8s environment behind a reverse proxy.

The swagger page (index.html) will load just fine, however it is looking for the json file but cannot find it because it needs to be directed to a slightly modified URL. It is all working locally without issue. I would like it retain the default base URL that it is using, just modify the path slightly. Here is the example:

path to swagger (working): https:///v2/swagger/index.html path it is looking for to load documents: https:///swagger/doc.json

The error appears to be that it should be directed to https:///v2/swagger/doc.json (which I can get to and view)

Is there a way here to direct it towards the modified path without hard coding the "my_api" portion so that I can keep my builds for staging and production without needing to specify those absolute paths?

in the header, if I modify the "Explore" path from /swagger/doc.json to /v2/swagger/doc.json it works just fine, is there a way I can have it do this automatically?

heath140 commented 1 year ago

I fixed this issue using the "URL" part of the configure in swagger.

My swagger route is now:

route.Get("*", swagger.New(swagger.Config{
        URL: "/v2/swagger/doc.json",
    }))