timoni icon indicating copy to clipboard operation
timoni copied to clipboard

[bug] The import function vendor crd not correctly converting fields that have constraints 'oneOf', 'not', and 'anyOf'

Open yyvess opened this issue 5 months ago • 1 comments

The import function vendor crd not correctly converting fields that have constraints 'oneOf', 'not', and 'anyOf'

Not sure if the bug is on Timoni or in Cue, perhaps around it https://github.com/cue-lang/cue/blob/64a117c07a084f82970596f3ac67023087952f4f/encoding/jsonschema/constraints.go#L288 ?

Command used timoni mod vendor crd -f https://raw.githubusercontent.com/istio/istio/1.20.2/manifests/charts/base/crds/crd-all.gen.yaml

As exemple the field method declared on the Istio crd to enforce that one and only one property exact, prefix or regex is defined as is

method: {
  oneOf: [{
    not: anyOf: [ { required: ["exact"]} , { required: ["prefix"]} , { required: ["regex"]}] },
    ,{required: ["exact"]}
    ,{required: ["prefix"]}
    ,{required: ["regex"]
  }]
  properties: {
	  exact: type: "string"
	  prefix: type: "string"
	  regex: { type: "string" }
  }
  type: "object"
}

The CUE output not corresponding and don't allow to set any property on method

method?: ({} | {
	exact: _
} | {
	prefix: _
} | {
	regex: _
}) & {
	exact?:  string
	prefix?: string
	regex?: string
}

yyvess avatar Feb 04 '24 22:02 yyvess