openapi: 3.0.1
info:
  title: <%= title %>
  description: <%= description %>
  version: <%= version %>
servers:
  - url: <%= apiRoot %>
tags:
  - name: Examples
    description: Simple example endpoints
  - name: Specification
    description: The swagger API specification
paths:
  /examples:
    get:
      tags:
        - Examples
      description: Fetch all examples
      responses:
        200:
          description: Return the example with the specified id
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Example'
        4XX:
          description: Example not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        5XX:
          description: Example not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    post:
      tags:
        - Examples
      description: Create a new example
      requestBody:
        description: an example
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExampleBody'
        required: true
      responses:
        201:
          description: Return the example with the specified id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Example'
        4XX:
          description: Example not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        5XX:
          description: Example not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /examples/{id}:
    get:
      tags:
        - Examples
      parameters:
        - name: id
          in: path
          description: The id of the example to retrieve
          required: true
          schema:
            type: integer
      responses:
        200:
          description: Return the example with the specified id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Example'
        4XX:
          description: Example not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        5XX:
          description: Example not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /spec:
    get:
      tags:
        - Specification
      responses:
        200:
          description: Return the API specification
          content: {}
components:
  schemas:
    Example:
      type: object
      properties:
        id:
          type: integer
          example: 3
        name:
          type: string
          example: example 3
    Error:
      type: object
      additionalProperties: true

    ExampleBody:
      title: example
      required:
        - name
      type: object
      properties:
        name:
          type: string
          example: no_stress
