{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/invopop/jsonschema/root-one-of",
  "$ref": "#/$defs/RootOneOf",
  "$defs": {
    "ChildOneOf": {
      "oneOf": [
        {
          "required": [
            "child1",
            "child4"
          ],
          "title": "group1"
        },
        {
          "required": [
            "child2",
            "child3"
          ],
          "title": "group2"
        }
      ],
      "properties": {
        "child1": {
          "type": "string"
        },
        "child2": {
          "type": "string"
        },
        "child3": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array"
            }
          ]
        },
        "child4": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "RootOneOf": {
      "oneOf": [
        {
          "required": [
            "field1",
            "field4"
          ],
          "title": "group1"
        },
        {
          "required": [
            "field2"
          ],
          "title": "group2"
        }
      ],
      "properties": {
        "field1": {
          "type": "string"
        },
        "field2": {
          "type": "string"
        },
        "field3": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array"
            }
          ]
        },
        "field4": {
          "type": "string"
        },
        "child": {
          "$ref": "#/$defs/ChildOneOf"
        },
        "field6": {
          "oneOf": [
            {
              "$ref": "Outer"
            },
            {
              "$ref": "OuterNamed"
            },
            {
              "$ref": "OuterPtr"
            }
          ]
        }
      },
      "additionalProperties": false,
      "type": "object"
    }
  }
}