Our first task is to install the libraries we are dependent on. Run the following commands from the commandline:
go get -u github.com/swaggo/swag/cmd/swag
go get -u github.com/swaggo/http-swagger
go get -u github.com/alecthomas/template
The first two commands install swag and http-swagger respectively:
This library converts Go annotations to Swagger 2.0 docs (swagger.json/swagger.yaml), which are later used by http-swagger to serve the Swagger UI.
This library helps to serve the Swagger UI using the docs generated by swag.
The third command is to install template, a fork of Go’s text/template package. This dependency is required in the docs.go file generated by swag, and we’ll see an error while running the application without it.
If you have not added the annotations, follow these docs
- https://www.soberkoder.com/swagger-go-api-swaggo/
- https://github.com/swaggo/swag#declarative-comments-format
From the root folder of l3afd
run following command
swag init -d "./" -g "apis/configwatch.go"