OpenAPI Specification

A standard format for describing REST APIs, enabling documentation and code generation.

OpenAPI Specification (formerly Swagger) is an industry-standard format for describing RESTful APIs. It allows both humans and machines to understand API capabilities.

Benefits of OpenAPI

  • Documentation: Auto-generate interactive API docs
  • Code Generation: Create client SDKs and server stubs
  • Validation: Verify requests and responses
  • Mock Servers: Generate fake APIs for testing
  • Testing: Create automated test cases

Key Components

  • Paths: API endpoints and operations
  • Schemas: Data models and types
  • Parameters: Query, path, and header params
  • Responses: Expected response formats
  • Security: Authentication methods

Code Examples

OpenAPI YAML

openapi: 3.0.0
info:
  title: Users API
  version: 1.0.0
paths:
  /users:
    get:
      summary: List users
      responses:
        200:
          description: Success