The Pet Store API is a common REST API used in REST literature.

petstore api.drawio
Implementing a Petstore in Rhino TAS

Pet Store API specification

Preamble

Preamble
openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
  - url: /petstore/v1

List Pets request

A GET request with request URL path /petstore/v1/pets.

List Pets request
  /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
            format: int32

List Pet responses

Defines the set of possible responses. 200 Success response returns a list of pets. The response body is a JSon object defined by #/components/schemas/Pets

The default corresponds to any other response. The response body is a JSon object defined by #/components/schemas/Error.

List Pets request responses
      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"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

Create Pet request

A POST request with request URL path /petstore/v1/pets. The request body is a JSon object defined by #/components/schemas/Pet

List Pets request
    post:
      summary: Create a pet
      operationId: createPet
      requestBody:
        description: Pet to add to the store
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Pet'
      tags:
        - pets
      responses:
        '204':
          description: Null response
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

List Pet by ID request

A GET request with request URL path /petstore/v1/pets/{petid}.

List Pet by ID request
  /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: integer
            format: int64
      responses:
        '200':
          description: Expected response to a valid request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pet"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

Pet and Pets

Defines JSon objects for a Pet and a collection of Pets.

Pet
    Pet:
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
Pets
    Pets:
      type: array
      items:
        $ref: "#/components/schemas/Pet"
    Error:
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
Previous page