Swagger · Example Payload

Openapi Spec Example

Pets

Openapi Spec Example is an example object payload from Swagger, with 6 top-level fields. It illustrates the shape of data this provider's APIs accept or return.

Top-level fields

openapiinfoserverstagspathscomponents

Example Payload

openapi-spec-example.json Raw ↑
{
  "openapi": "3.1.1",
  "info": {
    "title": "Pet Store API",
    "description": "A sample Pet Store API demonstrating OpenAPI 3.1.1 specification features.",
    "version": "1.0.0",
    "contact": {
      "name": "Pet Store Support",
      "url": "https://petstore.example.com/support",
      "email": "support@petstore.example.com"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0"
    }
  },
  "servers": [
    {
      "url": "https://api.petstore.example.com/v1",
      "description": "Production server"
    }
  ],
  "tags": [
    {
      "name": "Pets",
      "description": "Operations about pets"
    }
  ],
  "paths": {
    "/pets": {
      "get": {
        "operationId": "listPets",
        "summary": "List Pets",
        "description": "Returns a paginated list of all pets in the store.",
        "tags": ["Pets"],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of pets to return",
            "required": false,
            "schema": { "type": "integer", "maximum": 100 }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of pets",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/Pet" }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createPet",
        "summary": "Create Pet",
        "description": "Create a new pet in the store.",
        "tags": ["Pets"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/NewPet" }
            }
          }
        },
        "responses": {
          "201": { "description": "Pet created successfully" },
          "400": { "description": "Invalid input" }
        }
      }
    },
    "/pets/{petId}": {
      "get": {
        "operationId": "getPet",
        "summary": "Get Pet",
        "description": "Retrieve a pet by its ID.",
        "tags": ["Pets"],
        "parameters": [
          {
            "name": "petId",
            "in": "path",
            "required": true,
            "schema": { "type": "integer" }
          }
        ],
        "responses": {
          "200": {
            "description": "Pet details",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Pet" }
              }
            }
          },
          "404": { "description": "Pet not found" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Pet": {
        "type": "object",
        "required": ["id", "name"],
        "properties": {
          "id": { "type": "integer" },
          "name": { "type": "string" },
          "tag": { "type": "string" }
        }
      },
      "NewPet": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": { "type": "string" },
          "tag": { "type": "string" }
        }
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}