

However, there are some features I felt were necessary to be built on top. The combination of Negroni and Gorilla MUX is a useful combination for buildng REST applications. For that, we use reflection on the MakeMessage field - the mechanism we used for sort-of-strong-dynamic typing when consuming data, as seen in a prior installment on this topic.Īs an example, here is Swagger YAML for the Policy service.

If import is unsuccessful, skip this step. Walks through all directories and tries to import each one (using Import()).The first step is to run Analyzer on the entire repository. The entry point of the doc tool for generating the Swagger docs is in doc.go.

#Godocs go michigan code#
But a similar approach can be taken without Romana-specific code - or Romana approach can be adopted. NOTE: This approach assumes the services are based on the Romana-specific REST layer on top of Negroni and Gorilla MUX. It is not yet available as a separate project, so I will go over the code in the main Romana code base. Why not automate this process, sort of like godoc? Here I walk you through an initial attempt at doing that - a Go program that takes as input Go-based REST service code and outputs Swagger YAML files. But writing out JSON files by hand seemed not just tedious (and thus error-prone), but also likely to result in an outdated documentation down the road. As someone who offers a REST API, we at Romana project wanted to provide documentation on it via Swagger.
