openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /pets:
    get:
      summary: List all pets
      operationId: listPets
      tags:
        - pets
      parameters:
        - name: limit
          in: query
          description: How many items to return at one time (max 100)
          required: false
          schema:
            type: integer
            maximum: 100
            format: int32
      responses:
        '200':
          description: A paged array of pets
          headers:
            x-next:
              description: A link to the next page of responses
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pets"
              examples:
                pets_json:
                  value:
                    - id: 1
                      name: "Fluffy"
                      tag: "cat"
                    - id: 2
                      name: "Rex"
                      tag: "dog"
            application/xml:
              schema:
                $ref: "#/components/schemas/Pets"
              examples:
                pets_xml:
                  value: |
                    <pets:Pets xmlns:pets="http://petstore.swagger.io/v1/pets" xmlns:pet="http://petstore.swagger.io/v1/pet">
                      <pet:Pet>
                        <id>1</id>
                        <name>Fluffy</name>
                        <tag>cat</tag>
                      </pet:Pet>
                      <pet:Pet>
                        <id>2</id>
                        <name>Rex</name>
                        <tag>dog</tag>
                      </pet:Pet>
                    </pets:Pets>
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
              examples:
                error_json:
                  value:
                    code: 404
                    message: "Pet not found"
            application/xml:
              schema:
                $ref: "#/components/schemas/Error"
              examples:
                error_xml:
                  value: |
                    <error:Error xmlns:error="http://petstore.swagger.io/v1/error">
                      <code>404</code>
                      <message>Pet not found</message>
                    </error:Error>
    post:
      summary: Create a pet
      operationId: createPets
      tags:
        - pets
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Pet'
          application/xml:
            schema:
              $ref: '#/components/schemas/Pet'
        required: true
      responses:
        '201':
          description: Null response
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
            application/xml:
              schema:
                $ref: "#/components/schemas/Error"
  /pets/{petId}:
    get:
      summary: Info for a specific pet
      operationId: showPetById
      tags:
        - pets
      parameters:
        - name: petId
          in: path
          required: true
          description: The id of the pet to retrieve
          schema:
            type: string
      responses:
        '200':
          description: Expected response to a valid request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pet"
              examples:
                pet_json:
                  value:
                    id: 1
                    name: "Fluffy"
                    tag: "cat"
            application/xml:
              schema:
                $ref: "#/components/schemas/Pet"
              examples:
                pet_xml:
                  value: |
                    <pet:Pet xmlns:pet="http://petstore.swagger.io/v1/pet">
                      <id>1</id>
                      <name>Fluffy</name>
                      <tag>cat</tag>
                    </pet:Pet>
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
              examples:
                error_json:
                  value:
                    code: 404
                    message: "Pet not found"
            application/xml:
              schema:
                $ref: "#/components/schemas/Error"
              examples:
                error_xml:
                  value: |
                    <error:Error xmlns:error="http://petstore.swagger.io/v1/error">
                      <code>404</code>
                      <message>Pet not found</message>
                    </error:Error>
components:
  schemas:
    Pet:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
          example: 1
          xml:
            attribute: false
        name:
          type: string
          example: "Fluffy"
          xml:
            attribute: false
        tag:
          type: string
          example: "cat"
          xml:
            attribute: false
      example:
        id: 1
        name: "Fluffy"
        tag: "cat"
      xml:
        name: Pet
        namespace: http://petstore.swagger.io/v1/pet
        prefix: pet
    Pets:
      type: array
      maxItems: 100
      items:
        $ref: "#/components/schemas/Pet"
      example:
        - id: 1
          name: "Fluffy"
          tag: "cat"
        - id: 2
          name: "Rex"
          tag: "dog"
      xml:
        name: Pets
        namespace: http://petstore.swagger.io/v1/pets
        prefix: pets
        wrapped: true
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
          example: 404
          xml:
            attribute: false
        message:
          type: string
          example: "Pet not found"
          xml:
            attribute: false
      example:
        code: 404
        message: "Pet not found"
      xml:
        name: Error
        namespace: http://petstore.swagger.io/v1/error
        prefix: error
