Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 1.18 KB

swagger.md

File metadata and controls

38 lines (25 loc) · 1.18 KB

Swaggo setup

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:

swag

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.

http-swagger

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.

Generate Swagger documentation

Adding annotations in code

If you have not added the annotations, follow these docs

Generating Swagger specs (swagger.json and swagger.yaml)

From the root folder of l3afd run following command

swag init -d "./" -g "apis/configwatch.go"