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

JSON schema property with both $ref and description incorrectly resolves and does not show description #729

Open
uncenter opened this issue Jan 8, 2025 · 2 comments

Comments

@uncenter
Copy link
Contributor

uncenter commented Jan 8, 2025

I recently made a change for the SchemaStore Cargo.toml schema that added support for [lints]/[workspace.lints].
For workspace.lints specifically, this looks like:

"lints": {
  "$ref": "#/definitions/Lints",
  "description": "The `workspace.lints` table is where you define lint configuration to be inherited by members of a workspace.",
  "x-taplo": {
    "links": {
      "key": "https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspace-section"
    }
  }
},

(https://github.com/SchemaStore/schemastore/blob/7c91a8e5a643d68cd11ce7ebcd18214a88d1cf7e/src/schemas/json/cargo.json#L1185-L1193)

You can see that both $ref and description are defined for this property. However, when using the Taplo LSP/extension in VS Code (and presumably in other editors), hovering over the lints part of workspace.lints shows no information/tooltip:

CleanShot 2025-01-08 at 09 41 31

When applying the same schema in a JSON file with the same contents, hovering over the lints property of workspace.lints does show a tooltip:

CleanShot 2025-01-08 at 09 42 20

Contents of the two files for reference
{
	"$schema": "https://json.schemastore.org/cargo.json",
	"workspace": {
		"lints": {
			"clippy": {
				"missing_errors_doc": "allow",
				"all": {
					"level": "warn",
					"priority": -1
				},
				"pedantic": {
					"level": "warn",
					"priority": -1
				}
			}
		}
	}
}
"$schema" = "https://json.schemastore.org/cargo.json"

[workspace.lints.clippy]
all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
missing_errors_doc = "allow"

I suspect this is an issue where when resolving the $ref, the description field is ignored.

I can confirm that the definition on hover works in general with the TOML file, as evidenced by the tooltip shown if I hover over the clippy property of workspace.lints:

CleanShot 2025-01-08 at 09 43 51

And of course this still works for the JSON file:

CleanShot 2025-01-08 at 09 44 29

@uncenter
Copy link
Contributor Author

uncenter commented Jan 8, 2025

This might be an issue with https://github.com/Stranger6667/jsonschema, not sure exactly where the responsibility for this comes from. Happy to remake this over there if this is the case.

@uncenter
Copy link
Contributor Author

uncenter commented Jan 9, 2025

I'm now wondering if this is of my own fault. It is more likely that the behavior I expect is simply not how JSON Schema itself works/is defined. In that case I can probably use something like https://github.com/orgs/json-schema-org/discussions/502 to move the reference out of the top level area for this property, but let me know if my schema snippet is invalid and I can close this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant