#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": {
                            "alpha": {
                                "type": "string"
                            },
                            "beta": {
                                "type": "number"
                            },
                            "preserving": {
                                "type": "object",
                                "x-kubernetes-preserve-unknown-fields": true,
                                "properties": {
                                    "preserving": {
                                        "type": "object",
                                        "x-kubernetes-preserve-unknown-fields": true
                                    },
                                    "pruning": {
                                        "type": "object"
                                    },
                                    "pruning2": {
                                        "type": "object",
                                        "additionalProperties": {
                                            "type": "object",
                                            "properties": {
                                                "preserved": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            },
                            "pruning": {
                                "type": "object",
                                "properties": {
                                    "preserving": {
                                        "type": "object",
                                        "x-kubernetes-preserve-unknown-fields": true
                                    },
                                    "pruning": {
                                        "type": "object"
                                    }
                                }
                            }
                        },
                        "x-kubernetes-preserve-unknown-fields": true
                    }
                }
            }
        ]
    }
}

-- out/decode/extract --
_embeddedResource
alpha?: string
beta?:  number
preserving?: {
	preserving?: {
		...
	}
	pruning?: {}
	pruning2?: [string]: preserved?: string
	...
}
pruning?: {
	preserving?: {
		...
	}
	pruning?: {}
}

_embeddedResource: {
	apiVersion!: string
	kind!:       string
	metadata?: {
		...
	}
}
...
-- out/decodeCRD/extractCRD/0/v1 --
package v1

_embeddedResource
alpha?: string
beta?:  number
preserving?: {
	preserving?: {
		...
	}
	pruning?: {}
	pruning2?: [string]: preserved?: string
	...
}
pruning?: {
	preserving?: {
		...
	}
	pruning?: {}
}

_embeddedResource: {
	apiVersion!: string
	kind!:       string
	metadata?: {
		...
	}
}
apiVersion: "example.com/v1"
kind:       "MyApp"
metadata!: {
	name!:      string
	namespace!: string
	labels?: [string]: string
	annotations?: [string]: string
	...
}
...
