{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/vedika-io/json-schema/vedika-io-vastu-plan-report-request-schema.json",
  "title": "VastuPlanReportRequest",
  "description": "Source-derived request for plan/report. Fields not listed here are ignored. Explicit units/inputUnits is recommended for interchange. Omitted units retain legacy coordinate behavior.",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/vedika-io-openapi.json#/components/schemas/VastuPlanReportRequest",
  "type": "object",
  "required": [
    "rooms"
  ],
  "properties": {
    "rooms": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Room name as written or drawn; shown back unchanged. When it is not a known room type, room, roomType, label and type are tried in that order and the first known one classifies the room."
          },
          "room": {
            "type": "string"
          },
          "roomType": {
            "type": "string",
            "description": "Clean room type (for example kitchen). Used to classify the room when name is a drawing label the model cannot read, such as a CAD abbreviation or text in another language."
          },
          "label": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "description": "Alias for roomType, tried last."
          },
          "zone": {
            "type": "string"
          },
          "direction": {
            "type": "string"
          },
          "x": {
            "type": "number"
          },
          "y": {
            "type": "number"
          },
          "w": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true
          },
          "h": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true
          },
          "width": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true
          },
          "height": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true
          },
          "polygon": {
            "type": "array",
            "minItems": 3,
            "items": {
              "oneOf": [
                {
                  "type": "array",
                  "minItems": 2,
                  "maxItems": 2,
                  "items": {
                    "type": "number"
                  }
                },
                {
                  "type": "object",
                  "required": [
                    "x",
                    "y"
                  ],
                  "properties": {
                    "x": {
                      "type": "number"
                    },
                    "y": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false
                }
              ]
            },
            "description": "A simple (non-self-crossing) room outline inside the plot frame."
          },
          "outline": {
            "type": "array",
            "minItems": 3,
            "items": {
              "oneOf": [
                {
                  "type": "array",
                  "minItems": 2,
                  "maxItems": 2,
                  "items": {
                    "type": "number"
                  }
                },
                {
                  "type": "object",
                  "required": [
                    "x",
                    "y"
                  ],
                  "properties": {
                    "x": {
                      "type": "number"
                    },
                    "y": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false
                }
              ]
            },
            "description": "A simple (non-self-crossing) room outline inside the plot frame."
          },
          "area": {
            "type": "number",
            "minimum": 0
          },
          "headingErrorDeg": {
            "type": "number",
            "minimum": 0,
            "maximum": 180,
            "description": "Symmetric heading bound in degrees. Optional; absent preserves existing output exactly."
          },
          "positionErrorM": {
            "type": "number",
            "minimum": 0,
            "maximum": 10000,
            "description": "Euclidean position-disc radius in metres. Requires point geometry and an explicit plot frame. Metre geometry is the default; plot.units=ft converts coordinates using the international foot. The plot frame is held fixed."
          },
          "holes": {
            "type": "array",
            "maxItems": 64,
            "items": {
              "$ref": "#/$defs/VastuPlanPolygon"
            }
          },
          "multipolygons": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "$ref": "#/$defs/VastuPlanRegion"
            },
            "description": "Disjoint filled wings. Send either polygon with holes or multipolygons."
          }
        },
        "additionalProperties": false,
        "anyOf": [
          {
            "required": [
              "name"
            ]
          },
          {
            "required": [
              "room"
            ]
          },
          {
            "required": [
              "roomType"
            ]
          },
          {
            "required": [
              "label"
            ]
          }
        ],
        "description": "Each room needs a label and EITHER a zone/direction, a rectangle {x, y, w, h} (w/h may be sent as width/height) that lies inside the plot frame (1% tolerance), or a polygon/outline."
      }
    },
    "plot": {
      "type": "object",
      "additionalProperties": true
    },
    "format": {
      "type": "string",
      "enum": [
        "json",
        "html",
        "pdf"
      ],
      "default": "json",
      "description": "json returns report data; html adds escaped standalone HTML; pdf adds an existing-renderer PDF as base64 artifact.content. Composition applies to HTML and PDF. Render failure returns 503 without charge."
    },
    "brand": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "reportTitle": {
          "type": "string"
        },
        "generatedFor": {
          "type": "string"
        }
      }
    },
    "reportTitle": {
      "type": "string"
    },
    "generatedFor": {
      "type": "string"
    },
    "tenantName": {
      "type": "string"
    },
    "headingErrorDeg": {
      "type": "number",
      "minimum": 0,
      "maximum": 180,
      "description": "Symmetric heading bound in degrees. Optional; absent preserves existing output exactly."
    },
    "positionErrorM": {
      "type": "number",
      "minimum": 0,
      "maximum": 10000,
      "description": "Euclidean position-disc radius in metres. Requires point geometry and an explicit plot frame. Metre geometry is the default; plot.units=ft converts coordinates using the international foot. The plot frame is held fixed."
    },
    "composition": {
      "type": "object",
      "properties": {
        "sections": {
          "type": "array",
          "minItems": 1,
          "maxItems": 10,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "enum": [
              "summary",
              "facing",
              "plot-shape",
              "compliance",
              "rooms",
              "zones",
              "defects",
              "remedies",
              "elements",
              "sources"
            ]
          }
        },
        "intro": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 4000
        },
        "outro": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 4000
        },
        "ctaBlocks": {
          "type": "array",
          "maxItems": 8,
          "items": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160
              },
              "link": {
                "type": "string",
                "minLength": 1,
                "maxLength": 2048,
                "format": "uri",
                "pattern": "^https://"
              },
              "phone": {
                "type": [
                  "string",
                  "null"
                ],
                "minLength": 1,
                "maxLength": 40
              }
            },
            "required": [
              "label",
              "link"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "merchantCatalogId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[A-Za-z0-9_-]{1,128}$"
    },
    "propertyId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[A-Za-z0-9_.\\-/]+$",
      "description": "Buyer-supplied non-secret attribution identifier. Account-scoped; does not grant property access."
    },
    "tenantRef": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[A-Za-z0-9_.\\-/]+$",
      "description": "Buyer-supplied non-secret attribution identifier. Account-scoped; does not grant property access."
    },
    "units": {
      "type": "string",
      "enum": [
        "m",
        "ft",
        "mm",
        "in"
      ],
      "description": "Linear plan coordinates and unsuffixed dimensions use this unit. area fields use its square. Internally normalized once to metres; fields explicitly suffixed M/M2 remain metres."
    },
    "inputUnits": {
      "type": "string",
      "enum": [
        "m",
        "ft",
        "mm",
        "in"
      ],
      "description": "Linear plan coordinates and unsuffixed dimensions use this unit. area fields use its square. Internally normalized once to metres; fields explicitly suffixed M/M2 remain metres."
    }
  },
  "additionalProperties": true,
  "$defs": {
    "VastuPlanPolygon": {
      "type": "array",
      "minItems": 3,
      "items": {
        "oneOf": [
          {
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "items": {
              "type": "number"
            }
          },
          {
            "type": "object",
            "required": [
              "x",
              "y"
            ],
            "properties": {
              "x": {
                "type": "number"
              },
              "y": {
                "type": "number"
              }
            },
            "additionalProperties": true
          }
        ]
      },
      "description": "Traced ring as [x, y] pairs or {x, y} objects. Coordinates must be finite numbers. Runtime also requires at least three distinct corners enclosing nonzero area."
    },
    "VastuPlanRegion": {
      "type": "object",
      "required": [
        "polygon"
      ],
      "properties": {
        "polygon": {
          "$ref": "#/$defs/VastuPlanPolygon"
        },
        "holes": {
          "type": "array",
          "maxItems": 64,
          "items": {
            "$ref": "#/$defs/VastuPlanPolygon"
          }
        }
      },
      "description": "Filled outer boundary minus disjoint interior rings. Voids must lie strictly inside."
    }
  }
}