openapi: 3.0.0
info:
  version: 1.0.0
  title: Swagger Petstore
  description: A sample API that uses a petstore as an example to demonstrate features in
    the swagger-2.0 specification
  termsOfService: http://helloreverb.com/terms/
  contact:
    name: Wordnik API Team
    email: foo@example.com
    url: http://madskristensen.net
  license:
    name: MIT
    url: http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
servers:
  - url: "{protocol}://{hostName}/{basePath}"
    variables:
      protocol:
        enum:
          - http
          - https
        default: http
      hostName:
        default: company.com
      basePath:
        default: wrong
security:
  - petStoreBasic: []
    petStoreApiKey: []
  - petStoreOAuth:
      - view
paths:
  /pets:
    get:
      description: Returns all pets, optionally filtered by one or more criteria
      operationId: findPets
      security:
        []
      parameters:
        - name: Tags
          in: query
          description: Filters pets by one or more tags
          required: false
          style: form
          explode: false
          schema:
            type: array
            items:
              type: string
        - name: Type
          in: query
          description: Filters pets by type (dog, cat, or bird)
          required: true
          schema:
            type: string
        - name: Age
          in: query
          description: Filters pets by age
          required: false
          schema:
            type: integer
        - name: DOB
          in: query
          description: Filters pets by date of birth
          required: false
          schema:
            type: string
            format: date
        - name: Address.City
          in: query
          description: Filters pets by city
          required: false
          schema:
            type: string
        - name: Address.State
          in: query
          description: Filters pets by state
          required: false
          schema:
            type: string
        - name: Address.ZipCode
          in: query
          description: Filters pets by zip code
          required: false
          schema:
            type: integer
        - name: Vet.Name
          in: query
          description: Filters pets by veterinarian name
          required: false
          schema:
            type: string
        - name: Vet.Address.City
          in: query
          description: Filters pets by veterinarian city
          required: false
          schema:
            type: string
        - name: Vet.Address.State
          in: query
          description: Filters pets by veterinarian state
          required: false
          schema:
            type: string
        - name: Vet.Address.ZipCode
          in: query
          description: Filters pets by veterinarian zip code
          required: false
          schema:
            type: integer
      responses:
        "200":
          description: pet response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/pet"
            application/xml:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/pet"
            text/xml:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/pet"
            text/html:
              schema:
                type: string
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"
            application/xml:
              schema:
                $ref: "#/components/schemas/error"
            text/xml:
              schema:
                $ref: "#/components/schemas/error"
            text/html:
              schema:
                type: string
    post:
      description: Creates a new pet in the store.
      operationId: addPet
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/pet"
        description: Pet to add to the store
        required: true
      responses:
        "201":
          description: pet response
          headers:
            Location:
              description: Swagger-Express-Middleware will automatically set this header
                appropriately
              schema:
                type: string
        "409":
          description: new pet conflicts with an existing pet (i.e. they have the same name)
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"

  "/pets/{PetName}":
    parameters:
      - $ref: "#/components/parameters/petName"

    get:
      description: Returns a pet by name
      operationId: findPetByName
      responses:
        "200":
          description: pet response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/pet"
            application/xml:
              schema:
                $ref: "#/components/schemas/pet"
            text/xml:
              schema:
                $ref: "#/components/schemas/pet"
            text/html:
              schema:
                type: string
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"
            application/xml:
              schema:
                $ref: "#/components/schemas/error"
            text/xml:
              schema:
                $ref: "#/components/schemas/error"
            text/html:
              schema:
                type: string

    patch:
      description: Updates a pet by name
      security:
        - petStoreBasic: []
          petStoreApiKey: []
        - petStoreOAuth:
            - view
            - edit
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/pet"
        description: The updated pet info
        required: true
      responses:
        "200":
          description: pet response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/pet"
            application/xml:
              schema:
                $ref: "#/components/schemas/pet"
            text/xml:
              schema:
                $ref: "#/components/schemas/pet"
            text/html:
              schema:
                type: string
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"
            application/xml:
              schema:
                $ref: "#/components/schemas/error"
            text/xml:
              schema:
                $ref: "#/components/schemas/error"
            text/html:
              schema:
                type: string

    delete:
      description: deletes a single pet based on the name supplied
      operationId: deletePet
      security:
        - petStoreBasic: []
          petStoreApiKey: []
        - petStoreOAuth:
            - view
            - edit
            - delete
      responses:
        "204":
          description: pet deleted
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"

  "/pets/{PetName}/photos":
    parameters:
      - $ref: "#/components/parameters/petName"

    get:
      description: get a list of the photos for a pet
      responses:
        "200":
          description: the list of photos
          content:
            application/json:
              schema:
                type: array
                items:
                  properties:
                    ID:
                      type: integer
                      format: int32
                    Label:
                      type: string
                    Description:
                      type: string
                    Photo:
                      description: information about the photo (size, file name, etc.)

    post:
      description: adds a new pet photo
      security:
        - petStoreBasic: []
          petStoreApiKey: []
        - petStoreOAuth:
            - view
            - edit
            - create
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                ID:
                  description: the photo ID (generated automatically)
                  type: integer
                  format: int32
                  minimum: 1
                Label:
                  description: a label for the photo
                  type: string
                  minLength: 1
                Description:
                  description: an optional description of the photo
                  type: string
                Photo:
                  description: the pet photo
                  type: string
                  minLength: 1
                  maxLength: 5000000
                  format: binary
              required:
                - Label
                - Photo
      responses:
        "201":
          description: the photo was saved
          headers:
            Location:
              description: Swagger-Express-Middleware will automatically set this header
                appropriately
              schema:
                type: string

  "/pets/{PetName}/photos/{ID}":
    parameters:
      - $ref: "#/components/parameters/petName"
      - name: ID
        in: path
        description: id of the photo
        required: true
        schema:
          type: integer
          format: int32

    get:
      description: gets a pet photo
      responses:
        "200":
          description: the photo blob
          content:
            application/json:
              schema:
                type: string
                format: binary

    delete:
      description: deletes a pet photo
      security:
        - petStoreBasic: []
          petStoreApiKey: []
        - petStoreOAuth:
            - view
            - edit
            - delete
      responses:
        "204":
          description: the photo was deleted

