An OpenAPI document is a single JSON (or YAML) file that fully describes a REST API. Once you know its four regions, it reads easily.
1. Metadata
{ "openapi": "3.1.0", "info": { "title": "Items API", "version": "1.0.0" } }
- openapi — the spec version.
- info — human metadata: title, version, description.
2. Servers
servers lists base URLs, usually one per environment. Clients prepend these to each path.
3. Paths and operations
paths is the heart of the document. Each key is a URL template; each HTTP method under it is an operation:
"/items": {
"get": { "operationId": "listItems", "responses": { "200": { "description": "OK" } } }
}
Give every operation an operationId — code generators use it to name functions.
4. Components
components holds reusable pieces: schemas (data models), securitySchemes (auth), parameters and responses. Reference them with $ref:
"schema": { "$ref": "#/components/schemas/Item" }
Define a model once, reuse it everywhere.
Why it matters
From one OpenAPI file you can generate interactive docs, server stubs, typed client SDKs and mock servers. That is why "contract-first" API design starts here.
Open the OpenAPI starter template and ask the workspace to "add a DELETE operation" or "add pagination" — then review the change as a diff.