encoding/openapi: handle default-wrapped numeric conjunctions#4331
Open
orvis98 wants to merge 1 commit into
Open
encoding/openapi: handle default-wrapped numeric conjunctions#4331orvis98 wants to merge 1 commit into
orvis98 wants to merge 1 commit into
Conversation
With ExpandReferences set, a numeric field that combines a bound conjunction with a default via disjunction, such as "int & >=1 | *1", would fail to generate an OpenAPI schema with "unsupported op for number &". The value() dispatch pipeline relies on appendSplit to flatten a top-level conjunction into individual bound operands before handing each one to number(). When the value carries a default marker, cue.Value.Expr strips it and returns a NoOp wrapping the non-default arm. appendSplit's NoOp branch accepts that arm as a single conjunct without recursing, so a compound like "int & >=1" reaches number() with its AndOp intact and falls into the unsupported-op arm. Handle AndOp in number() by recursing into each operand. The operands are simpler sub-expressions and hit the existing bound handlers, which merge minimum/maximum into the same schema node. Fixes cue-lang#4305. Signed-off-by: John Enarsson <johnenarsson@hotmail.com>
orvis98
added a commit
to open-platform-model/cli
that referenced
this pull request
Apr 18, 2026
Converts a module's `#config` into a Kubernetes CRD via CUE's openapi encoder + structural-schema post-processing, enabling native kubectl/GitOps workflows alongside release files. Controller-side reconciliation is future work. - pkg/crd: name/version derivation, schema extraction, CRD assembly with provenance labels/annotations (OPM keys win over module keys). - internal/cmd/module/crd.go: Cobra command with `--group` and `-o yaml|json`. - tests/integration/module-crd: server-side dry-run apply against kind. go.mod temporarily `replace`s cuelang.org/go with the `opm-cli` branch of github.com/orvis98/cue to pick up cue-lang/cue#4331 (numeric bounds + default); drop once upstream tags a release. See openspec/changes/module-crd-poc/proposal.md for POC rules and deferred work. Signed-off-by: John Enarsson <johnenarsson@hotmail.com>
orvis98
added a commit
to open-platform-model/cli
that referenced
this pull request
Apr 18, 2026
Converts a module's `#config` into a Kubernetes CRD via CUE's openapi encoder + structural-schema post-processing, enabling native kubectl/GitOps workflows alongside release files. Controller-side reconciliation is future work. - pkg/crd: name/version derivation, schema extraction, CRD assembly with provenance labels/annotations (OPM keys win over module keys). - internal/cmd/module/crd.go: Cobra command with `--group` and `-o yaml|json`. - tests/integration/module-crd: server-side dry-run apply against kind. go.mod temporarily `replace`s cuelang.org/go with the `opm-cli` branch of github.com/orvis98/cue to pick up cue-lang/cue#4331 (numeric bounds + default); drop once upstream tags a release. See openspec/changes/module-crd-poc/proposal.md for POC rules and deferred work. Signed-off-by: John Enarsson <johnenarsson@hotmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With ExpandReferences set, a numeric field that combines a bound conjunction with a default via disjunction, such as "int & >=1 | *1", would fail to generate an OpenAPI schema with "unsupported op for number &".
The value() dispatch pipeline relies on appendSplit to flatten a top-level conjunction into individual bound operands before handing each one to number(). When the value carries a default marker, cue.Value.Expr strips it and returns a NoOp wrapping the non-default arm. appendSplit's NoOp branch accepts that arm as a single conjunct without recursing, so a compound like "int & >=1" reaches number() with its AndOp intact and falls into the unsupported-op arm.
Handle AndOp in number() by recursing into each operand. The operands are simpler sub-expressions and hit the existing bound handlers, which merge minimum/maximum into the same schema node.
Fixes #4305.