Skip to content

Commit

Permalink
encoding/jsonschema: add test case for issue 3176
Browse files Browse the repository at this point in the history
The current logic gets the disjunction wrong when
generating CUE for jsonschema when there's a
oneOf that is then modified by an additional constraint.
Specifically the resulting schema does not allow
a string value when it should.

This CL adds a test case that will be fixed in a subsequent CL.

For #3176.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I96a24d981fb4a90c55c9f09bee6db1bbde047648
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199400
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
  • Loading branch information
rogpeppe committed Aug 13, 2024
1 parent 0bd8619 commit 2122b51
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions encoding/jsonschema/testdata/issue3176.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- definition.json --
{
"oneOf": [
{
"type": "object"
},
{
"maxLength": 3,
"type": "string"
}
],
"patternProperties": {
"^x-": {
"type": "string"
}
}
}
-- out/decode/cue --
import "strings"

({
...
} | strings.MaxRunes(3)) & {
{[=~"^x-" & !~"^()$"]: string}
...
}

0 comments on commit 2122b51

Please sign in to comment.