Skip to content

Instantly share code, notes, and snippets.

@joshtwist
Created November 5, 2024 08:54
Show Gist options
  • Save joshtwist/068f5994d1020b99feab0086fe0c3207 to your computer and use it in GitHub Desktop.
Save joshtwist/068f5994d1020b99feab0086fe0c3207 to your computer and use it in GitHub Desktop.
{
"openapi": "3.0.0",
"info": {
"title": "Pizza Ordering API",
"description": "An API to order pizzas, check order status, and view menu options",
"version": "1.0.0"
},
"paths": {
"/pizza/order": {
"post": {
"summary": "Place a pizza order",
"operationId": "placeOrder",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OrderRequest"
},
"examples": {
"orderExample": {
"summary": "Example order",
"value": {
"customerName": "John Doe",
"pizzaType": "Margherita",
"size": "Large",
"toppings": ["Mushrooms", "Olives"],
"deliveryAddress": "123 Pizza St, Pizzatown"
}
}
}
}
}
},
"responses": {
"201": {
"description": "Order successfully placed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OrderResponse"
},
"examples": {
"orderResponseExample": {
"orderId": "abc123",
"estimatedDeliveryTime": "45 minutes"
}
}
}
}
}
}
}
},
"/pizza/order/{orderId}": {
"get": {
"summary": "Check the status of an existing order",
"operationId": "checkOrderStatus",
"parameters": [
{
"name": "orderId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "filter",
"in": "query",
"required": true,
"schema": {
"type": "integer"
}
},
{
"name": "banana",
"in": "header",
"required": true,
"schema": {
"type": "number"
}
}
],
"responses": {
"200": {
"description": "Order status retrieved",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OrderStatusResponse"
},
"examples": {
"statusExample": {
"summary": "Status example",
"value": {
"orderId": "abc123",
"status": "In the oven",
"estimatedDeliveryTime": "20 minutes"
}
}
}
}
}
},
"404": {
"description": "Order not found"
}
}
}
},
"/pizza/menu": {
"get": {
"summary": "Get the available pizza menu",
"operationId": "getMenu",
"responses": {
"200": {
"description": "Menu retrieved",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MenuResponse"
},
"examples": {
"menuExample": {
"summary": "Menu example",
"value": {
"pizzas": [
{
"name": "Margherita",
"sizes": ["Small", "Medium", "Large"],
"toppings": ["Cheese", "Tomato"]
},
{
"name": "Pepperoni",
"sizes": ["Small", "Medium", "Large"],
"toppings": ["Pepperoni", "Cheese", "Tomato"]
}
]
}
}
}
}
}
}
}
}
},
"/no-mock-available": {
"get": {
"summary": "Information about the pizza API",
"operationId": "noMockAvailable",
"responses": {
"200": {
"description": "Information retrieved",
"content": {}
}
}
}
},
"/foo": {
"get": {
"summary": "Retrieve the foo structure",
"operationId": "getFoo",
"responses": {
"200": {
"description": "Foo structure retrieved",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"bar": {
"type": "object",
"properties": {
"wibble": {
"type": "object",
"properties": {
"foo": {
"type": "array",
"items": {
"type": "integer"
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"/xml": {
"get": {
"summary": "Get XML response",
"operationId": "getXmlResponse",
"responses": {
"200": {
"description": "XML response",
"content": {
"application/xml": {
"examples": {
"xmlExample": {
"summary": "XML Example",
"value": "<note>\n <to>User</to>\n <from>API</from>\n <heading>Reminder</heading>\n <body>This is an XML response example.</body>\n</note>"
}
}
}
}
}
}
}
},
"/text": {
"get": {
"summary": "Get plain text response",
"operationId": "getTextResponse",
"responses": {
"200": {
"description": "Plain text response",
"content": {
"text/plain": {
"examples": {
"textExample": {
"summary": "Text Example",
"value": "This is a plain text response example."
}
}
}
}
}
}
}
},
"/multi-type": {
"get": {
"summary": "Get response with multiple content types",
"operationId": "getMultiTypeResponse",
"responses": {
"200": {
"description": "Response with multiple content types",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
},
"examples": {
"jsonExample": {
"summary": "JSON Example",
"value": {
"message": "This is a JSON response example."
}
}
}
},
"application/xml": {
"examples": {
"xmlExample": {
"summary": "XML Example",
"value": "<response>\n <message>This is an XML response example.</message>\n</response>"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"OrderRequest": {
"type": "object",
"properties": {
"customerName": {
"type": "string"
},
"pizzaType": {
"type": "string"
},
"size": {
"type": "string",
"enum": ["Small", "Medium", "Large"]
},
"toppings": {
"type": "array",
"items": {
"type": "string"
}
},
"deliveryAddress": {
"$ref": "#/components/schemas/Address"
}
},
"required": ["customerName", "pizzaType", "size", "deliveryAddress"]
},
"Address": {
"type": "string"
},
"OrderResponse": {
"type": "object",
"properties": {
"orderId": {
"type": "string"
},
"estimatedDeliveryTime": {
"type": "string"
}
}
},
"OrderStatusResponse": {
"type": "object",
"properties": {
"orderId": {
"type": "string"
},
"status": {
"type": "string"
},
"estimatedDeliveryTime": {
"type": "string"
}
}
},
"MenuResponse": {
"type": "object",
"properties": {
"pizzas": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"sizes": {
"type": "array",
"items": {
"type": "string"
}
},
"toppings": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment