swaggo / fiber-swagger

fiber middleware to automatically generate RESTful API documentation with Swagger 2.0.
MIT License
39 stars 12 forks source link

Reverse proxy configuration #7

Open lucasoares opened 2 years ago

lucasoares commented 2 years ago

I'm using swag with fiber but I can't configure correctly the swagger definition to access the documentation behind a reverse proxy or multiple accesses.

In my use case I have three ways of accessing applications' documentation:

  1. From the proxy using a custom host and path. Example: https://my-proxy/custom/path/swag/index.html
  2. From the pod's direct IP. Example: http://123.123.1.2/swag/index.html
  3. From a port forwarding, which basically follows the same rule of 2.

The problem: I can't make basePath dynamic. It will always have one single value. And because of that the Try it out button may only work from one of those access.

Would be nice to have in swag's implementation a way of adding a prefix to the basePath in the swag.ReadDoc() call (or a new one).

If this is implemented I will be able to change the implementation of gofiber's swagger to use the X-Forwarded-Prefix header as prefix for the basePath using swag.

Thanks.

Openning by requested in https://github.com/swaggo/swag/issues/1210