Template REST api
$ make local
go get swagger: go get -u github.com/swaggo/swag/cmd/swag
generate doc: swag init -g cmd/server/main.go
Add some description:
// @title Go Learn REST API
// @version 1.0
// @description Golang REST API
// @contact.name Duc PX
// @contact.url https://github.com/ducpx
// @contact.email [email protected]
// @BasePath /api/v1
In handler, register docs api to server
import (
_ "github.com/ducpx/rest-api/docs"
echoSwagger "github.com/swaggo/echo-swagger"
)
...
e.GET("/swagger/*", echoSwagger.WrapHandler)