Skip to content

Instantly share code, notes, and snippets.

@joshtwist
Created August 30, 2024 15:47
Show Gist options
  • Save joshtwist/f48a103601858a4c2c591c514f23db61 to your computer and use it in GitHub Desktop.
Save joshtwist/f48a103601858a4c2c591c514f23db61 to your computer and use it in GitHub Desktop.
{
"openapi": "3.0.0",
"info": {
"title": "Slice of Heaven Pizza API",
"description": "Welcome to the Slice of Heaven Pizza API! We're serving up hot, fresh endpoints faster than you can say 'extra cheese'. Whether you're looking to order a pizza, track your delivery, or browse our menu, we've got you covered. So sit back, relax, and let our API do the heavy lifting (unlike our delivery drivers, who are strictly forbidden from lifting heavy objects).",
"version": "1.0.0",
"contact": {
"name": "Pizza Support",
"email": "support@sliceofheaven.com",
"url": "https://sliceofheaven.com/support"
},
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
}
},
"servers": [
{
"url": "https://api.sliceofheaven.com/v1",
"description": "Production server (uses live data)"
},
{
"url": "https://staging-api.sliceofheaven.com/v1",
"description": "Staging server (uses test data)"
}
],
"tags": [
{
"name": "menu",
"description": "Everything related to our delicious menu"
},
{
"name": "orders",
"description": "Managing orders, from creation to delivery"
},
{
"name": "customers",
"description": "Customer management and loyalty program"
}
],
"paths": {
"/menu": {
"get": {
"summary": "Retrieve the full menu",
"description": "Get a list of all available pizzas, toppings, and sides. Warning: May cause excessive drooling.",
"tags": ["menu"],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Menu"
}
}
}
}
}
}
},
"/orders": {
"post": {
"summary": "Place a new order",
"description": "Submit a new pizza order. Remember, ordering a pineapple pizza is at your own risk - we won't judge (much).",
"tags": ["orders"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OrderRequest"
}
}
}
},
"responses": {
"201": {
"description": "Order created successfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Order"
}
}
}
},
"400": {
"description": "Invalid order. Did you try to order a pizza without crust again?"
}
}
}
},
"/orders/{orderId}": {
"get": {
"summary": "Get order details",
"description": "Retrieve details of a specific order. Find out if your pizza is still in the oven or if it's embarked on its epic journey to your doorstep.",
"tags": ["orders"],
"parameters": [
{
"name": "orderId",
"in": "path",
"required": true,
"description": "Unique identifier of the order",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Order"
}
}
}
},
"404": {
"description": "Order not found. Are you sure you didn't dream about ordering that pizza?"
}
}
},
"patch": {
"summary": "Update an order",
"description": "Update an existing order. Perfect for when you realize you forgot to add extra cheese (a cardinal sin in the pizza world).",
"tags": ["orders"],
"parameters": [
{
"name": "orderId",
"in": "path",
"required": true,
"description": "Unique identifier of the order",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OrderUpdateRequest"
}
}
}
},
"responses": {
"200": {
"description": "Order updated successfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Order"
}
}
}
},
"400": {
"description": "Invalid update request. No, you can't change your pizza to a burger."
},
"404": {
"description": "Order not found. It's either in someone else's belly or lost in the void."
}
}
}
},
"/customers/{customerId}/orders": {
"get": {
"summary": "Get customer's order history",
"description": "Retrieve the order history for a specific customer. Prepare to be amazed by their dedication to the pizza arts.",
"tags": ["customers", "orders"],
"parameters": [
{
"name": "customerId",
"in": "path",
"required": true,
"description": "Unique identifier of the customer",
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "Maximum number of orders to return",
"schema": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 20
}
},
{
"name": "offset",
"in": "query",
"description": "Number of orders to skip",
"schema": {
"type": "integer",
"minimum": 0,
"default": 0
}
}
],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Order"
}
}
}
}
},
"404": {
"description": "Customer not found. They might be on a secret pizza mission."
}
}
}
}
},
"components": {
"schemas": {
"Menu": {
"type": "object",
"properties": {
"pizzas": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MenuItem"
}
},
"toppings": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MenuItem"
}
},
"sides": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MenuItem"
}
}
}
},
"MenuItem": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"price": {
"type": "number",
"format": "float"
},
"category": {
"type": "string",
"enum": ["pizza", "topping", "side"]
}
}
},
"OrderRequest": {
"type": "object",
"properties": {
"customerId": {
"type": "string"
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"itemId": {
"type": "string"
},
"quantity": {
"type": "integer",
"minimum": 1
}
}
}
},
"deliveryAddress": {
"type": "string"
}
},
"required": ["customerId", "items", "deliveryAddress"]
},
"Order": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"customerId": {
"type": "string"
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"itemId": {
"type": "string"
},
"name": {
"type": "string"
},
"quantity": {
"type": "integer"
},
"price": {
"type": "number",
"format": "float"
}
}
}
},
"totalPrice": {
"type": "number",
"format": "float"
},
"status": {
"type": "string",
"enum": ["pending", "preparing", "in-delivery", "delivered", "cancelled"]
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"updatedAt": {
"type": "string",
"format": "date-time"
}
}
},
"OrderUpdateRequest": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"itemId": {
"type": "string"
},
"quantity": {
"type": "integer",
"minimum": 0
}
}
}
},
"deliveryAddress": {
"type": "string"
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment