OpenAPI lets us define RESTful APIs in a standardized manner, and they can be defined without being tied down to any particular programming language or framework being used. This provides us with a powerful abstraction to define an API that can have the initial implementation of the RESTful server in Java or Python; also we can port the codebase to Go, with little to no change in the behavior of the service.
Let's list the general structure of an OpenAPI specification and use it to redefine the Books API described in Chapter 4, The RESTful Web.
If we look at the Books API title, we can define the following elements to describe the API:
- The URL to our server
- The basic information about the intent of the API
- The paths available in our API
- The methods available per each of the paths in the API
- The possible description and example payloads for the requests...