openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
  - url: https://api.36node.com{basePath}
    description: The production API server
    variables:
      basePath:
        default: /petstore/v0
paths:
  /pets:
    get:
      summary: List all pets
      operationId: listPets
      tags:
        - pet
      parameters:
        - name: _limit
          in: query
          description: How many items to return at one time (max 100)
          required: false
          schema:
            type: integer
            format: int32
            default: 10
        - name: tag
          in: query
          description: Tag of pet
          required: false
          schema:
            type: string
        - name: age_gt
          in: query
          description: Return Pet older than given age
          required: false
          schema:
            type: integer
      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:
                type: array
                items:
                  $ref: "#/components/schemas/Pet"
              examples:
                default:
                  value: |
                    [
                      {
                        "id": 1,
                        "name": "aa",
                        "tag": "red",
                        "age": 3
                      },
                      {
                        "id": 2,
                        "name": "bb",
                        "tag": "happy",
                        "age": 5
                      },
                      {
                        "id": 3,
                        "name": "cc",
                        "tag": "husky",
                        "age": 6
                      }
                    ]
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/InternalError"

    post:
      summary: Create a pet
      operationId: createPets
      tags:
        - pet
      requestBody:
        description: Pet to add to the store
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/NewPet"
            examples:
              default:
                value: |
                  {
                    "name": "dd",
                    "tag": "red",
                    "age": 5
                  }
      responses:
        "201":
          description: The Pet created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pet"
              examples:
                default:
                  value: |
                    {
                      "id": 4,
                      "name": "dd",
                      "tag": "red",
                      "age": 5
                    }
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/InternalError"

  /pets/{petId}:
    get:
      summary: Find pet by id
      operationId: showPetById
      tags:
        - pet
      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:
                default:
                  value: |
                    {
                      "id": 3,
                      "name": "cc",
                      "tag": "red",
                      "age": 6
                    }
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/InternalError"
    delete:
      description: deletes a single pet based on the ID supplied
      operationId: deletePet
      tags:
        - pet
      parameters:
        - name: id
          in: path
          description: ID of pet to delete
          required: true
          schema:
            type: integer
            format: int64
      responses:
        "204":
          description: pet deleted
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/InternalError"

security:
  - bearerAuth: []

components:
  responses:
    NoContent:
      description: The resource was deleted successfully.
    NotFound:
      description: The specified resource was not found
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Err"
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Err"
    InternalError:
      description: unexpected error
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Err"
  schemas:
    Pet:
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        age:
          type: integer
          format: int32
        name:
          type: string
        tag:
          type: string
    NewPet:
      required:
        - name
      properties:
        name:
          type: string
        tag:
          type: string
        age:
          type: integer
    Err:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
      required:
        - code
        - message

  securitySchemes:
    bearerAuth: # arbitrary name for the security scheme
      type: http
      scheme: bearer
      bearerFormat: JWT
