Documenting and exposing an API with Swagger

This section details how to provide and expose metadata about the REST API using Swagger.

Getting ready

We are often required to document APIs for users and customers. When documenting an API, depending on the tools we use, we often get a few extras such as the ability to generate client code from the API metadata or even the generation of integrated test harnesses for the API.

There isn't yet a recognized and universal standard for the format of the API metadata. This lack of standards leads to a quite a few different solutions on the market for the REST documentation.

We have chosen Swagger here because it has the largest and the most active community. It has existed since 2011, and it offers a very nice ...

Get Spring MVC: Designing Real-World Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.