{
  "openapi": "3.1.0",
  "info": {
    "title": "MFT/3 TableTop Creator API",
    "version": "1.5.0",
    "summary": "Festool MFT/3 hole patterns as files",
    "description": "The Festool MFT/3 dog-hole pattern for any valid top size, as a true-to-scale SVG for Shaper Origin/Studio or as JSON. Both endpoints take the same parameters as the tool's address and apply the same rules: sizes snap to the nearest valid MFT/3 length (46 + 96 × n mm, n = 1–20). All values are millimetres. Free, unofficial hobby tool by Anders Fredenslund — not affiliated with Festool or Shaper.",
    "contact": {
      "name": "Anders Fredenslund",
      "email": "anders@fredenslund.dk",
      "url": "https://fredenslund.dk/"
    }
  },
  "servers": [
    {
      "url": "https://fredenslund.dk"
    }
  ],
  "paths": {
    "/mft/pattern.svg": {
      "get": {
        "operationId": "getPatternSvg",
        "summary": "The hole pattern as a true-to-scale SVG, identical to the tool's Download button",
        "parameters": [
          {
            "$ref": "#/components/parameters/b"
          },
          {
            "$ref": "#/components/parameters/d"
          },
          {
            "$ref": "#/components/parameters/t"
          },
          {
            "$ref": "#/components/parameters/c"
          },
          {
            "name": "download",
            "in": "query",
            "description": "If present, the response is sent as a file download (Content-Disposition: attachment) instead of inline",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SVG in mm (width/height in mm, 1:1 viewBox, no text). Cut types follow Shaper's colour convention with depths in shaper:cutDepth: outline = exterior at thickness + 1 mm, Ø20 dog holes and Ø11 screw holes = interior at the same depth, Ø15 counterbores = pocket at the counterbore depth (omitted at 0). The file name is in Content-Disposition.",
            "content": {
              "image/svg+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/mft/pattern.json": {
      "get": {
        "operationId": "getPatternJson",
        "summary": "The snapped size, hole count, every hole and screw-hole position, export depths, file name and links",
        "parameters": [
          {
            "$ref": "#/components/parameters/b"
          },
          {
            "$ref": "#/components/parameters/d"
          },
          {
            "$ref": "#/components/parameters/t"
          },
          {
            "$ref": "#/components/parameters/c"
          }
        ],
        "responses": {
          "200": {
            "description": "The pattern as data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Pattern"
                },
                "example": {
                  "tool": "MFT/3 TableTop Creator",
                  "units": "mm",
                  "input": {
                    "b": 1100,
                    "d": 700
                  },
                  "top": {
                    "width": 1102,
                    "depth": 718,
                    "holesX": 11,
                    "holesY": 7,
                    "holes": 77,
                    "adjustedWidth": 2,
                    "adjustedDepth": 18
                  },
                  "grid": {
                    "spacing": 96,
                    "holeDiameter": 20,
                    "edgeToFirstHoleCentre": 71,
                    "marginX": 71,
                    "marginY": 71
                  },
                  "aluProfile": {
                    "width": 1060,
                    "depth": 676
                  },
                  "holes": [
                    {
                      "x": 71,
                      "y": 71
                    }
                  ],
                  "screwHoles": {
                    "throughDiameter": 11,
                    "counterboreDiameter": 15,
                    "fromCorner": {
                      "x": 43.36,
                      "y": 50.5
                    },
                    "positions": [
                      {
                        "x": 43.36,
                        "y": 50.5
                      }
                    ]
                  },
                  "export": {
                    "thickness": 19,
                    "cutDepth": 20,
                    "counterboreDepth": 6,
                    "fileName": "MFT3-TableTop 1102mm x 718mm 11x7 holes 19mm.svg"
                  },
                  "links": {
                    "tool": "https://fredenslund.dk/mft/?b=1102&d=718",
                    "svg": "https://fredenslund.dk/mft/pattern.svg?b=1102&d=718&t=19&c=6",
                    "specifications": "https://fredenslund.dk/mft/specifications/",
                    "openapi": "https://fredenslund.dk/mft/openapi.json"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "b": {
        "name": "b",
        "in": "query",
        "description": "Top width in mm. Snaps to the nearest valid size (142–1966); empty, invalid or 0 gives the original 1102",
        "schema": {
          "type": "number",
          "default": 1102
        }
      },
      "d": {
        "name": "d",
        "in": "query",
        "description": "Top depth in mm. Snaps to the nearest valid size (142–1966); empty, invalid or 0 gives the original 718",
        "schema": {
          "type": "number",
          "default": 718
        }
      },
      "t": {
        "name": "t",
        "in": "query",
        "description": "Board thickness in mm (> 0, default 19). Through cuts are encoded at thickness + 1 mm overcut",
        "schema": {
          "type": "number",
          "default": 19
        }
      },
      "c": {
        "name": "c",
        "in": "query",
        "description": "Counterbore depth in mm for the Ø15 screw-hole rings (≥ 0, default 6; 0 omits them; never deeper than the thickness)",
        "schema": {
          "type": "number",
          "default": 6
        }
      }
    },
    "schemas": {
      "Pattern": {
        "type": "object",
        "properties": {
          "tool": {
            "type": "string"
          },
          "units": {
            "type": "string",
            "const": "mm"
          },
          "input": {
            "type": "object",
            "properties": {
              "b": {
                "type": "number"
              },
              "d": {
                "type": "number"
              }
            },
            "description": "The values received (after defaults)"
          },
          "top": {
            "type": "object",
            "properties": {
              "width": {
                "type": "integer"
              },
              "depth": {
                "type": "integer"
              },
              "holesX": {
                "type": "integer"
              },
              "holesY": {
                "type": "integer"
              },
              "holes": {
                "type": "integer"
              },
              "adjustedWidth": {
                "type": "number",
                "description": "width − b"
              },
              "adjustedDepth": {
                "type": "number",
                "description": "depth − d"
              }
            }
          },
          "grid": {
            "type": "object",
            "properties": {
              "spacing": {
                "type": "integer"
              },
              "holeDiameter": {
                "type": "integer"
              },
              "edgeToFirstHoleCentre": {
                "type": "number"
              },
              "marginX": {
                "type": "number"
              },
              "marginY": {
                "type": "number"
              }
            }
          },
          "aluProfile": {
            "type": "object",
            "properties": {
              "width": {
                "type": "integer"
              },
              "depth": {
                "type": "integer"
              }
            },
            "description": "Matching aluminium edge profile lengths from the size matrix (top − 42 mm)"
          },
          "holes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Point"
            },
            "description": "Hole centres, row by row from the top-left corner of the top"
          },
          "screwHoles": {
            "type": "object",
            "properties": {
              "throughDiameter": {
                "type": "number"
              },
              "counterboreDiameter": {
                "type": "number"
              },
              "fromCorner": {
                "$ref": "#/components/schemas/Point"
              },
              "positions": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Point"
                }
              }
            }
          },
          "export": {
            "type": "object",
            "properties": {
              "thickness": {
                "type": "number"
              },
              "cutDepth": {
                "type": "number"
              },
              "counterboreDepth": {
                "type": "number"
              },
              "fileName": {
                "type": "string"
              }
            }
          },
          "links": {
            "type": "object",
            "properties": {
              "tool": {
                "type": "string",
                "format": "uri"
              },
              "svg": {
                "type": "string",
                "format": "uri"
              },
              "specifications": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      },
      "Point": {
        "type": "object",
        "properties": {
          "x": {
            "type": "number"
          },
          "y": {
            "type": "number"
          }
        }
      }
    }
  }
}
