chapter five
This chapter covers
- Learning about JSON Schema and how to describe data
- Describing the
200response ofGET /reviews
- Adding the response definition piece into our FarmStall API
Data makes the world go round
…or maybe that’s money?
In this chapter we’re going to describe a simple HTTP response with OpenAPI and add it to our FarmStall API definition. Responses are the fuel for consumers and they can be large/complex. Describing them is an important part of communicating an API.
An HTTP response is made up of three things. A status code, a set of headers and an optional body. We’re going to focus on the status code and body for now and leave response headers for another chapter.
A response definition in OpenAPI needs at least a status code and a description. If there is a response body it must include at least one media type (eg: application/json).