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

How do I configure a schema that uses a "bundle" format? #64

Open
nbn22385 opened this issue Aug 5, 2022 · 4 comments
Open

How do I configure a schema that uses a "bundle" format? #64

nbn22385 opened this issue Aug 5, 2022 · 4 comments

Comments

@nbn22385
Copy link

nbn22385 commented Aug 5, 2022

See here: https://github.com/ansible/schemas#schema-bundle

The Ansible schemas have migrated to using this new bundle format but coc-yaml cannot seem to resolve the schema in this format.

image

I have my yaml.schemas configured as they suggest in the linked documentation:

image

For the filetypes in the image above that use the non-bundle format (ansible-meta, ansible-vars), the schema works just fine, but the bundle ones (lines 114, 115) i get the errors above.

Can coc-yaml resolve these types of URLs?

@nbn22385
Copy link
Author

nbn22385 commented Aug 8, 2022

May be unrelated to coc-yaml:

redhat-developer/yaml-language-server#694

@jguedez
Copy link

jguedez commented Nov 13, 2022

The "$ref" in the error message looks like a URL encoded string for /$defs/tasks :

$ref '%2F%24defs%2Ftasks' in 'https://raw.githubusercontent.com/ansible/schemas/main/f/ansible.json' can not be resolved. (YAML 768)

Something along the way is not decoding the URL properly and causing the issue, since subschemas seem to work properly (no errors and stuff like "hover", etc. does work), when specifying directly a modline like this:

# yaml-language-server: $schema=https://raw.githubusercontent.com/ansible/schemas/main/f/ansible.json#/$defs/tasks

However, overriding the glob mapping in the coc-settings.json to avoid having to set that in each file did not for me unless I'm doing something wrong (or that might just be related to: redhat-developer/yaml-language-server#694)

{
  "yaml.schemas": {
    "https://raw.githubusercontent.com/ansible/schemas/main/f/ansible.json#/$defs/tasks": [
        "**/tasks/*.yml",
        "**/tasks/*.yaml",
        "**/handlers/*.yml", 
        "**/handlers/*.yaml"
    ]
}

@metal3d
Copy link

metal3d commented Dec 22, 2022

@jguedez same problem with the coc-settings. Nothing seems to work for me excepting the comment in all yaml files.

@metal3d
Copy link

metal3d commented Dec 22, 2022

Found the solution... Setup Coc with :CocConfig and add:

  "yaml.schemas": {
    "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/tasks.json": [
      "**/tasks/*.yml",
      "**/tasks/*.yaml",
      "**/handlers/*.yml",
      "**/handlers/*.yaml"
    ]
  }

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

3 participants