{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.connectsoft.ai/reference/schemas/blueprint-saas-descriptor.schema.json",
  "title": "SaaS descriptor import (blueprint-saas-descriptor-v1)",
  "description": "Import document of the SaaS descriptor family (<Context>.json with its entity-model schema), mapped by BlueprintService into one Service Blueprint context and one Module Blueprint (ADR-0025, BC-02); metadata per blueprint-common.schema.json; validation rules SAD-001..003 per model/blueprints.yaml.",
  "type": "object",
  "required": [
    "metadata",
    "context",
    "descriptorRef",
    "entities",
    "provisional"
  ],
  "additionalProperties": false,
  "properties": {
    "metadata": {
      "$ref": "blueprint-common.schema.json#/$defs/Metadata"
    },
    "context": {
      "type": "string"
    },
    "descriptorRef": {
      "type": "string",
      "description": "<Context>.json"
    },
    "schemaRef": {
      "type": "string",
      "description": "<Context>.schema.json"
    },
    "entityModelSchemaRef": {
      "type": "string",
      "description": "<Context>.entitymodel.schema.json"
    },
    "microserviceSchemaRef": {
      "type": "string",
      "description": "Microservice.schema.json"
    },
    "entities": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "name",
          "aggregate",
          "fields"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "aggregate": {
            "type": "string"
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "name",
                "type"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "required": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      }
    }
  }
}
