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: cannot define scalar at top level #3361

Closed
rogpeppe opened this issue Aug 8, 2024 · 0 comments
Closed

encoding/jsonschema: cannot define scalar at top level #3361

rogpeppe opened this issue Aug 8, 2024 · 0 comments

Comments

@rogpeppe
Copy link
Member

rogpeppe commented Aug 8, 2024

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

v0.9.2

Does this issue reproduce with the latest stable release?

Yes

What did you do?

exec cue def jsonschema: schema.json
cmp stdout want-stdout

-- want-stdout --
@jsonschema(schema="http://json-schema.org/draft-07/schema#")
@jsonschema(id="https://test.example/foo")
string

-- schema.json --
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://test.example/foo",
  "type": "string"
}

What did you expect to see?

Passing test.

What did you see instead?

> exec cue def jsonschema: schema.json
[stderr]
constraint not allowed because type object is excluded:
    ./schema.json:3:3
[exit status 1]
FAIL: /tmp/testscript1546751584/x.txtar/script.txtar:1: unexpected command failure

In the jsonschema implementation, the $id implementation constrains the result type to be
an object even though it doesn't have to be.

@rogpeppe rogpeppe added NeedsInvestigation Triage Requires triage/attention encoding NeedsFix and removed NeedsInvestigation Triage Requires triage/attention labels Aug 8, 2024
@cueckoo cueckoo closed this as completed in 915059d Aug 9, 2024
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