{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://specs.kivanura.org/gedra/0.1/gedra-0.1.schema.json",
  "title": "GEDRA 0.1 Machine-Readable Architecture Schema",
  "description": "Structural JSON / JSON-LD validation companion for GEDRA 0.1. Structural validity does not by itself establish GEDRA architectural conformance.",
  "oneOf": [
    {
      "$ref": "#/$defs/ArchitectureInstance"
    },
    {
      "$ref": "#/$defs/ConformanceClaim"
    },
    {
      "$ref": "#/$defs/ArchitectureElement"
    },
    {
      "$ref": "#/$defs/ArchitectureMapping"
    },
    {
      "$ref": "#/$defs/TerminologyMapping"
    },
    {
      "$ref": "#/$defs/ApplicabilityStatement"
    },
    {
      "$ref": "#/$defs/Extension"
    },
    {
      "$ref": "#/$defs/Deviation"
    },
    {
      "$ref": "#/$defs/AssessmentEvidenceReference"
    },
    {
      "$ref": "#/$defs/ArchitectureDecisionReference"
    },
    {
      "$ref": "#/$defs/RequirementReference"
    }
  ],
  "$defs": {
    "Scope": {
      "oneOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "object",
          "required": [
            "name"
          ],
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "format": "uri-reference"
            },
            "name": {
              "type": "string",
              "minLength": 1
            },
            "description": {
              "type": "string",
              "minLength": 1
            },
            "scopeType": {
              "type": "string",
              "minLength": 1
            }
          },
          "additionalProperties": true
        }
      ]
    },
    "ProfileBinding": {
      "type": "object",
      "required": [
        "id",
        "version"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "version": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "ArchitectureElement": {
      "type": "object",
      "required": [
        "id",
        "type",
        "name",
        "elementType"
      ],
      "properties": {
        "@context": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "object"
            },
            {
              "type": "array",
              "minItems": 1,
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object"
                  }
                ]
              }
            }
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "type": {
          "const": "ArchitectureElement"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        },
        "elementType": {
          "type": "string",
          "minLength": 1
        },
        "owner": {
          "type": "string",
          "minLength": 1
        },
        "sourceReference": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "technology": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": true
    },
    "ArchitectureMapping": {
      "type": "object",
      "required": [
        "id",
        "type",
        "source",
        "relationship",
        "target"
      ],
      "properties": {
        "@context": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "object"
            },
            {
              "type": "array",
              "minItems": 1,
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object"
                  }
                ]
              }
            }
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "type": {
          "const": "ArchitectureMapping"
        },
        "source": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "relationship": {
          "type": "string",
          "enum": [
            "hasPlane",
            "hasCrossCuttingConcern",
            "hasTechnologyFoundation",
            "hasPattern",
            "hasView",
            "hasProfile",
            "hasConformanceLevel",
            "referencesConcept",
            "hasParticipantConcept",
            "primaryArchitecturalPlacementFor",
            "mapsTo",
            "realizes",
            "playsRole",
            "usesPattern",
            "derivedFrom",
            "profileOf",
            "specializes",
            "requires",
            "projects",
            "assesses",
            "claimsConformanceLevel",
            "appliesProfile",
            "hasDeviation",
            "hasExtension",
            "hasTerminologyMapping",
            "supportedBy",
            "inheritedFrom",
            "delegatedTo"
          ]
        },
        "target": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "rationale": {
          "type": "string",
          "minLength": 1
        },
        "scope": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/Scope"
          }
        }
      },
      "additionalProperties": true
    },
    "TerminologyMapping": {
      "type": "object",
      "required": [
        "id",
        "type",
        "localTerm",
        "targetConcept",
        "mappingType"
      ],
      "properties": {
        "@context": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "object"
            },
            {
              "type": "array",
              "minItems": 1,
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object"
                  }
                ]
              }
            }
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "type": {
          "const": "TerminologyMapping"
        },
        "localTerm": {
          "type": "string",
          "minLength": 1
        },
        "targetConcept": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "mappingType": {
          "type": "string",
          "enum": [
            "equivalent",
            "specializes",
            "broader",
            "narrower",
            "related",
            "not-equivalent"
          ]
        },
        "rationale": {
          "type": "string",
          "minLength": 1
        },
        "scope": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/Scope"
          }
        },
        "caveats": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        }
      },
      "additionalProperties": true
    },
    "ApplicabilityStatement": {
      "type": "object",
      "required": [
        "id",
        "type",
        "subject",
        "targetResponsibility",
        "status"
      ],
      "properties": {
        "@context": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "object"
            },
            {
              "type": "array",
              "minItems": 1,
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object"
                  }
                ]
              }
            }
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "type": {
          "const": "ApplicabilityStatement"
        },
        "subject": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "targetResponsibility": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "status": {
          "type": "string",
          "enum": [
            "applicable",
            "not-applicable",
            "inherited",
            "delegated"
          ]
        },
        "rationale": {
          "type": "string",
          "minLength": 1
        },
        "inheritedFrom": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1,
            "format": "uri-reference"
          },
          "uniqueItems": true
        },
        "delegatedTo": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1,
            "format": "uri-reference"
          },
          "uniqueItems": true
        },
        "supportedBy": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1,
            "format": "uri-reference"
          },
          "uniqueItems": true
        },
        "realizes": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1,
            "format": "uri-reference"
          },
          "uniqueItems": true
        },
        "mapsTo": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1,
            "format": "uri-reference"
          },
          "uniqueItems": true
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "status": {
                "const": "not-applicable"
              }
            },
            "required": [
              "status"
            ]
          },
          "then": {
            "required": [
              "rationale"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "status": {
                "const": "inherited"
              }
            },
            "required": [
              "status"
            ]
          },
          "then": {
            "required": [
              "inheritedFrom"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "status": {
                "const": "delegated"
              }
            },
            "required": [
              "status"
            ]
          },
          "then": {
            "required": [
              "delegatedTo"
            ]
          }
        }
      ],
      "additionalProperties": true
    },
    "Extension": {
      "type": "object",
      "required": [
        "id",
        "type",
        "name",
        "description",
        "scope"
      ],
      "properties": {
        "@context": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "object"
            },
            {
              "type": "array",
              "minItems": 1,
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object"
                  }
                ]
              }
            }
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "type": {
          "const": "Extension"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        },
        "scope": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/Scope"
          }
        },
        "rationale": {
          "type": "string",
          "minLength": 1
        },
        "relatedGEDRAConstruct": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "format": "uri-reference"
          },
          "uniqueItems": true
        }
      },
      "additionalProperties": true
    },
    "Deviation": {
      "type": "object",
      "required": [
        "id",
        "type",
        "subject",
        "deviatesFrom",
        "reason",
        "status"
      ],
      "properties": {
        "@context": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "object"
            },
            {
              "type": "array",
              "minItems": 1,
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object"
                  }
                ]
              }
            }
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "type": {
          "const": "Deviation"
        },
        "subject": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "deviatesFrom": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "reason": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "minLength": 1
        },
        "scope": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/Scope"
          }
        },
        "impact": {
          "type": "string",
          "minLength": 1
        },
        "risk": {
          "type": "string",
          "minLength": 1
        },
        "approvedBy": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "reviewDate": {
          "type": "string",
          "format": "date"
        },
        "expiryDate": {
          "type": "string",
          "format": "date"
        },
        "remediation": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": true
    },
    "AssessmentEvidenceReference": {
      "type": "object",
      "required": [
        "id",
        "type",
        "evidenceType",
        "reference"
      ],
      "properties": {
        "@context": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "object"
            },
            {
              "type": "array",
              "minItems": 1,
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object"
                  }
                ]
              }
            }
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "type": {
          "const": "AssessmentEvidenceReference"
        },
        "evidenceType": {
          "type": "string",
          "minLength": 1
        },
        "reference": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": true
    },
    "ArchitectureDecisionReference": {
      "type": "object",
      "required": [
        "id",
        "type",
        "reference"
      ],
      "properties": {
        "@context": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "object"
            },
            {
              "type": "array",
              "minItems": 1,
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object"
                  }
                ]
              }
            }
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "type": {
          "const": "ArchitectureDecisionReference"
        },
        "reference": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "decisionDate": {
          "type": "string",
          "format": "date"
        }
      },
      "additionalProperties": true
    },
    "RequirementReference": {
      "type": "object",
      "required": [
        "id",
        "type",
        "reference"
      ],
      "properties": {
        "@context": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "object"
            },
            {
              "type": "array",
              "minItems": 1,
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object"
                  }
                ]
              }
            }
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "type": {
          "const": "RequirementReference"
        },
        "reference": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": true
    },
    "ArchitectureInstance": {
      "type": "object",
      "required": [
        "id",
        "type",
        "name",
        "architectureType",
        "scope",
        "gedraVersion",
        "status"
      ],
      "properties": {
        "@context": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "object"
            },
            {
              "type": "array",
              "minItems": 1,
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object"
                  }
                ]
              }
            }
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "type": {
          "const": "ArchitectureInstance"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        },
        "architectureType": {
          "type": "string",
          "enum": [
            "enterprise",
            "domain",
            "programme",
            "solution",
            "implementation",
            "other"
          ]
        },
        "scope": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/Scope"
          }
        },
        "gedraVersion": {
          "const": "0.1"
        },
        "status": {
          "type": "string",
          "minLength": 1
        },
        "derivedFrom": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "format": "uri-reference"
          },
          "uniqueItems": true
        },
        "appliesProfile": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ProfileBinding"
          },
          "uniqueItems": true
        },
        "architectureElements": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ArchitectureElement"
          }
        },
        "architectureMappings": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ArchitectureMapping"
          }
        },
        "applicabilityStatements": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ApplicabilityStatement"
          }
        },
        "terminologyMappings": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TerminologyMapping"
          }
        },
        "extensions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Extension"
          }
        },
        "deviations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Deviation"
          }
        },
        "views": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "format": "uri-reference"
          },
          "uniqueItems": true
        },
        "references": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "format": "uri-reference"
          },
          "uniqueItems": true
        }
      },
      "additionalProperties": true
    },
    "ConformanceClaim": {
      "type": "object",
      "required": [
        "id",
        "type",
        "assesses",
        "gedraVersion",
        "scope",
        "claimsConformanceLevel",
        "assessmentDate",
        "assessmentResult",
        "status"
      ],
      "properties": {
        "@context": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "object"
            },
            {
              "type": "array",
              "minItems": 1,
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object"
                  }
                ]
              }
            }
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "type": {
          "const": "ConformanceClaim"
        },
        "assesses": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "gedraVersion": {
          "const": "0.1"
        },
        "scope": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/Scope"
          }
        },
        "claimsConformanceLevel": {
          "type": "string",
          "enum": [
            "GEDRA-CL-001",
            "GEDRA-CL-002",
            "GEDRA-CL-003"
          ]
        },
        "assessmentDate": {
          "type": "string",
          "format": "date"
        },
        "assessmentResult": {
          "type": "string",
          "enum": [
            "conformant",
            "conformant-with-approved-deviations",
            "not-conformant",
            "assessment-incomplete"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "draft",
            "self-assessed",
            "reviewed",
            "approved",
            "approved-with-deviation",
            "not-conformant",
            "expired",
            "superseded"
          ]
        },
        "appliesProfile": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ProfileBinding"
          },
          "uniqueItems": true
        },
        "applicabilityStatements": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ApplicabilityStatement"
          }
        },
        "hasTerminologyMapping": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TerminologyMapping"
          }
        },
        "hasDeviation": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Deviation"
          }
        },
        "hasExtension": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Extension"
          }
        },
        "supportedBy": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AssessmentEvidenceReference"
          }
        },
        "assessedBy": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "format": "uri-reference"
          },
          "uniqueItems": true
        },
        "approvedBy": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "format": "uri-reference"
          },
          "uniqueItems": true
        },
        "effectiveFrom": {
          "type": "string",
          "format": "date"
        },
        "reviewDate": {
          "type": "string",
          "format": "date"
        },
        "supersedes": {
          "type": "string",
          "minLength": 1,
          "format": "uri-reference"
        },
        "notes": {
          "type": "string",
          "minLength": 1
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "claimsConformanceLevel": {
                "const": "GEDRA-CL-003"
              }
            },
            "required": [
              "claimsConformanceLevel"
            ]
          },
          "then": {
            "required": [
              "appliesProfile"
            ],
            "properties": {
              "appliesProfile": {
                "minItems": 1
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "claimsConformanceLevel": {
                "enum": [
                  "GEDRA-CL-002",
                  "GEDRA-CL-003"
                ]
              }
            },
            "required": [
              "claimsConformanceLevel"
            ]
          },
          "then": {
            "required": [
              "supportedBy"
            ],
            "properties": {
              "supportedBy": {
                "minItems": 1
              }
            }
          }
        }
      ],
      "additionalProperties": true
    }
  }
}
