OpenAPI 2.0 Domain Example

Below is a sample OpenAPI 2.0 domain definition demonstrating various types of domain components.

See also: OpenAPI 3.0 Domain Example and AsyncAPI Domain Example

# OpenAPI version identifier - optional for OpenAPI 2.0 domains
swagger: '2.0'

######################
# Optional info section
######################
info:
  title: Components
  description: Common components for Acme REST APIs
  version: 1.0.0

####################
# Common data models
####################
definitions:
  ErrorModel:
    type: object
    required:
      - code
      - message
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string

####################
# Common parameters
####################
parameters:
  offsetParam:
    name: offset
    in: query
    type: integer
    minimum: 0
    description: The number of items to skip before returning the results
  limitParam:
    in: query
    name: limit
    type: integer
    format: int32
    minimum: 1
    maximum: 100
    default: 20
    description: The number of items to return

####################
# Common responses
####################
responses:
  GeneralError:
    description: An error occurred
    schema:
      $ref: '#/definitions/ErrorModel'

####################
# Common path items
####################
pathitems:
  EntityOperations:     # In domains, path item names do not have to be actual paths
    get:
      summary: Get all items
      description: This operation supports pagination
      parameters:
        - $ref: '#/parameters/offsetParam'
        - $ref: '#/parameters/limitParam'
      responses:
        200:
          description: A list of items
        default:
          $ref: '#/responses/GeneralError'
    post:
      summary: Add a new item
      parameters:
        - in: body
          name: item
          schema:
            type: object
      responses:
        201:
          description: Created

See Also

Publication date: