{
  "openapi": "3.1.1",
  "info": {
    "title": "Maze Maker (Rectangle, Hexagon, Round and Shapes) API",
    "version": "1.0.0",
    "summary": "Printable mazes in squares, hexagons or circles, cut to a heart, star or your own shape.",
    "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://printshopmaze.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Printable mazes in squares, hexagons or circles, cut to a heart, star or your own shape.",
        "description": "Make printable mazes with square or hexagon cells or round “theta” mazes, optionally cut to a heart, star, circle, diamond, triangle or a shape you draw with # signs. Choose the recursive backtracker (long corridors), Kruskal or Wilson (uniform random) algorithm, up to six mazes per page and answer keys with the solution path.\n\nMethodology:\n- Every shape is a graph of cells whose sides are either shared with a neighbour or part of the outer wall. Square and hexagon grids can be cut to an outline (tested at each cell centre); only the largest connected group of cells is kept. Round mazes have one centre cell and rings whose cell count doubles when cells get wider than two ring heights.\n- The maze is a spanning tree of that graph, so exactly one path joins the entrance (top) and the exit (bottom, or the centre of a round maze). Recursive backtracker = randomised depth-first search (about 10 % dead ends); Kruskal = random walls removed with union–find (about 30 %); Wilson = loop-erased random walks, which pick every possible maze with the same probability.\n- The solution is found by breadth-first search through the open passages and drawn through the cell centres and the middle of each passage.\n\nVery large mazes on small paper get thin walls; check the PNG preview before printing many copies.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "printshop_maze",
        "x-owner-app": "printshop",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PrintshopMazeInput"
              },
              "examples": {
                "example1": {
                  "summary": "Classic 16 × 20 maze",
                  "value": {
                    "shape": "rect",
                    "cols": 16,
                    "rows": 20,
                    "algorithm": "backtracker",
                    "seed": "maze-1"
                  }
                },
                "example2": {
                  "summary": "Four heart-shaped mazes per page",
                  "value": {
                    "shape": "rect",
                    "cols": 24,
                    "rows": 22,
                    "mask": "heart",
                    "count": 4,
                    "perPage": "4",
                    "seed": "hearts"
                  }
                },
                "example3": {
                  "summary": "Round maze with 14 rings (Wilson)",
                  "value": {
                    "shape": "circle",
                    "rows": 14,
                    "algorithm": "wilson",
                    "seed": "round-1"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrintshopMazeResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "PrintshopMazeInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "shape": {
            "title": "Cells",
            "type": "string",
            "enum": [
              "rect",
              "hex",
              "circle"
            ],
            "default": "rect"
          },
          "cols": {
            "title": "Columns",
            "type": "integer",
            "minimum": 2,
            "maximum": 80,
            "default": 16
          },
          "rows": {
            "title": "Rows (rings for a round maze)",
            "type": "integer",
            "minimum": 2,
            "maximum": 80,
            "default": 20
          },
          "mask": {
            "title": "Outline",
            "type": "string",
            "enum": [
              "none",
              "heart",
              "star",
              "circle",
              "diamond",
              "triangle",
              "custom"
            ],
            "default": "none"
          },
          "maskText": {
            "title": "Own shape (# = inside)",
            "description": "One text line per row; # marks a cell inside the maze. Columns and rows then come from the drawing.",
            "type": "string",
            "maxLength": 8000,
            "default": ""
          },
          "algorithm": {
            "title": "Algorithm",
            "type": "string",
            "enum": [
              "backtracker",
              "kruskal",
              "wilson"
            ],
            "default": "backtracker"
          },
          "count": {
            "title": "Number of mazes",
            "type": "integer",
            "minimum": 1,
            "maximum": 24,
            "default": 1
          },
          "perPage": {
            "title": "Mazes per page",
            "type": "string",
            "enum": [
              "1",
              "2",
              "4",
              "6"
            ],
            "default": "1"
          },
          "seed": {
            "title": "Seed",
            "description": "The same seed and settings always give the same puzzles. Change it for new ones.",
            "type": "string",
            "maxLength": 80,
            "default": "maze-1"
          },
          "title": {
            "title": "Title on the page (optional)",
            "type": "string",
            "maxLength": 120,
            "default": ""
          },
          "answers": {
            "title": "Answer-key pages",
            "type": "boolean",
            "default": true
          },
          "header": {
            "title": "Name and date line",
            "type": "boolean",
            "default": true
          },
          "paper": {
            "title": "Paper size",
            "type": "string",
            "enum": [
              "a3",
              "a4",
              "a5",
              "a6",
              "b5",
              "letter",
              "legal",
              "tabloid",
              "halfletter"
            ],
            "default": "a4"
          },
          "orientation": {
            "title": "Orientation",
            "type": "string",
            "enum": [
              "portrait",
              "landscape"
            ],
            "default": "portrait"
          }
        },
        "required": []
      },
      "PrintshopMazeResult": {
        "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": [
              "shape",
              "algorithm",
              "mazes",
              "seed",
              "pages",
              "puzzlePages",
              "answerPages",
              "pageWidthMm",
              "pageHeightMm",
              "warnings",
              "files",
              "openInApp"
            ],
            "properties": {
              "shape": {
                "type": "string"
              },
              "algorithm": {
                "type": "string"
              },
              "mazes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "cells",
                    "deadEnds",
                    "solutionCells"
                  ],
                  "properties": {
                    "cells": {
                      "type": "integer"
                    },
                    "deadEnds": {
                      "type": "integer"
                    },
                    "solutionCells": {
                      "type": "integer"
                    }
                  }
                }
              },
              "seed": {
                "type": "string"
              },
              "pages": {
                "type": "integer"
              },
              "puzzlePages": {
                "type": "integer"
              },
              "answerPages": {
                "type": "integer"
              },
              "pageWidthMm": {
                "type": "number"
              },
              "pageHeightMm": {
                "type": "number"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "files": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "pdf",
                  "svg",
                  "png"
                ],
                "properties": {
                  "pdf": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  },
                  "svg": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  },
                  "png": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  }
                }
              },
              "openInApp": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}