Activity: Create an OpenAPI specification document
I need your input — I'm conducting a survey about trends in developer documentation for 2020. If you write docs for developers, please take this survey. (You can view the ongoing results viewed here.)
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
- Create the OpenAPI specification document for an API of your choosing
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:
- Copy the code from this pre-built OpenAPI specification.
- Paste the YAML content into the Swagger Editor.
- Identify each of the root-level objects of the OpenAPI spec:
- In the
infoobject (near the top), make some changes to the
descriptionproperty and see how the visual display in the right column gets updated.
- In the
parametersobject, make some changes to one of the
descriptionproperties and see how the visual editor gets updated.
- Look for the
$refpointer in the
responsesobject. Identify what it points to in
- 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.
- 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:
- Step 1: The openapi object
- Step 2: The info object
- Step 3: The servers object
- Step 4: The paths object
- Step 5: The components object
- Step 6: security object
- Step 7: The tags object
- Step 8: The externalDocs object
Validate your specification document in the Swagger Editor. Execute a request to make sure it’s working correctly.
49/128 pages complete. Only 79 more pages to go.