Describe an HTTP API in an OpenAPI document
8 steps · about 1 h 6 min · Beginner
- Start with what an OpenAPI description is for (guide, OpenAPI Initiative, 6 min)
Explains how one file drives docs, client code and tests.
- Lay out the top-level structure of an OpenAPI file (guide, OpenAPI Initiative, 8 min)
Shows the required fields and how the document is organised.
- Describe API endpoints with paths and operations (guide, OpenAPI Initiative, 10 min)
Covers how each URL and HTTP method is written down.
- Document path, query and header parameters (guide, OpenAPI Initiative, 8 min)
Makes inputs explicit so clients stop guessing.
- Define request and response bodies with schemas (guide, OpenAPI Initiative, 10 min)
Shows how payload shapes and media types are described.
- Reuse schemas and responses with components and $ref (guide, OpenAPI Initiative, 8 min)
Keeps a growing description small and consistent.
- Lint the description against style rules with Spectral (reference, Stoplight, 10 min)
Catches missing fields and inconsistent naming automatically.
- Validate the file in CI with Redocly CLI lint (reference, Redocly, 6 min)
Adds a pass/fail check so the description stays valid.