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

encoding/jsonschema: #/properties $ref results in bad reference #3548

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

encoding/jsonschema: #/properties $ref results in bad reference #3548

rogpeppe opened this issue Nov 3, 2024 · 0 comments

Comments

@rogpeppe
Copy link
Member

rogpeppe commented Nov 3, 2024

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

73d4e255

Does this issue reproduce with the latest stable release?

Yes (v0.10.0)

What did you do?

exec cue import jsonschema: schema.json
exec cat schema.cue
exec cue vet schema.cue
-- schema.json --
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
    	"foo": {
    		"type": "boolean"
    	}
    },
    "definitions": {
    	"bar": {
    		"$ref": "#/properties/foo"
    	}
    }
}

What did you expect to see?

Passing test.

What did you see instead?

> exec cue import jsonschema: schema.json
> exec cat schema.cue
[stdout]
@jsonschema(schema="http://json-schema.org/draft-07/schema#")
"foo"?: bool

#bar: foo
...
> exec cue vet schema.cue
[stderr]
#bar: reference "foo" not found:
    ./schema.cue:4:7
[exit status 1]
FAIL: /tmp/x.txtar:3: unexpected command failure

There are a couple of issues here: firstly the foo field name is quoted so can't be referred to.
Secondly, the foo field is optional so can't be referred to anyway.

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