{
  "openapi": "3.1.0",
  "info": {
    "title": "The Right Bag API",
    "version": "1.0.0",
    "description": "The bag dataset (specs, sizes, airline fit and sources for every bag in the catalog) and the endpoint that suggests a bag to add.",
    "license": { "name": "CC BY-NC 4.0", "url": "https://creativecommons.org/licenses/by-nc/4.0/" }
  },
  "servers": [{ "url": "https://therightbag.com" }],
  "externalDocs": { "url": "https://therightbag.com/data/" },
  "paths": {
    "/data/bags.json": {
      "get": {
        "summary": "Every bag in the catalog as JSON",
        "description": "Sizes in centimetres, weight in kilograms, volume in litres. null means the brand doesn't publish the value. carryOnPct and personalItemPct are the share of airlines whose limits the bag fits.",
        "responses": {
          "200": {
            "description": "The dataset",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "license": { "type": "object", "properties": { "name": { "type": "string" }, "url": { "type": "string", "format": "uri" } } },
                    "citation": { "type": "string" },
                    "lastChecked": { "type": "string", "description": "Year and month the specs were last checked, YYYY-MM" },
                    "count": { "type": "integer" },
                    "bags": { "type": "array", "items": { "$ref": "#/components/schemas/Bag" } }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/data/bags.csv": {
      "get": {
        "summary": "Every bag in the catalog as CSV",
        "description": "One row per bag, same fields as bags.json. Sources are space-separated and sizes are separated by semicolons.",
        "responses": { "200": { "description": "The dataset", "content": { "text/csv": { "schema": { "type": "string" } } } } }
      }
    },
    "/api/suggest": {
      "post": {
        "summary": "Suggest a bag to add to the catalog",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": { "schema": { "$ref": "#/components/schemas/Suggestion" } },
            "multipart/form-data": { "schema": { "$ref": "#/components/schemas/Suggestion" } }
          }
        },
        "responses": {
          "204": { "description": "Suggestion received" },
          "400": { "description": "Brand, model or product link missing", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "405": { "description": "Only POST is allowed" },
          "502": { "description": "Could not send the suggestion right now", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Bag": {
        "type": "object",
        "required": ["slug", "name", "brand", "type"],
        "additionalProperties": true,
        "properties": {
          "slug": { "type": "string", "description": "The bag's page is https://therightbag.com/bags/{slug}/" },
          "name": { "type": "string" },
          "brand": { "type": "string" },
          "type": { "type": "string", "examples": ["backpack", "bike"] },
          "priceUsd": { "type": ["number", "null"] },
          "volumeL": { "type": ["number", "null"] },
          "expandsToL": { "type": ["number", "null"] },
          "heightCm": { "type": ["number", "null"] },
          "widthCm": { "type": ["number", "null"] },
          "depthCm": { "type": ["number", "null"] },
          "weightKg": { "type": ["number", "null"] },
          "laptopIn": { "type": ["number", "null"] },
          "carryOnPct": { "type": ["number", "null"] },
          "personalItemPct": { "type": ["number", "null"] }
        }
      },
      "Suggestion": {
        "type": "object",
        "required": ["brand", "model", "url"],
        "properties": {
          "brand": { "type": "string", "maxLength": 80 },
          "model": { "type": "string", "maxLength": 120 },
          "url": { "type": "string", "format": "uri", "maxLength": 500, "description": "The product page, http or https" },
          "note": { "type": "string", "maxLength": 1000 }
        }
      },
      "Error": { "type": "object", "properties": { "error": { "type": "string" } } }
    }
  }
}
