{
  "openapi": "3.0.3",
  "info": {
    "title": "ZOOM API",
    "version": "1.0.0",
    "description": "Swagger/OpenAPI document for legacy zoom-api."
  },
  "servers": [
    {
      "url": "/",
      "description": "Current environment"
    }
  ],
  "tags": [
    { "name": "health" },
    { "name": "application" },
    { "name": "authorization" },
    { "name": "catalog" },
    { "name": "custom-catalog" },
    { "name": "flyer" },
    { "name": "category" },
    { "name": "quickcanvas" },
    { "name": "admin" }
  ],
  "paths": {
    "/": {
      "get": {
        "tags": ["health"],
        "summary": "Returns API version string",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/application": {
      "get": {
        "tags": ["application"],
        "summary": "Application index",
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/auth": {
      "get": {
        "tags": ["authorization"],
        "summary": "Authorization index",
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/auth/authorize": {
      "post": {
        "tags": ["authorization"],
        "summary": "Authorize access",
        "requestBody": { "$ref": "#/components/requestBodies/GenericJsonBody" },
        "responses": { "200": { "description": "Authorized" }, "400": { "description": "Invalid request" } }
      }
    },
    "/auth/register": {
      "post": {
        "tags": ["authorization"],
        "summary": "Register user",
        "security": [{ "accessTokenAuth": [] }],
        "requestBody": { "$ref": "#/components/requestBodies/GenericJsonBody" },
        "responses": { "200": { "description": "Registered" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/auth/register/{email}": {
      "post": {
        "tags": ["authorization"],
        "summary": "Register user by email path",
        "security": [{ "accessTokenAuth": [] }],
        "parameters": [
          {
            "name": "email",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": { "200": { "description": "Registered" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/auth/autologin": {
      "get": {
        "tags": ["authorization"],
        "summary": "Generate autologin URI",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/auth/verify": {
      "get": {
        "tags": ["authorization"],
        "summary": "Verify access token (GET)",
        "responses": { "200": { "description": "Valid" }, "401": { "description": "Invalid" } }
      },
      "post": {
        "tags": ["authorization"],
        "summary": "Verify access token (POST)",
        "requestBody": { "$ref": "#/components/requestBodies/GenericJsonBody" },
        "responses": { "200": { "description": "Valid" }, "401": { "description": "Invalid" } }
      }
    },
    "/catalog": {
      "get": {
        "tags": ["catalog"],
        "summary": "Catalog index",
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/catalogs": {
      "get": {
        "tags": ["catalog"],
        "summary": "Get catalogs",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/catalogs/all": {
      "get": {
        "tags": ["catalog"],
        "summary": "Get merged catalogs and custom catalogs",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/custom/catalog": {
      "get": {
        "tags": ["custom-catalog"],
        "summary": "Custom catalog index",
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/custom/catalogs": {
      "get": {
        "tags": ["custom-catalog"],
        "summary": "Get custom catalogs",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/custom/catalogs/suppliers": {
      "get": {
        "tags": ["custom-catalog"],
        "summary": "Get custom catalogs for many suppliers",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/custom/catalogs/personalized": {
      "get": {
        "tags": ["custom-catalog"],
        "summary": "Get personalized custom catalogs",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/custom/catalogs/random": {
      "get": {
        "tags": ["custom-catalog"],
        "summary": "Get random custom catalogs",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/flyer": {
      "get": {
        "tags": ["flyer"],
        "summary": "Flyer index",
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/flyers": {
      "get": {
        "tags": ["flyer"],
        "summary": "Get flyers",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/flyers/suppliers": {
      "get": {
        "tags": ["flyer"],
        "summary": "Get flyers for many suppliers",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/flyers/personalized": {
      "get": {
        "tags": ["flyer"],
        "summary": "Get personalized flyers",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/category": {
      "get": {
        "tags": ["category"],
        "summary": "Category index",
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/categories": {
      "get": {
        "tags": ["category"],
        "summary": "Get categories",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/categories/catalogs": {
      "get": {
        "tags": ["category"],
        "summary": "Get catalogs by category query parameter",
        "security": [{ "accessTokenAuth": [] }],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": { "type": "string" }
          }
        ],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/categories/all": {
      "get": {
        "tags": ["category"],
        "summary": "Get all categories",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/category/{slug}": {
      "get": {
        "tags": ["category"],
        "summary": "Get category by slug",
        "security": [{ "accessTokenAuth": [] }],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/canvas": {
      "get": {
        "tags": ["quickcanvas"],
        "summary": "Canvas index",
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/canvas/projects": {
      "get": {
        "tags": ["quickcanvas"],
        "summary": "Get canvas projects",
        "security": [{ "accessTokenAuth": [] }],
        "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/canvas/generate-project": {
      "post": {
        "tags": ["quickcanvas"],
        "summary": "Generate canvas project",
        "security": [{ "accessTokenAuth": [] }],
        "requestBody": { "$ref": "#/components/requestBodies/GenericJsonBody" },
        "responses": { "200": { "description": "Generated" }, "401": { "description": "Unauthorized" } }
      }
    },
    "/admin/catalog-image-overrides": {
      "get": {
        "tags": ["admin"],
        "summary": "List catalog image overrides",
        "description": "Returns all catalog image overrides. Applied by /catalogs/all when uid matches.",
        "security": [{ "adminTokenAuth": [] }],
        "parameters": [
          { "name": "uid",     "in": "query", "required": false, "schema": { "type": "integer" }, "description": "Filter by uid" },
          { "name": "enabled", "in": "query", "required": false, "schema": { "type": "integer", "enum": [0, 1] }, "description": "Filter by enabled flag" }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "overrides": { "type": "array", "items": { "$ref": "#/components/schemas/CatalogImageOverride" } },
                    "count": { "type": "integer" }
                  }
                }
              }
            }
          },
          "401": { "description": "Unauthorized" }
        }
      },
      "post": {
        "tags": ["admin"],
        "summary": "Create a catalog image override",
        "security": [{ "adminTokenAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CatalogImageOverrideInput" }
            }
          }
        },
        "responses": {
          "201": { "description": "Created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CatalogImageOverride" } } } },
          "400": { "description": "Invalid payload" },
          "401": { "description": "Unauthorized" },
          "409": { "description": "Duplicate (uid+nid already exists)" }
        }
      }
    },
    "/admin/catalog-image-overrides/{id}": {
      "get": {
        "tags": ["admin"],
        "summary": "Get a catalog image override by id",
        "security": [{ "adminTokenAuth": [] }],
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }
        ],
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CatalogImageOverride" } } } },
          "401": { "description": "Unauthorized" },
          "404": { "description": "Not found" }
        }
      },
      "put": {
        "tags": ["admin"],
        "summary": "Update a catalog image override",
        "description": "Send {\"enabled\": false} to disable an override without removing it.",
        "security": [{ "adminTokenAuth": [] }],
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CatalogImageOverrideInput" }
            }
          }
        },
        "responses": {
          "200": { "description": "Updated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CatalogImageOverride" } } } },
          "400": { "description": "Invalid payload" },
          "401": { "description": "Unauthorized" },
          "404": { "description": "Not found" },
          "409": { "description": "Duplicate (uid+nid already exists)" }
        }
      }
    }
  },
  "components": {
    "requestBodies": {
      "GenericJsonBody": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      }
    },
    "securitySchemes": {
      "accessTokenAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "Access token (JWT) only — no \"Bearer \" prefix. Send the raw token, e.g. eyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9..."
      },
      "adminTokenAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Admin-Token",
        "description": "Internal admin shared secret. Set server-side via the ADMIN_API_TOKEN environment variable (or ADMIN_API_TOKENS, comma-separated, to support rotation)."
      }
    },
    "schemas": {
      "CatalogImageOverride": {
        "type": "object",
        "properties": {
          "id":           { "type": "integer" },
          "uid":          { "type": "integer", "description": "User id the override applies to (e.g. 2604=S&S, 1381=Alphabroder)" },
          "nid":          { "type": "integer", "description": "Catalog nid (zc_catalog.nid)" },
          "image_small":  { "type": "string", "format": "uri", "nullable": true },
          "image_medium": { "type": "string", "format": "uri", "nullable": true },
          "image_large":  { "type": "string", "format": "uri", "nullable": true },
          "note":         { "type": "string", "nullable": true, "description": "Human-readable note; typically the catalog title at creation time" },
          "enabled":      { "type": "integer", "enum": [0, 1] },
          "created_at":   { "type": "string", "format": "date-time" },
          "updated_at":   { "type": "string", "format": "date-time" }
        }
      },
      "CatalogImageOverrideInput": {
        "type": "object",
        "required": ["uid", "nid"],
        "properties": {
          "uid":          { "type": "integer", "example": 2604 },
          "nid":          { "type": "integer", "example": 12345 },
          "image_small":  { "type": "string", "format": "uri", "nullable": true },
          "image_medium": { "type": "string", "format": "uri", "nullable": true },
          "image_large":  { "type": "string", "format": "uri", "nullable": true },
          "note":         { "type": "string", "nullable": true, "maxLength": 255 },
          "enabled":      { "type": "boolean" }
        }
      }
    }
  }
}
