Complete reference for OpenAPI 3.0 schema structure, components, and best practices for documenting REST APIs.
OpenAPI Specification (formerly Swagger) is a standard, language-agnostic interface for RESTful APIs. It allows both humans and computers to understand API capabilities without accessing source code.
| Field | Required | Description |
|---|---|---|
| openapi | Yes | OpenAPI version (3.0.0 or 3.0.1) |
| info | Yes | API metadata (title, version, description) |
| servers | No | Server connection info |
| paths | Yes | Available endpoints and operations |
| components | No | Reusable schemas, parameters, responses |
| security | No | Global security requirements |
| tags | No | Tags for grouping operations |
Tools like Swagger UI allow users to select which server to use for testing. List servers in order of preference (production first).
| Field | Type | Description |
|---|---|---|
| summary | string | Short description |
| description | string | Detailed description (Markdown) |
| operationId | string | Unique operation identifier |
| tags | array | Grouping tags |
| parameters | array | Query, path, header parameters |
| requestBody | object | Request body definition |
| responses | object | Possible responses (required) |
| security | array | Override global security |
| Type | Format | Example |
|---|---|---|
| string | - | "Hello World" |
| string | "user@example.com" | |
| string | uri | "https://example.com" |
| string | date | "2025-01-15" |
| string | date-time | "2025-01-15T10:30:00Z" |
| string | password | ****** |
| string | byte | Base64 encoded |
| string | binary | File upload |
| integer | int32 | 123 |
| integer | int64 | 9223372036854775807 |
| number | float | 123.45 |
| number | double | 123.456789 |
| boolean | - | true / false |
| array | - | [1, 2, 3] |
| object | - | { } |