ConfigGenerator

OpenAPI Generator

Generate OpenAPI YAML and JSON specs with paths, schemas, responses, authentication, examples, tags, and API documentation.

Output:A ready-to-use configuration file for OpenAPI with best practices applied.

API Metadata

A short, descriptive title for your API.

Semantic versioning of your API (e.g., 1.0.0).

A detailed description of what your API does.

Server & Security

The base URL for your production API server.

Schema Content

- Generate mock examples in schema definitions.
- Generate standard error response schemas (e.g., 404, 422).
openapi.yaml

Syntax highlighting disabled for large output (443 lines).

openapi: 3.0.3
info:
  title: My Production API
  version: 1.0.0
  description: Enterprise API providing access to core platform features.
  contact:
    name: API Support
    email: api-support@example.com
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: https://api.example.com/v1
    description: Production Server
  - url: http://localhost:3000
    description: Local Development
paths:
  /users:
    get:
      summary: List users
      description: Returns a paginated list of users. Supports filtering and sorting.
      operationId: listUsers
      tags:
        - Users
      parameters:
        - name: page
          in: query
          description: 'Page number (default: 1)'
          schema:
            type: integer
            default: 1
            minimum: 1
        - name: limit
          in: query
          description: 'Items per page (default: 20, max: 100)'
          schema:
            type: integer
            default: 20
            minimum: 1
            maximum: 100
        - name: sort
          in: query
          description: Sort field
          schema:
            type: string
            enum:
              - createdAt
              - name
              - email
            default: createdAt
        - name: order
          in: query
          description: Sort order
          schema:
            type: string
            enum:
              - asc
              - desc
            default: desc
        - name: search
          in: query
          description: Search by name or email
          schema:
            type: string
      responses:
        '200':
          description: A paginated list of users
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedUsers'
              example:
                data:
                  - id: 123e4567-e89b-12d3-a456-426614174000
                    name: Jane Doe
                    email: jane@example.com
                    role: user
                    createdAt: '2024-01-15T10:30:00Z'
                    updatedAt: '2024-01-15T10:30:00Z'
                meta:
                  total: 1
                  page: 1
                  limit: 20
                  totalPages: 1
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
    post:
      summary: Create a new user
      description: Creates a new user with the provided data. Returns the created user.
      operationId: createUser
      tags:
        - Users
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserInput'
            example:
              name: Jane Doe
              email: jane@example.com
              role: user
      responses:
        '201':
          description: User created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  data:
                    $ref: '#/components/schemas/User'
        '400':
          description: Bad request - Invalid input
        '401':
          description: Unauthorized - Invalid or missing authentication
        '409':
          description: Conflict - User with this email already exists
        '422':
          description: Validation failed
        '429':
          description: Rate limit exceeded
        '500':
          description: Internal server error
  /users/{id}:
    get:
      summary: Get a user by ID
      description: Returns a single user by their unique identifier.
      operationId: getUser
      tags:
        - Users
      parameters:
        - name: id
          in: path
          required: true
          description: The user's unique identifier
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: User found
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    $ref: '#/components/schemas/User'
        '401':
          description: Unauthorized
        '404':
          description: User not found
        '429':
          description: Rate limit exceeded
        '500':
          description: Internal server error
    put:
      summary: Replace a user
      description: Replaces all fields of an existing user. All required fields must be provided.
      operationId: replaceUser
      tags:
        - Users
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserInput'
      responses:
        '200':
          description: User replaced successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    $ref: '#/components/schemas/User'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '404':
          description: Not found
        '422':
          description: Validation failed
        '429':
          description: Rate limit exceeded
        '500':
          description: Internal server error
    patch:
      summary: Update a user
      description: Partially updates an existing user. Only provided fields will be updated.
      operationId: updateUser
      tags:
        - Users
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateUserInput'
      responses:
        '200':
          description: User updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    $ref: '#/components/schemas/User'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '404':
          description: Not found
        '422':
          description: Validation failed
        '429':
          description: Rate limit exceeded
        '500':
          description: Internal server error
    delete:
      summary: Delete a user
      description: Permanently deletes a user by their unique identifier.
      operationId: deleteUser
      tags:
        - Users
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '204':
          description: User deleted successfully
        '401':
          description: Unauthorized
        '404':
          description: Not found
        '429':
          description: Rate limit exceeded
        '500':
          description: Internal server error
components:
  schemas:
    User:
      type: object
      required:
        - id
        - name
        - email
        - createdAt
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the user
        name:
          type: string
          minLength: 1
          maxLength: 255
          description: Full name of the user
        email:
          type: string
          format: email
          description: Email address of the user
        role:
          type: string
          enum:
            - admin
            - user
            - viewer
          default: user
          description: Role assigned to the user
        createdAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the user was created
        updatedAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the user was last updated
      example:
        id: 123e4567-e89b-12d3-a456-426614174000
        name: Jane Doe
        email: jane@example.com
        role: user
        createdAt: '2024-01-15T10:30:00Z'
        updatedAt: '2024-01-15T10:30:00Z'
    CreateUserInput:
      type: object
      required:
        - name
        - email
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
          description: Full name of the user
        email:
          type: string
          format: email
          description: Email address of the user
        role:
          type: string
          enum:
            - admin
            - user
            - viewer
          default: user
      example:
        name: Jane Doe
        email: jane@example.com
        role: user
    UpdateUserInput:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
        email:
          type: string
          format: email
        role:
          type: string
          enum:
            - admin
            - user
            - viewer
      example:
        name: Jane Smith
        email: jane.smith@example.com
    PaginationMeta:
      type: object
      properties:
        total:
          type: integer
          description: Total number of items
        page:
          type: integer
          description: Current page number
        limit:
          type: integer
          description: Items per page
        totalPages:
          type: integer
          description: Total number of pages
    PaginatedUsers:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/User'
        meta:
          $ref: '#/components/schemas/PaginationMeta'
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Machine-readable error code
        message:
          type: string
          description: Human-readable error message
        details:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
              message:
                type: string
          description: Optional field-level error details
      example:
        code: VALIDATION_FAILED
        message: The provided payload is invalid.
        details:
          - field: email
            message: Must be a valid email address
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Enter your JWT token in the format: Bearer <token>'
  responses:
    Unauthorized:
      description: Unauthorized - Invalid or missing authentication
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
security:
  - bearerAuth: []

OpenAPI vs Swagger Comparison

Confused between OpenAPI 3.0 specs and Swagger 2.0 definitions? Read our comprehensive comparison guide: OpenAPI vs Swagger Comparison Guide.

Official References