-
Notifications
You must be signed in to change notification settings - Fork 264
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
Show all json schemas for yaml file in codelens #424
Conversation
…elens Signed-off-by: Yevhen Vydolob <[email protected]>
Signed-off-by: Yevhen Vydolob <[email protected]>
Signed-off-by: Yevhen Vydolob <[email protected]>
I am not sure about the overall experience of this. I do not think there are many users out there who are interested to navigate to json schemas. Now this path is putting navigation to schema to the front of every yaml file for the purpose of listing the schemas that the yaml is validated against. I do not think code lenses is a good fit for that purpose. |
@gorkem I don't think that we have much options on this, we have a lot of issues where users reports unexpected validation errors, just because yaml-ls uses wrong schema to validate file. The main goal for this PR is to show which JSON schemas used for specific yaml file, and navigation to thous schemas is optional. An alternative way to show which schema used is to add new vscode statusbar item, which will be vscode only and requires new non standard LSP extension. |
Signed-off-by: Yevhen Vydolob <[email protected]>
@@ -93,7 +94,7 @@ function addSchemasForOf(schema: JSONSchema, result: Map<string, JSONSchema>): v | |||
|
|||
function addInnerSchemaUrls(schemas: JSONSchemaRef[], result: Map<string, JSONSchema>): void { | |||
for (const subSchema of schemas) { | |||
if (isJSONSchema(subSchema)) { | |||
if (!isBoolean(subSchema)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still does not confirm that it is a JSONSchema.
"I'm looking for a dog. Is a bird? No, it's not a bird. OK, it's not a bird so it must be a dog" That does not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have only two choices, subSchema
can be boolean or JSONSchema
It would be enough to check that schema is not boolean, as rest check will do TS compiler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, since you are not using an any
I guess that could work.
I was thinking that if you wanted to confirm that matched the interface then test for expected mandatory fields. But I'll leave it up to you.
…rver into fix-i412 Signed-off-by: Yevhen Vydolob <[email protected]>
Signed-off-by: Yevhen Vydolob <[email protected]>
Is there any way this feature can be disabled? Sometimes it takes a while before the extension figures out the schema. When opening a file it can take 1-3 seconds before I find the line I am looking for, only for the codelens to pop in at that exact moment, shifting all the lines one down and completely ruining my concentration. It's... frustrating to say the least. |
@andsens Just put "[yaml]": {
"editor.codeLens": false
} in to your settings |
@evidolob this info should be on README. on vscode-yaml |
What does this PR do?
Add CodeLens at the beginning of the file with all applied JSON Schema's, click on that CodeLans will open JSON Schema in separate tab:
Screen.Recording.2021-03-16.at.15.58.43.mov
Als it improves opening schemas, now all possible type of schema is supported, including schema contributed from vscode-yaml api.
What issues does this PR fix or reference?
#412
Is it tested? How?
With tests and manual, just open any yaml file which has JSON Schema, CodeLens with name and file name should appears above first line.