#version: k8sCRD

-- schema.json --
{
    "apiVersion": "apiextensions.k8s.io/v1",
    "kind": "CustomResourceDefinition",
    "metadata": {
        "name": "myapps.example.com"
    },
    "spec": {
        "group": "example.com",
        "scope": "Namespaced",
        "names": {
            "kind": "MyApp",
            "singular": "myapp",
            "plural": "myapps"
        },
        "versions": [
            {
                "name": "v1",
                "served": true,
                "storage": true,
                "schema": {
                    "openAPIV3Schema": {
                        "type": "object",
                        "properties": {
                            "apiVersion": {
                              "type": "string"
                            },
                            "kind": {
                               "type": "string"
                            },
                            "metadata": {
                              "type": "object"
                            },
                            "r1": {
                                "type": "object",
                                "x-kubernetes-embedded-resource": true,
                                "x-kubernetes-preserve-unknown-fields": true
                            },
                            "r2": {
                                "type": "object",
                                "x-kubernetes-embedded-resource": true,
                                "properties": {
                                    "foo": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        ]
    }
}
-- out/decode/extract --
_embeddedResource
apiVersion?: string
kind?:       string
metadata?: {}
r1?: {
	_embeddedResource
	...
}
r2?: {
	_embeddedResource
	foo?: string
}

_embeddedResource: {
	apiVersion!: string
	kind!:       string
	metadata?: {
		...
	}
}
