cue
cue copied to clipboard
encoding/jsonschema: additionalProperties false in top level object results in open struct
What version of CUE are you using (cue version)?
$ cue version v0.10.0
Does this issue reproduce with the latest stable release?
Yes
What did you do?
exec cue def schema.json
cmp stdout want-stdout
-- want-stdout --
@jsonschema(schema="https://json-schema.org/draft/2020-12/schema")
_#: {}
_#
-- schema.json --
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": false
}
What did you expect to see?
A passing test (or similar closed struct output)
What did you see instead?
> exec cue def schema.json
[stdout]
@jsonschema(schema="https://json-schema.org/draft/2020-12/schema")
...
> cmp stdout want-stdout
diff stdout want-stdout
--- stdout
+++ want-stdout
@@ -1,2 +1,4 @@
@jsonschema(schema="https://json-schema.org/draft/2020-12/schema")
-...
+
+_#: {}
+_#
FAIL: /tmp/testscript2715937007/x.txtar/script.txtar:2: stdout and want-stdout differ
The resulting top level struct is not closed as it should be.
The resulting top level struct is not closed as it should be.
I think it probably depends on how the result is used. If the imported result is used as a package value, then it is closed.
What's your intuition on what we should do here?
This is very much related to https://github.com/cue-lang/cue/issues/3008
Fixed by https://review.gerrithub.io/c/cue-lang/cue/+/1202854