forked from swaggo/echo-swagger
/
main.go
34 lines (27 loc) · 944 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
echoSwagger "github.com/dwlpra/echo-swagger"
_ "github.com/dwlpra/echo-swagger/example/docs" // docs is generated by Swag CLI, you have to import it.
"github.com/labstack/echo"
)
// @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()
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"))
}