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

Pick up schema from $schema prop like with JSON #567

Open
safareli opened this issue Jul 26, 2021 · 4 comments
Open

Pick up schema from $schema prop like with JSON #567

safareli opened this issue Jul 26, 2021 · 4 comments

Comments

@safareli
Copy link

In case of JSON files it's possible to discover the support for $schema naturally by following the Trigger Suggest command:

Screen.Recording.2021-07-26.at.3.54.50.PM.mov

Tho with YAML, even if you were to write out the comment you would see no autocompletion. To achieve same you should write out # yaml-language-server: $schema=https://json.schemastore.org/tsconfig. Which should be memoized, or stored as a snippet. or you should mess with configuration of this extension, which should be discovered in the first place and is not as portable as $schema is with json.

Screen.Recording.2021-07-26.at.3.56.49.PM.mov

Describe the solution you would like

It would be great to support similar UX to what exists with JSON. where suggestions help you discover $schema support and then by specifying $schema, schema is used to validate the file. no need to mess with extentsion configuration or comments.

@evidolob
Copy link
Collaborator

@safareli We already have a PR with this redhat-developer/yaml-language-server#354
But we not merged yet, as having $schema key in YAML may cause validation errors if JSON Schema doesn’t allow additional properties for "root" Object.
I need to think how we can handle that.

@apupier
Copy link
Member

apupier commented Oct 21, 2021

I think the $schema should not be added at yam-language-server. it will break the yaml schema specifications. It is the yaml specification which needs top be updated. You can vote for it yaml/yaml-spec#33. Even if there is a trick in yaml language server to allow invalid file, the risk is high that another tool/library will respect it and fail to load/parse the file.

if i understand well, the problem here is the discovery on how to add a schema. For this, it is possible to provide the completion to add the full modeline redhat-developer/yaml-language-server#559 and another one for the list of schemas redhat-developer/yaml-language-server#560 .

@apupier
Copy link
Member

apupier commented Dec 6, 2021

Here is the result:
yamlInlineSchemaCompletionSmaller

Note: the tsconfig, used as example of this issue, is filtered out because no filename match a yaml file. In fact, for tsconfig, yaml file is not supported.

@carlosedp
Copy link

Any news on 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

4 participants