Need help with openapi-to-dhall

Hi,

I’ve tried to generate dhall bindings for traefik using openapi-to-dhall. They provide CRDs here: https://github.com/traefik/traefik/blob/v2.5/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml
I’ve looked at how dhall-kubernetes is generated, but this didn’t help much, there are the following key differences:

  • K8 provides a single swagger file, while there are 9 files for Traefik. This affects top-level files like schemas.dhall - they are overwritten for each file;
  • K8 schema provides more fine-grained types.

As a result I get 9 huge types almost without defaults. Sample default: { apiVersion = "v1alpha1", kind = "TLSOption" }
I’ve been able to “fix” dhall files for traefik.containo.us.Middleware.dhall, but this required manually splitting 12 type files and 2 default and schema files. This might work for a single release, but will be very hard to support over future releases. Sample test file - https://github.com/K0Te/dhall-traefik-k8/blob/main/2.5/Test.dhall
Am I misusing openapi-to-dhall? Or is it just a poor schema that should be improved?
I’ve used the following commands:

for file in `ls ../source/`; do echo $file; yaml-to-dhall --file ../source/$file | dhall-to-json > $file ; done
for file in `ls work`; do openapi-to-dhall --crd work/$file; done

Does combining the split YAML files into a single YAML file resolve the issue?

openapi-to-dhall --crd seems to handle a single CRD at once. I’ve tried to compose all YAMLs, but this resulted in the list at the top level, failing validation for openapi-to-dhall --crd.

hey @Oleg_Nykolyn did you happen to find a resolution to your problem here? I am facing a very similar thing (with Argo Rollouts and Applications.)

To cross link (if I can) the issue I opened on the dhall-haskell repo: openapi-to-dhall generates deeply nested objects from CRDs · Issue #2330 · dhall-lang/dhall-haskell · GitHub

Unfortunately not, I’ve manually re-created part of schema that was required for my traefik setup.
It would be great if openapi-to-dhall supported full generation for such openapi schemas.

got it. I was about to do something similar but then realized that I can just use jq to flatten the schema out and add the right k8s custom fields. Seems to be working so far. If it does, hopefully we can release a nice CRD preprocessor to help with this.