This is a utility for automatically generating API documentation from annotations in Go code. It generates the documentation as JSON, according to the Swagger Spec, and then displays it using Swagger UI.
This tool was inspired by Beego, and follows the same annotation standards set by Beego.
The main difference between this tool and Beego is that this generator doesn't depend on the Beego framework. You can use any framework to implement your API (or don't use a framework at all). You just add declarative comments to your API controllers, then run this generator and your documentation is ready! For an example of what such documentation looks like when presented via Swagger UI, see the Swagger pet store example.
-apiPackage - package with API controllers implementation
-mainApiFile - main API file. We will look for "General API info" in this file. If the mainApiFile command-line switch is left blank, then main.go is assumed (in the location specified by apiPackage).
-format - One of: go|swagger|asciidoc|markdown|confluence. Default is -format="go". See below.
-output - Output specification. Default varies according to -format. See below.
-controllerClass - Speed up parsing by specifying which receiver objects have the controller methods. The default is to search all methods. The argument can be a regular expression. For example, -controllerClass="(Context|Controller)$" means the receiver name must end in Context or Controller.
To run the generated swagger UI (assuming you used -format="go"), copy/move the generated docs.go file to a new folder under GOPATH/src. Also bring in the web.go-example file, renaming it to web.go. Then: go run web.go docs.go
@APIVersion 1.0.0 @APITitle Swagger Example API @APIDescription Swagger Example API @Contact varyous@gmail.com @TermsOfServiceUrl http://yvasiyarov.com/ @License BSD @LicenseUrl http://yvasiyarov.com/
@APIVersion 1.0.0 @APITitle Swagger Example API @APIDescription Swagger Example API @Contact varyous@gmail.com @TermsOfServiceUrl http://yvasiyarov.com/ @License BSD @LicenseUrl http://yvasiyarov.com/