components:
  parameters:
    petName:
      name: PetName
      in: path
      description: name of the pet
      required: true
      schema:
        type: string

  securitySchemes:
    petStoreBasic:
      type: http
      description: basic HTTP auth
      scheme: basic

    petStoreApiKey:
      type: apiKey
      name: petStoreKey
      in: header
      description: requires an API key header

    petStoreOAuth:
      type: oauth2
      description: OAuth2 security
      flows:
        password:
          tokenUrl: http://company.com/authorize
          scopes:
            view: read only
            edit: can edit pets
            create: can create new pets
            delete: can delete pets

  schemas:
    pet:
      required:
        - Name
        - Type
      properties:
        Name:
          type: string
          minLength: 2
          pattern: ^[a-zA-Z0-9- ]+$
        Age:
          type: integer
        DOB:
          type: string
          format: date
        Type:
          type: string
          enum:
            - cat
            - dog
            - bird
        Address:
          $ref: "#/components/schemas/address"
        Vet:
          $ref: "#/components/schemas/veterinarian"
        Tags:
          type: array
          items:
            type: string
            minLength: 1

    veterinarian:
      required:
        - Name
      properties:
        Name:
          type: string
          minLength: 1
        Address:
          $ref: "#/components/schemas/address"

    address:
      required:
        - Street
        - City
        - State
        - ZipCode
      properties:
        Street:
          type: string
          minLength: 1
        City:
          type: string
          minLength: 1
        State:
          type: string
          minLength: 2
          maxLength: 2
          pattern: ^[A-Z]+$
        ZipCode:
          type: integer
          minimum: 10000
          maximum: 99999

    error:
      required:
        - Code
        - Message
      properties:
        Code:
          type: integer
          format: int32
        Message:
          type: string
        Pet:
          $ref: "#/components/schemas/pet"