Created
January 6, 2025 20:15
-
-
Save tasn/edebd544817a50f85685f7414ccf15ab to your computer and use it in GitHub Desktop.
Example OpenAPI spec with webhooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"openapi": "3.1.0", | |
"info": { | |
"title": "FastAPI", | |
"version": "0.1.0" | |
}, | |
"paths": { | |
"/pet": { | |
"get": { | |
"summary": "List Pets", | |
"operationId": "list_pets_pet_get", | |
"responses": { | |
"200": { | |
"description": "Successful Response", | |
"content": { | |
"application/json": { | |
"schema": { | |
"items": { | |
"$ref": "#/components/schemas/Pet" | |
}, | |
"type": "array", | |
"title": "Response List Pets Pet Get" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"webhooks": { | |
"pet.new": { | |
"post": { | |
"summary": "New Pet", | |
"description": "When a new pet is created", | |
"operationId": "new_petpet_new_post", | |
"requestBody": { | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/PetNewEvent" | |
} | |
} | |
}, | |
"required": true | |
}, | |
"responses": { | |
"200": { | |
"description": "Successful Response", | |
"content": { | |
"application/json": { | |
"schema": {} | |
} | |
} | |
}, | |
"422": { | |
"description": "Validation Error", | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/HTTPValidationError" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"components": { | |
"schemas": { | |
"HTTPValidationError": { | |
"properties": { | |
"detail": { | |
"items": { | |
"$ref": "#/components/schemas/ValidationError" | |
}, | |
"type": "array", | |
"title": "Detail" | |
} | |
}, | |
"type": "object", | |
"title": "HTTPValidationError" | |
}, | |
"Pet": { | |
"properties": { | |
"name": { | |
"type": "string", | |
"title": "Name" | |
}, | |
"age": { | |
"type": "integer", | |
"title": "Age" | |
} | |
}, | |
"type": "object", | |
"required": [ | |
"name", | |
"age" | |
], | |
"title": "Pet" | |
}, | |
"PetNewEvent": { | |
"properties": { | |
"type": { | |
"type": "string", | |
"title": "Type", | |
"default": "pet.new" | |
}, | |
"timestamp": { | |
"type": "string", | |
"format": "date-time", | |
"title": "Timestamp" | |
}, | |
"data": { | |
"$ref": "#/components/schemas/Pet" | |
} | |
}, | |
"type": "object", | |
"required": [ | |
"timestamp", | |
"data" | |
], | |
"title": "PetNewEvent" | |
}, | |
"ValidationError": { | |
"properties": { | |
"loc": { | |
"items": { | |
"anyOf": [ | |
{ | |
"type": "string" | |
}, | |
{ | |
"type": "integer" | |
} | |
] | |
}, | |
"type": "array", | |
"title": "Location" | |
}, | |
"msg": { | |
"type": "string", | |
"title": "Message" | |
}, | |
"type": { | |
"type": "string", | |
"title": "Error Type" | |
} | |
}, | |
"type": "object", | |
"required": [ | |
"loc", | |
"msg", | |
"type" | |
], | |
"title": "ValidationError" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment