Search results

Activity: Create an OpenAPI specification document

The OpenAPI tutorial walked you through 8 steps in building the OpenAPI specification document. Now it’s your turn to practice first editing and then creating an OpenAPI specification document.

Activity: Edit an existing OpenAPI specification document

Use this simple Sunrise and sunset times API to get more familiar with the process of creating an OpenAPI specification file. This Sunrise and sunset times API doesn’t require authentication with requests, so it removes some of the more complicated authentication workflows (the spec file doesn’t require the security object). In this activity, you’ll edit some of the existing values in an OpenAPI specification document that’s already written.

To edit the OpenAPI specification file:

  1. Copy the code from this pre-built OpenAPI specification.
  2. Paste the YAML content into the Swagger Editor.
  3. Identify each of the root-level objects of the OpenAPI spec:
  4. In the info object (near the top), make some changes to the description property and see how the visual display in the right column gets updated.
  5. In the parameters object, make some changes to one of the description properties and see how the visual editor gets updated.
  6. Look for the $ref pointer in the responses object. Identify what it points to in components.
  7. Change some spacing in a way that makes the spec invalid (such as inserting a space before info), and look at the error that appears. Then revert the invalid space.
  8. Expand the Get section and click Try it out. Then click Execute and look at the response.

Create the OpenAPI specification document for an API of your choosing

In an earlier activity, you found an open-source API project with some documentation needs. Try creating an OpenAPI specification for this API. Depending on the API you choose to work with, you could potentially use this specification document as part of your portfolio.

If your open-source project doesn’t have an API, or if it’s API already has an OpenAPI specification, find another API (perhaps from this list of 100+ APIs) and create the OpenAPI specification.

Go through each step of the OpenAPI specification tutorial to build out the specification document:

Validate your specification document in the Swagger Editor. Execute a request to make sure it’s working correctly.

Buy me a coffee
50% Complete

50/145 pages complete. Only 95 more pages to go.