3 Our first taste of OpenAPI definitions

 

This chapter covers

  • Informal versus formal descriptions
  • Learning about the OpenAPI specification
  • Learning about YAML
  • Describing our first GET operation

OpenAPI definitions are at the heart of automating our API workflows. They are the slices of bread in a sandwich shop, the fruit on a breakfast buffet, and the vanilla in vanilla muffins, which is our way of saying that they’re important.

When we formally describe an API, we’re turning the idea of that API into some data, which we call a definition. It differs from an informal description, which has no strict rules or syntactical structure. Informal descriptions are akin to documentation found on websites—great for humans to read, but hard for machines to decipher.

Once an API has been described in a definition, the definition can be used by tools (machines) fueling different parts of the API ecosystem, such as API request validation, code stubs, documentation, and more. Figure 3.1 illustrates where definitions fit into the scheme of things.

Figure 3.1 Tool and workflow examples around OpenAPI definition
03-01

If movies have taught us anything, it’s that machines shouldn’t have too much power, else they’ll take over the world. However, they should be able to help us out just a little!

Warning

API definitions both excite and propel us, and as such, we will continue to wax lyrical on the merits of API definitions. You’ve been warned!

3.1 The problem

3.2 Introducing the OpenAPI specification

3.3 A quick refresher on YAML

3.3.1 From JSON to YAML

3.4 Describing our first operation

3.5 Extending our first operation

Summary

sitemap