{
  "openapi": "3.1.0",
  "info": {
    "title": "Context Window Supply store API",
    "version": "0.1.0",
    "description": "Browse products, get shipping quotes, and create a Stripe checkout link. US shipping per item: Tees: $4.95 for the first, plus $2.25 for each extra. Hoodies: $8.95 for the first, plus $2.50 for each extra. Sticker sheets: $3.95 for the first sheet alone, plus $1.95 for each extra. With a tee or hoodie, each sheet is $1.95. In a mixed order the most expensive item ships at its first-item rate and everything else at its extra rate. There is no free-shipping threshold. Printed in 2 to 7 business days, then delivered in 3 to 8 business days. Tees and hoodies need an explicit color and size.",
    "x-shipping-rates-usd": {
      "t-shirt": {
        "first_item": 4.95,
        "each_extra": 2.25
      },
      "hoodie": {
        "first_item": 8.95,
        "each_extra": 2.5
      },
      "sticker": {
        "first_item": 3.95,
        "each_extra": 1.95
      }
    }
  },
  "servers": [
    {
      "url": "https://contextwindowsupply.com"
    }
  ],
  "paths": {
    "/api/products": {
      "get": {
        "operationId": "listProducts",
        "summary": "List or search products",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "t-shirt",
                "hoodie",
                "sticker"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Products"
          }
        }
      }
    },
    "/api/products/{id}": {
      "get": {
        "operationId": "getProduct",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Product"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/quote": {
      "post": {
        "operationId": "getShippingQuote",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Order"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Subtotal, shipping and total"
          }
        }
      }
    },
    "/api/checkout": {
      "post": {
        "operationId": "createCheckout",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Order"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "checkout_url to a Stripe Checkout page"
          },
          "503": {
            "description": "Checkout not live yet"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Order": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "country": {
            "type": "string",
            "default": "US"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "product_id",
                "quantity"
              ],
              "properties": {
                "product_id": {
                  "type": "string"
                },
                "color": {
                  "type": "string"
                },
                "size": {
                  "type": "string"
                },
                "quantity": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 10
                }
              }
            }
          }
        }
      }
    }
  }
}