{
  "$defs": {
    "ChildAnyOf": {
      "additionalProperties": false,
      "anyOf": [
        {
          "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"
        }
      },
      "type": "object"
    },
    "RootAnyOf": {
      "additionalProperties": false,
      "anyOf": [
        {
          "required": [
            "field1",
            "field4"
          ],
          "title": "group1"
        },
        {
          "required": [
            "field2"
          ],
          "title": "group2"
        }
      ],
      "properties": {
        "child": {
          "$ref": "#/$defs/ChildAnyOf"
        },
        "field1": {
          "type": "string"
        },
        "field2": {
          "type": "string"
        },
        "field3": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "array"
            }
          ]
        },
        "field4": {
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "$id": "https://github.com/invopop/jsonschema/root-any-of",
  "$ref": "#/$defs/RootAnyOf",
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}