{
  "openapi": "3.1.1",
  "info": {
    "title": "Cabinet Variant Sheet API",
    "version": "1.0.0",
    "summary": "Compare up to 25 width/height combinations on one measured concept sheet.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://kerfwisevariantsheet.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Compare up to 25 width/height combinations on one measured concept sheet.",
        "description": "Compare open-shelf dimensions, clear shelf spacing and panel area, then export an editable native Kerfwise project and generated part dimensions.\n\nMethodology:\n- At most five widths × five heights, common display scale, user-specified depth and thickness. Panel area and clear shelf spacing are geometric estimates.\n- The selected valid variant is built through the real Kerfwise cabinet engine. The native project has a custom zero-price material, no back, no doors or edging, and butt-joint settings.\n- Open the exported .kerfwise.json in Kerfwise to inspect construction, material prices, fixings, loads and anti-tip requirements before manufacture. This tool does not establish structural adequacy.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "kerfwise_variant_sheet",
        "x-owner-app": "kerfwise",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KerfwiseVariantSheetInput"
              },
              "examples": {
                "example1": {
                  "summary": "Try an example",
                  "value": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KerfwiseVariantSheetResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "KerfwiseVariantSheetInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "widths": {
            "title": "Widths in mm, separated by commas",
            "type": "string",
            "maxLength": 200,
            "default": "400, 600, 800"
          },
          "heights": {
            "title": "Heights in mm, separated by commas",
            "type": "string",
            "maxLength": 200,
            "default": "600, 900, 1200"
          },
          "depth": {
            "title": "Depth (mm)",
            "type": "number",
            "minimum": 100,
            "maximum": 1200,
            "default": 300
          },
          "thickness": {
            "title": "Panel thickness (mm)",
            "type": "number",
            "minimum": 3,
            "maximum": 100,
            "default": 18
          },
          "shelves": {
            "title": "Whole shelf count",
            "type": "number",
            "minimum": 0,
            "maximum": 12,
            "default": 2
          },
          "selected": {
            "title": "Selected variant number",
            "type": "number",
            "minimum": 1,
            "maximum": 25,
            "default": 1
          }
        },
        "required": []
      },
      "KerfwiseVariantSheetResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "variants",
              "svg",
              "selected",
              "parts",
              "warnings"
            ],
            "properties": {
              "variants": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "index",
                    "width",
                    "height",
                    "depth",
                    "valid",
                    "panelAreaM2",
                    "usableShelfHeight"
                  ],
                  "properties": {
                    "index": {
                      "type": "number"
                    },
                    "width": {
                      "type": "number"
                    },
                    "height": {
                      "type": "number"
                    },
                    "depth": {
                      "type": "number"
                    },
                    "valid": {
                      "type": "boolean"
                    },
                    "panelAreaM2": {
                      "type": "number"
                    },
                    "usableShelfHeight": {
                      "type": "number"
                    }
                  }
                }
              },
              "svg": {
                "type": "string"
              },
              "selected": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "index",
                  "width",
                  "height",
                  "depth",
                  "valid",
                  "panelAreaM2",
                  "usableShelfHeight"
                ],
                "properties": {
                  "index": {
                    "type": "number"
                  },
                  "width": {
                    "type": "number"
                  },
                  "height": {
                    "type": "number"
                  },
                  "depth": {
                    "type": "number"
                  },
                  "valid": {
                    "type": "boolean"
                  },
                  "panelAreaM2": {
                    "type": "number"
                  },
                  "usableShelfHeight": {
                    "type": "number"
                  }
                }
              },
              "parts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "name",
                    "length",
                    "width",
                    "thickness"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "length": {
                      "type": "number"
                    },
                    "width": {
                      "type": "number"
                    },
                    "thickness": {
                      "type": "number"
                    }
                  }
                }
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}