sample-swagger.yaml•4.55 kB
openapi: 3.0.0
info:
title: Sample Pet Store API
description: A sample API for demonstration purposes
version: 1.0.0
contact:
name: API Support
email: support@example.com
servers:
- url: https://api.example.com/v1
description: Production server
- url: https://staging-api.example.com/v1
description: Staging server
paths:
/pets:
get:
summary: List all pets
description: Returns a list of all pets in the store
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: Maximum number of pets to return
required: false
schema:
type: integer
format: int32
default: 20
- name: offset
in: query
description: Number of pets to skip
required: false
schema:
type: integer
format: int32
default: 0
responses:
'200':
description: A list of pets
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
'500':
description: Internal server error
post:
summary: Create a pet
description: Add a new pet to the store
operationId: createPet
tags:
- pets
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/NewPet'
responses:
'201':
description: Pet created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid input
/pets/{petId}:
get:
summary: Get a pet by ID
description: Returns a single pet
operationId: getPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The ID of the pet to retrieve
schema:
type: string
responses:
'200':
description: Pet details
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'404':
description: Pet not found
put:
summary: Update a pet
description: Update an existing pet's information
operationId: updatePet
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The ID of the pet to update
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/NewPet'
responses:
'200':
description: Pet updated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'404':
description: Pet not found
delete:
summary: Delete a pet
description: Remove a pet from the store
operationId: deletePet
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The ID of the pet to delete
schema:
type: string
responses:
'204':
description: Pet deleted successfully
'404':
description: Pet not found
components:
schemas:
Pet:
type: object
required:
- id
- name
properties:
id:
type: string
description: Unique identifier for the pet
name:
type: string
description: Name of the pet
species:
type: string
description: Species of the pet (e.g., dog, cat, bird)
age:
type: integer
description: Age of the pet in years
status:
type: string
enum:
- available
- pending
- adopted
description: Current status of the pet
NewPet:
type: object
required:
- name
- species
properties:
name:
type: string
description: Name of the pet
species:
type: string
description: Species of the pet
age:
type: integer
description: Age of the pet in years