{ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Container", "type": "object", "properties": { "result1": { "$ref": "#/$defs/Result_of_MyStruct_or_Array_of_string" }, "result2": { "$ref": "#/$defs/Result_of_boolean_or_null" } }, "required": [ "result1", "result2" ], "$defs": { "Result_of_MyStruct_or_Array_of_string": { "oneOf": [ { "type": "object", "properties": { "Ok": { "$ref": "#/$defs/MyStruct" } }, "required": [ "Ok" ] }, { "type": "object", "properties": { "Err": { "type": "array", "items": { "type": "string" } } }, "required": [ "Err" ] } ] }, "MyStruct": { "type": "object", "properties": { "foo": { "type": "integer", "format": "int32" } }, "required": [ "foo" ] }, "Result_of_boolean_or_null": { "oneOf": [ { "type": "object", "properties": { "Ok": { "type": "boolean" } }, "required": [ "Ok" ] }, { "type": "object", "properties": { "Err": { "type": "null" } }, "required": [ "Err" ] } ] } } }