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: unnecessary ellipses in open struct #3433

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

encoding/jsonschema: unnecessary ellipses in open struct #3433

rogpeppe opened this issue Sep 3, 2024 · 0 comments

Comments

@rogpeppe
Copy link
Member

rogpeppe commented Sep 3, 2024

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

$ cue version
46fb300df650bbaefdbe70d646a1a5b45f968c1f

Does this issue reproduce with the latest stable release?

Yes (at least since v0.9.2)

What did you do?

exec cue def schema.json
cmp stdout want-stdout
-- schema.json --
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
        "a": {
            "oneOf": [
                {
                    "type": "object",
                    "properties": {
                        "a": {
                            "type": "boolean"
                        }
                    },
                    "required": [
                        "a"
                    ]
                },
                {
                    "type": "object",
                    "properties": {
                        "b": {
                            "type": "boolean"
                        }
                    },
                    "required": [
                        "b"
                    ]
                }
            ]
        }
    }
}
-- want-stdout --
@jsonschema(schema="https://json-schema.org/draft/2020-12/schema")
a?: matchN(1, [{
	a!: bool
}, {
	b!: bool
}])

What did you expect to see?

Passing test.

What did you see instead?

> exec cue def schema.json
[stdout]
@jsonschema(schema="https://json-schema.org/draft/2020-12/schema")
a?: {
	a: bool
	...
} | {
	b: bool
	...
}
...
> cmp stdout want-stdout
diff stdout want-stdout
--- stdout
+++ want-stdout
@@ -1,9 +1,6 @@
 @jsonschema(schema="https://json-schema.org/draft/2020-12/schema")
-a?: {
-	a: bool
-	...
-} | {
-	b: bool
-	...
-}
-...
+a?: matchN(1, [{
+	a!: bool
+}, {
+	b!: bool
+}])

FAIL: /tmp/y.txtar:2: stdout and want-stdout differ

The ellipses (...) are unecessary because the structs (and the top level package) are open 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