{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/vedika-io/json-schema/vedika-io-vastu-plan-upload-request-schema.json",
  "title": "VastuPlanUploadRequest",
  "description": "Source-derived request for plan/upload. 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/VastuPlanUploadRequest",
  "type": "object",
  "required": [],
  "properties": {
    "rooms": {
      "type": "array",
      "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."
      }
    },
    "layout": {
      "description": "The floor plan as an array of rooms (same items as rooms) or as an object {rooms, plot}. Send exactly one of rooms, layout or asciiGrid. An object layout may carry its own plot; do not also send a different top-level plot.",
      "oneOf": [
        {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "room": {
                "type": "string"
              },
              "roomType": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "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
              },
              "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."
          }
        },
        {
          "type": "object",
          "required": [
            "rooms"
          ],
          "properties": {
            "rooms": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "room": {
                    "type": "string"
                  },
                  "roomType": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string"
                  },
                  "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
                  },
                  "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
            }
          },
          "additionalProperties": true
        }
      ]
    },
    "asciiGrid": {
      "type": "string",
      "description": "A grid of room names, north at the top: one row per line, cells separated by \"|\", \",\" or two spaces. A cell is a room name, optionally with its zone (\"kitchen:SE\"); \".\" or \"-\" marks an empty cell. A bare zone code is not a room. Example: \"kitchen:NE | living:N\\npooja:NE | dining:E\\nbedroom:SW | toilet:SE\"."
    },
    "plot": {
      "type": "object",
      "additionalProperties": true
    },
    "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."
    },
    "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."
    }
  }
}