I want to be able to register multiple hosts so that the production environment and development environment can be used simultaneously
Does this library provide such functionality?
First of all swag it's an cli application that generate OpenAPI 2.0 Specification from your go code annotations.
When ever you use the generated documentation into a http Handler (no matter what type), you can change the endpoint by assingin a new value to variable Host of SwaggerInfo object of your documentation.
import ("github.com/swaggo/swag/example/basic/docs/docs.go")
func register_routes(router) error {
docs.SwaggerInfo.Host = "http://new.endpoint"
}
Unfortunately there is no way to do that in OpenAPI 2.0, so you will have to do that at runtime.
Just added this line ...
docs.SwaggerInfo.Host = *host + ":" + *port
host and port the flags to the application.
Thank you so much, You've been very helpful!
Most helpful comment
First of all swag it's an cli application that generate OpenAPI 2.0 Specification from your go code annotations.
When ever you use the generated documentation into a http Handler (no matter what type), you can change the endpoint by assingin a new value to variable Host of SwaggerInfo object of your documentation.
Unfortunately there is no way to do that in OpenAPI 2.0, so you will have to do that at runtime.