kube-rs / kopium

Kubernetes OPenapI UnMangler
Apache License 2.0
113 stars 21 forks source link

Fix missing handling of preserve-unknown-fields on additionalProperties #244

Closed clux closed 5 months ago

clux commented 5 months ago

Implements handling of preserve-unknown-fields on dictionaries and fixes an issue on https://github.com/traefik/traefik-helm-chart/blob/ba3c4c44d60214dbfd6d15fae69b464bbcbbd4a6/traefik/crds/traefik.io_middlewares.yaml#L789

in particular this yaml:

              plugin:
                additionalProperties:
                  x-kubernetes-preserve-unknown-fields: true
                description: |-
                  Plugin defines the middleware plugin configuration.
                  More info: https://doc.traefik.io/traefik/plugins/
                type: object

causing an exit with Error: unknown empty dict type for plugin as noted in https://github.com/kube-rs/kopium/issues/73#issuecomment-2122674167

Now generates:

    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub plugin: Option<BTreeMap<String, serde_json::Value>>,