6 Describing HTTP operations with OpenAPI
This chapter covers
- Introduction to the OpenAPI Specification
- Describing resource paths
- Describing HTTP operations
- Describing HTTP operations’ inputs and outputs
Our API designer’s job could be considered done. We have designed a versatile REST API exposing capabilities that meet the needs identified in the Define stage of the API lifecycle. But we described the programming interface using a spreadsheet; it could also have been a word processor document or a wiki page. These formats are not made for this task; authoring and maintaining such documents can be complex and error-prone. A more efficient way is to use an API specification, a standard format for describing APIs. The OpenAPI Specification is the most common for REST APIs, simplifying design, reducing errors, and facilitating discussions while enabling more than just describing APIs and benefiting the rest of the API lifecycle.
After introducing OpenAPI, this chapter shows how the “Describe the programming interface” step of the API design process parallels “Design the programming interface.” Then we discuss how to author OpenAPI documents and provide an overview of the steps to create an OpenAPI document describing the HTTP operations as we design them. We also go through these steps to describe the API’s resources and operations and their inputs and outputs. The following chapter describes data models as we design them.