- Parse and validate OpenAPI 3.x / Swagger 2.0 specs - Query endpoints by method, path pattern, tag, operationId - Get component schema details - Generate TypeScript interfaces from schemas - Support local files and remote URLs Tools: parse-spec, validate-spec, query-endpoints, get-schema, generate-types Co-Authored-By: Claude <noreply@anthropic.com>
181 lines
4.1 KiB
YAML
181 lines
4.1 KiB
YAML
openapi: 3.0.3
|
|
info:
|
|
title: Pet Store API
|
|
description: A sample Pet Store API for testing swagger-tools
|
|
version: 1.0.0
|
|
servers:
|
|
- url: https://api.petstore.example.com/v1
|
|
description: Production server
|
|
- url: https://staging.petstore.example.com/v1
|
|
description: Staging server
|
|
tags:
|
|
- name: pets
|
|
description: Pet operations
|
|
- name: store
|
|
description: Store operations
|
|
paths:
|
|
/pets:
|
|
get:
|
|
operationId: listPets
|
|
summary: List all pets
|
|
tags:
|
|
- pets
|
|
parameters:
|
|
- name: limit
|
|
in: query
|
|
description: Maximum number of pets to return
|
|
required: false
|
|
schema:
|
|
type: integer
|
|
maximum: 100
|
|
- name: status
|
|
in: query
|
|
description: Filter by status
|
|
schema:
|
|
$ref: '#/components/schemas/PetStatus'
|
|
responses:
|
|
'200':
|
|
description: A list of pets
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/Pet'
|
|
'400':
|
|
description: Bad request
|
|
post:
|
|
operationId: createPet
|
|
summary: Create a new pet
|
|
tags:
|
|
- pets
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/NewPet'
|
|
responses:
|
|
'201':
|
|
description: Pet created
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Pet'
|
|
'400':
|
|
description: Invalid input
|
|
/pets/{petId}:
|
|
get:
|
|
operationId: getPet
|
|
summary: Get a pet by ID
|
|
tags:
|
|
- pets
|
|
parameters:
|
|
- name: petId
|
|
in: path
|
|
required: true
|
|
description: The pet ID
|
|
schema:
|
|
type: integer
|
|
format: int64
|
|
responses:
|
|
'200':
|
|
description: Pet details
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Pet'
|
|
'404':
|
|
description: Pet not found
|
|
delete:
|
|
operationId: deletePet
|
|
summary: Delete a pet
|
|
tags:
|
|
- pets
|
|
parameters:
|
|
- name: petId
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: integer
|
|
format: int64
|
|
responses:
|
|
'204':
|
|
description: Pet deleted
|
|
'404':
|
|
description: Pet not found
|
|
/store/inventory:
|
|
get:
|
|
operationId: getInventory
|
|
summary: Get store inventory
|
|
tags:
|
|
- store
|
|
responses:
|
|
'200':
|
|
description: Inventory counts by status
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
additionalProperties:
|
|
type: integer
|
|
components:
|
|
schemas:
|
|
Pet:
|
|
type: object
|
|
description: A pet in the store
|
|
required:
|
|
- id
|
|
- name
|
|
properties:
|
|
id:
|
|
type: integer
|
|
format: int64
|
|
description: Unique identifier
|
|
name:
|
|
type: string
|
|
description: Pet name
|
|
status:
|
|
$ref: '#/components/schemas/PetStatus'
|
|
tags:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/Tag'
|
|
NewPet:
|
|
type: object
|
|
description: Data for creating a new pet
|
|
required:
|
|
- name
|
|
properties:
|
|
name:
|
|
type: string
|
|
description: Pet name
|
|
status:
|
|
$ref: '#/components/schemas/PetStatus'
|
|
PetStatus:
|
|
type: string
|
|
description: Pet availability status
|
|
enum:
|
|
- available
|
|
- pending
|
|
- sold
|
|
Tag:
|
|
type: object
|
|
description: A tag for categorizing pets
|
|
properties:
|
|
id:
|
|
type: integer
|
|
format: int64
|
|
name:
|
|
type: string
|
|
Error:
|
|
type: object
|
|
description: Error response
|
|
required:
|
|
- code
|
|
- message
|
|
properties:
|
|
code:
|
|
type: integer
|
|
message:
|
|
type: string
|