-
Notifications
You must be signed in to change notification settings - Fork 351
Open
Description
Summary
openapi.Gen with ExpandReferences: true fails with unsupported op for number & when a definition contains a default value combined with a bounded integer conjunction.
Minimal reproduction
ctx := cuecontext.New()
v := ctx.CompileString(`#X: *20 | int & >=1 & <=100`)
_, err := openapi.Gen(v, &openapi.Generator{ExpandReferences: true})
// err: unsupported op for number &What works vs what doesn't
| Expression | ExpandReferences | Result |
|---|---|---|
#X: *20 | int & >=1 & <=100 |
false |
OK |
#X: *20 | int & >=1 & <=100 |
true |
FAILS |
#X: *20 | int |
true |
OK |
#X: int & >=1 & <=100 |
true |
OK |
#X: *20 | >=1 |
true |
OK |
#X: null | *20 | >=1 & <=100 |
true |
OK |
The combination of a default value (*20), a disjunction (|), and a conjunction of type+bounds (int & >=1 & <=100) is required to trigger the bug.
Where it fails
The error is produced at the default branch of the number() function:
Lines 936 to 942 in 66ea772
| case cue.NoOp: | |
| // TODO: extract format from specific type. | |
| default: | |
| b.failf(v, "unsupported op for number %v", op) | |
| } | |
| } |
number() handles individual constraint ops (>=, <=, <, >, !=, CallOp, NoOp) but has no case for AndOp. Normally conjunctions are decomposed before reaching number(), but with ExpandReferences: true the value arrives unsplit.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels