chapter five
5 Documenting REST APIs with OpenAPI
This chapter covers
- Using JSON Schema to create validation models for JSON documents
- Describing REST APIs with the OpenAPI documentation standard
- Modelling the payloads for API requests and responses
- Creating reusable schemas in OpenAPI specifications
In this chapter, you’ll learn to document APIs using the OpenAPI. OpenAPI is the most popular standard for describing RESTful APIs, and it has a rich ecosystem of tools for testing, validating, and visualizing APIs. Most programming languages have libraries that support OpenAPI specifications, and in chapter 6 you’ll learn to use OpenAPI-compatible libraries from the Python ecosystem.
OpenAPI uses JSON Schema to describe an API’s structure and models, so we start by providing an overview of how JSON Schema works. JSON Schema is a specification for defining the structure of a JSON document, including the types and formats of the values within the document.