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

Support $schema reference to JSON schema #204

Closed
aaron-meyers opened this issue Nov 26, 2019 · 7 comments
Closed

Support $schema reference to JSON schema #204

aaron-meyers opened this issue Nov 26, 2019 · 7 comments

Comments

@aaron-meyers
Copy link

aaron-meyers commented Nov 26, 2019

Currently JSON schema for a YAML file must be specified externally, either via settings or from the public schema store.

I'd like to be able to specify the schema to use in the YAML document itself. This is possible with JSON documents by specifying a $schema property, e.g.

{
  "$schema": "http://some.org/schema",
  "prop1": "value1"
  ...
}

It seems reasonable to me that the same convention could be supported for YAML documents (as this is defined as part of the JSON schema spec itself):

$schema: http://some.org/schema
prop1: value1
...
@pappasam
Copy link

This feature would be incredible.

@apupier
Copy link
Member

apupier commented Jul 15, 2020

I don't think that we can use the notation

$schema: http://some.org/schema
prop1: value1

because it means that the $schema should be part of the schema definition. It seems quite intrusive. All schemas would need to be updated.

What about using a comment/modeline? such as:

# json-schema: http://some.org/schema
prop1: value1

or

# yaml-language-server: json-schema=http://some.org/schema
prop1: value1

or

# yaml-language-server: $schema=http://some.org/schema
prop1: value1

nota: would be best to have it part of the specification but it doesn't seem to be part of priorities: json-schema-org/json-schema-spec#828

apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 15, 2020
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 15, 2020
@ssbarnea
Copy link
Member

Lets open a sister ticket on YAML meta repository itself, maybe YAML spec authors can help us make a good/future proof decision?

@apupier
Copy link
Member

apupier commented Jul 16, 2020

YAML meta repository itself

Can you precise which repository it is please?

@ssbarnea
Copy link
Member

I think there is an existing ticket at yaml/yaml-spec#33 -- better to comment on it. Also a good channel to engage with spec people is #yaml-dev on freenode. Maybe there is some hope...

@apupier
Copy link
Member

apupier commented Jul 16, 2020

I tried to put a not yet defined directive and unfortunately, they are not ignored. It is reporting a validation error. I think that we can go with a comment # something as a first iteration, waiting that Yaml spec introduce the specific Yaml schema directive.
When the yaml schema directive will be available, it will be relatively simple to support it also.

apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 21, 2020
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 21, 2020
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 21, 2020
- association done using modeline "# yaml-language-server:
$schema=<mySchemaURL">

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 21, 2020
- association done using modeline "# yaml-language-server:
$schema=<mySchemaURL">

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 21, 2020
- association done using modeline "# yaml-language-server:
$schema=<mySchemaURL">

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 21, 2020
…veloper#204

it requires to cast the parameter in 2 places.

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 22, 2020
Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 22, 2020
…veloper#204

it requires to cast the parameter in 2 places.

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 22, 2020
Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 22, 2020
…at-developer#204

it ensures that the schema is well-applied also on documents with only
the schema declaration

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 22, 2020
the "textEdit" is not provided due to an existing bug on master
redhat-developer#288

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 23, 2020
apupier added a commit to apupier/yaml-language-server that referenced this issue Jul 23, 2020
@apupier
Copy link
Member

apupier commented Jul 24, 2020

implemented using # yaml-language-server: $schema=http://some.org/schema format

@apupier apupier closed this as completed Jul 24, 2020
@apupier apupier added this to the 0.10.0 milestone Jul 24, 2020
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

5 participants