---
title: "Chapter 5: Step-by-step OpenAPI code tutorial"
date: 2026-10-13
description: "Download PDF Whereas the previous chapter involved building and publishing OpenAPI specification using a visual editor (Stoplight), in this chapter you code the spec by hand..."
canonical_url: https://idratherbewriting.com/learnapidoc/openapi_tutorial
---

> For AI agents: a documentation index is available at https://idratherbewriting.com/llms.txt. Markdown versions of all pages are available by appending .md to any page URL.

# Chapter 5: Step-by-step OpenAPI code tutorial

[Download PDF](https://www.buymeacoffee.com/learnapidoc/e/146076)

Whereas the previous chapter involved building and publishing OpenAPI specification using a visual editor (Stoplight), in this chapter you code the spec by hand following a step-by-step tutorial using the Swagger Editor. You populate each of the main objects in the OpenAPI spec: `openapi`, `info`, `servers`, `paths`, `components`, `security`, `tags`, and `externalDocs`. For each object, you can refer to code samples and see how the source maps to the documentation output. The goal is to gain familiarity with the OpenAPI objects and properties by building a valid OpenAPI file from scratch.

If you’re a beginner or want a visual editor, check out the [Getting started tutorial: Using Stoplight to create an OpenAPI specification document](https://idratherbewriting.com/learnapidoc/pubapis_openapis_quickstart_stoplight.html) instead.

- [OpenAPI tutorial using Swagger Editor and Swagger UI: Overview](https://idratherbewriting.com/learnapidoc/pubapis_openapi_tutorial_overview.html)
- [Working in YAML](https://idratherbewriting.com/learnapidoc/pubapis_yaml.html)
- [Step 1: The openapi object](https://idratherbewriting.com/learnapidoc/pubapis_openapi_step1_openapi_object.html)
- [Step 2: The info object](https://idratherbewriting.com/learnapidoc/pubapis_openapi_step2_info_object.html)
- [Step 3: The servers object](https://idratherbewriting.com/learnapidoc/pubapis_openapi_step3_servers_object.html)
- [Step 4: The paths object](https://idratherbewriting.com/learnapidoc/pubapis_openapi_step4_paths_object.html)
- [Step 5: The components object](https://idratherbewriting.com/learnapidoc/pubapis_openapi_step5_components_object.html)
- [Step 6: security object](https://idratherbewriting.com/learnapidoc/pubapis_openapi_step6_security_object.html)
- [Step 7: The tags object](https://idratherbewriting.com/learnapidoc/pubapis_openapi_step7_tags_object.html)
- [Step 8: The externalDocs object](https://idratherbewriting.com/learnapidoc/pubapis_openapi_step8_externaldocs_object.html)
- [Step 9: Other elements: webhooks and jsonSchemaDialect](https://idratherbewriting.com/learnapidoc/pubapis_openapi_step9_other_elements.html)
- [Activity: Create an OpenAPI specification document](https://idratherbewriting.com/learnapidoc/pubapis_openapi_activity.html)
