Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cue: cue def does not quote fields correctly #3563

Open
rogpeppe opened this issue Nov 7, 2024 · 0 comments
Open

cmd/cue: cue def does not quote fields correctly #3563

rogpeppe opened this issue Nov 7, 2024 · 0 comments

Comments

@rogpeppe
Copy link
Member

rogpeppe commented Nov 7, 2024

What version of CUE are you using (cue version)?

v0.11.0-alpha.5

Does this issue reproduce with the latest stable release?

No, although it might have related issues.
v0.10.0 version of encoding/jsonschema doesn't use matchN.

What did you do?

exec cue def -o schema.cue jsonschema: schema.json
exec cat schema.cue
exec cue vet schema.cue data.json
-- schema.json --
{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"type": "object",
	"properties": {
		"matchN": {
			"oneOf": [{
				"type": "string",
				"pattern": "^foo"
			}, {
				"type": "boolean"
			}]
		}
	}
}
-- data.json --
{"matchN": false}

What did you expect to see?

Passing test.

What did you see instead?

> exec cue def -o schema.cue jsonschema: schema.json
> exec cat schema.cue
[stdout]
@jsonschema(schema="https://json-schema.org/draft/2020-12/schema")
matchN?: matchN(1, [=~"^foo", bool])
...
> exec cue vet schema.cue data.json
[stderr]
matchN: cannot call non-function matchN (type bool):
    ./schema.cue:2:10
[exit status 1]
FAIL: /tmp/z.txtar:3: unexpected command failure

Note: this does not happen when using cue import: in that case, the matchN field is quoted correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant