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

Schema URL fragments broken since 0.21.0 #557

Closed
1 of 4 tasks
mgabeler-lee-6rs opened this issue Jul 14, 2021 · 1 comment · Fixed by redhat-developer/yaml-language-server#512
Closed
1 of 4 tasks
Assignees

Comments

@mgabeler-lee-6rs
Copy link

Describe the bug

Given a yaml file with something like this as the first line:

# yaml-language-server: $schema=https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json#/definitions/Schema

In 0.20.x and before, the sub-schema was correctly loaded and applied to the document.

In 0.21.0, the remote load is broken, and in 0.21.1, it ignores the fragment and applies the top level schema.

Expected Behavior

It should obey the URL fragment like it used to, so that portions of schemas can be used. This is especially important for validating the targets of $ref properties from OpenAPI schemas.

Current Behavior

It ignores the fragment and validates the file using the "root" schema, which produces bazillions of bogus schema validation errors.

Steps to Reproduce

  1. Create a file using the fragment reference, which should validate according to the fragment. For example:
# yaml-language-server: $schema=https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json#/definitions/Schema
type: string
pattern: ^[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}$
  1. It should validate correctly
  2. Instead it complains that properties for a top level OpenAPI document are missing

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)
@evidolob
Copy link
Collaborator

I made some investigation of this, basically we don’t have a direct implementation of supporting schema url fragments (like: '#/definitions/Schema'). Previously it was working because of bug(related to how we store schema priority) with redhat-developer/yaml-language-server#499 I fix that bug. But apparently it broke schema url fragments. So I'm going to implement this like new feature.

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

Successfully merging a pull request may close this issue.

2 participants