You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ go get -d github.com/swaggo/swag/cmd/swag
# 1.21 or newer
$ go install github.com/swaggo/swag/cmd/swag@latest
Run the Swag in your Go project root folder which contains main.go file, Swag will parse comments and generate required files(docs folder and docs/doc.go).
package main
import (
"github.com/labstack/echo/v4""github.com/swaggo/echo-swagger"
_ "github.com/swaggo/echo-swagger/example/docs"// docs is generated by Swag CLI, you have to import it.
)
// @title Swagger Example API// @version 1.0// @description This is a sample server Petstore server.// @termsOfService https://swagger.io/terms/// @contact.name API Support// @contact.url https://www.swagger.io/support// @contact.email support@swagger.io// @license.name Apache 2.0// @license.url https://www.apache.org/licenses/LICENSE-2.0.html// @host petstore.swagger.io// @BasePath /v2funcmain() {
e:=echo.New()
e.GET("/swagger/*", echoSwagger.WrapHandler)
e.Logger.Fatal(e.Start(":1323"))
}
OpenAPI Specification (OAS) 3.0
package main
import (
"github.com/labstack/echo/v4""github.com/swaggo/echo-swagger"
_ "github.com/swaggo/echo-swagger/example/docs"// docs is generated by Swag CLI, you have to import it.
)
// @title Swagger Example API// @version 1.0// @description This is a sample server Petstore server.// @termsOfService https://swagger.io/terms/// @contact.name API Support// @contact.url https://www.swagger.io/support// @contact.email support@swagger.io// @license.name Apache 2.0// @license.url https://www.apache.org/licenses/LICENSE-2.0.html// @host petstore.swagger.io// @BasePath /v2funcmain() {
e:=echo.New()
e.GET("/swagger/*", echoSwagger.WrapHandlerV3)
e.Logger.Fatal(e.Start(":1323"))
}