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: doc comments are lost #3522

Open
rogpeppe opened this issue Oct 18, 2024 · 0 comments
Open

encoding/jsonschema: doc comments are lost #3522

rogpeppe opened this issue Oct 18, 2024 · 0 comments

Comments

@rogpeppe
Copy link
Member

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

6e0525b34633e296ae3e775faf7e4e99456c33e4

Does this issue reproduce with the latest stable release?

Yes (v0.10.0)

What did you do?

exec cue def -l '#top:' schema.json
stdout 'description of a field'
stdout 'overall description'
stdout 'description of foo'

-- schema.json --
{
    "$schema": "https://json-schema.org/draft/2019-09/schema",
    "$defs": {
        "foo": {
            "description": "description of foo",
            "properties": {
                "a": {
                    "description": "description of a field",
                    "type": "number"
                }
            }
        }
    },
    "description": "overall description",
    "$ref": "#/$defs/foo"
}

What did you expect to see?

A passing test. All the descriptions should be present as doc comments in the result.

What did you see instead?

> exec cue def -l '#top:' schema.json
[stdout]
#top: {
	// overall description
	@jsonschema(schema="https://json-schema.org/draft/2019-09/schema")
	#foo
	#foo: null | bool | number | string | [...] | {
		// description of a field
		a?: number
		...
	}
}
> stdout 'description of a field'
> stdout 'overall description'
> stdout 'description of foo'
FAIL: y.txtar:4: no match for `description of foo` found in stdout

The description of the foo definition isn't present, and the "overall description" text has moved into an inner comment on #top, where it will then be lost when computed with (e.g. compiling to a cue.Value) because it doesn't attach to any particular field.

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