{ "$schema":                "https://json-schema.org/draft/2020-12/schema",
  "$id":                    "https://schemas.mpai.community/MMM4/V2.2/data/MEnvironment.json",
  "title":                  "MEnvironment V2.2", "type":                   "object", "properties": {

    "Header":               { "type": "string", "pattern": "^MMM-MEN-V[0-9],{1,2},[.][0-9],{1,2}$" },
    "MInstanceID":          { "type": "string" },
    "MEnvironmentID":       { "type": "string" },

    "Capabilities":         { "$ref": "https://schemas.mpai.community/MMM4/V2.2/data/Capabilities.json" },

    "Rules":                { "type": "array", "items": { "anyOf": [
      { "type": "object", "properties": { "Rules": { "$ref": "#/$defs/Rules" } } },
      { "type": "object", "properties": { "RulesID": { "type": "string" } } } ] } },

    "Rights":               { "$ref": "#/$defs/Rights" },
    "DataExchangeMetadata": { "$ref": "https://schemas.mpai.community/PTF/V1.0/data/DataExchangeMetadata.json" },
    "Trace":                { "$ref": "https://schemas.mpai.community/AIF/V3.0/data/Trace.json" },
    "DescrMetadata":        { "type": "string", "maxLength": 2048 } },

  "$defs":                  {

    "Rules":               { "type": "array", "minItems": 1, "items": { "oneOf": [

      { "type": "object", "additionalProperties": false, "required": [ "Rule" ], "properties":
        { "Rule": { "$ref": "https://schemas.mpai.community/MMM4/V2.2/data/Rule.json" } } },

      { "type": "object", "additionalProperties": false, "required": [ "RuleID" ], "properties":
        { "RightID": { "type": "string" } } } ] } },

    "Rights":               { "type": "array", "minItems": 1, "items": { "oneOf": [

      { "type": "object", "additionalProperties": false, "required": [ "Right" ], "properties":
        { "Right": { "$ref": "https://schemas.mpai.community/MMM4/V2.2/data/Right.json" } } },

      { "type": "object", "additionalProperties": false, "required": [ "RightID" ], "properties":
        { "RightID": { "type": "string" } } } ] } } } }

