Micronaut Mastery: Documenting Our API Using Spring REST Docs
Spring REST Docs is a project to document a RESTful API using tests. The tests are used to invoke real REST calls on the application and to generate Asciidoctor markup snippets. We can use the generated snippets in an Asciidoctor document with documentation about our API. We can use Spring REST Docs to document a REST API we create using Micronaut.
First we must change our build file and include the Asciidoctor plugin and add dependencies to Spring REST Docs.
The following example Gradle build file adds the Gradle Asciidoctor plugin, Spring REST Docs dependencies and configures the test
and asciidoctor
tasks.
Spring REST Docs supports three different web clients to invoke the REST API of our application: Spring MockMVC, Spring Webflux WebTestClient and REST Assured.
We use REST Assured 3, because it has little dependencies on other frameworks (like Spring).