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

Is it possible to fill in parameters from the configuration? #42

Closed
outdead opened this issue Mar 26, 2021 · 4 comments
Closed

Is it possible to fill in parameters from the configuration? #42

outdead opened this issue Mar 26, 2021 · 4 comments

Comments

@outdead
Copy link

outdead commented Mar 26, 2021

The canonical example describes how to fill parameters with hardcode:

// @title Swagger Example API
// @version 1.0
// @host petstore.swagger.io
// @BasePath /v2

Is it possible to fill in parameters from the configuration or something template?

// @title Swagger Example API
// @version {{APP_VERSION}}
// @host {{APP_HOST}}
// @BasePath /v2
@roppa
Copy link

roppa commented Jun 4, 2021

I'm looking for this for echo too. Looks like gin-swagger can do this.

@ubogdan
Copy link
Contributor

ubogdan commented Aug 11, 2021

This is not router specific feature , it is related to the generated documentation. See source code.

package main

import (
	"github.com/labstack/echo/v4"
	"github.com/swaggo/echo-swagger"
	"github.com/swaggo/swag/example/basic/docs"
)

// @title Swagger Example API
// @version 1.0
// @description This is a sample server Petstore server.
// @termsOfService http://swagger.io/terms/

// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io

// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html

// @host petstore.swagger.io
// @BasePath /v2
func main() {
	e := echo.New()

	docs.SwaggerInfo.Version = "Test"
	docs.SwaggerInfo.Host = "test.io"
	docs.SwaggerInfo.BasePath = "/v3"
	docs.SwaggerInfo.Schemes = []string{"http"}
	docs.SwaggerInfo.Title = "Demo server"
	docs.SwaggerInfo.Description = "This is a sample server Petstore server."

	e.GET("/swagger/*", echoSwagger.WrapHandler)

	/*
		Or can use EchoWrapHandler func with configurations.
		url := echoSwagger.URL("http://localhost:1323/swagger/doc.json") //The url pointing to API definition
		e.GET("/swagger/*", echoSwagger.EchoWrapHandler(url))
	*/
	e.Logger.Fatal(e.Start(":1323"))
}

@roppa
Copy link

roppa commented Aug 12, 2021

Ahh I see. Ok thank you very much

@outdead
Copy link
Author

outdead commented Aug 12, 2021

This is great. Thanks!

@outdead outdead closed this as completed Aug 12, 2021
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

3 participants