Writing the OpenAPI Specification
The OpenAPI Specification (formerly known as the Swagger Specification) is an API description format or API definition language. It allows you to describe an API, including the following information:
- General information about the API
- The available paths and operations (HTTP methods)
- The expected inputs (query or path parameters, request body, and so on) and responses (HTTP status code, response body, and so on) for each operation
Finding an easy way to generate the OpenAPI definition from an existing API can be challenging. The good news is that Swagger tools can help you do this with ease.
Installing Go Swagger
To get started, install the go-swagger
tool from the official guide at https://goswagger.io/install.html or download the binary from GitHub at https://github.com/go-swagger/go-swagger/releases. At the time of writing this book, the latest stable version is v0.25.0: