Documenting microservices
The traditional approach of API documentation is either by writing service specification documents or using static service registries. With a large number of microservices, it would be hard to keep the documentation of APIs in sync.
Microservices can be documented in many ways. This section will explore how microservices can be documented using the popular Swagger framework. The following example will use Springfox libraries to generate REST API documentation. Springfox is a set of Java- and Spring-friendly libraries.
Create a new Spring Starter Project and select Web in the library selection window. Name the project chapter2.swagger
.
Note
The full source code of this example is available as the chapter2.swagger
project in the code files of this book.
As Springfox libraries are not part of the Spring suite, edit pom.xml
and add Springfox Swagger library dependencies. Add the following dependencies to the project:
<dependency> <groupId>io.springfox<...