Skip to content

Instantly share code, notes, and snippets.

@joshtwist
Last active October 8, 2024 14:08
Show Gist options
  • Save joshtwist/c27cbe8202e9087344dd435e479ed89f to your computer and use it in GitHub Desktop.
Save joshtwist/c27cbe8202e9087344dd435e479ed89f 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": {
"summary": "Order Response Example",
"value": {
"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"
}
}
],
"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"]
}
]
}
}
}
}
}
}
}
}
}
},
"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": {
"type": "string"
}
},
"required": ["customerName", "pizzaType", "size", "deliveryAddress"]
},
"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