Skip to content

URL-encoded characters in $ref paths break schema resolution #1082

@adalinesimonian

Description

@adalinesimonian

Describe the bug

Schemas with URL-encoded characters in $ref paths do not resolve. For example, a reference to something like "#/definitions/Interface<type>" fails to resolve if it is written as "#/definitions/Interface%3Ctype%3E".

Expected Behavior

The YAML language server should properly resolve URL-encoded $ref paths (e.g., #/definitions/Interface%3Ctype%3E) and provide IntelliSense, validation, and other features based on the referenced schema definition.

Current Behavior

When using a $ref path that includes URL-encoded characters, vscode-yaml does not recognize or resolve the schema definition, resulting in validation errors (e.g. $ref '/definitions/Interface%3Ctype%3E' in 'file:///.../schema.json' can not be resolved.).

Steps to Reproduce

  1. Create a file named example.schema.json containing the following schema:
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "myProperty": {
          "$ref": "#/definitions/Interface%3Ctype%3E"
        }
      },
      "definitions": {
        "Interface<type>": {
          "type": "object",
          "properties": {
            "foo": {
              "type": "string"
            }
          }
        }
      }
    }
  2. Create a file named example.yaml containing the following content:
    # yaml-language-server: $schema=example.schema.json
    
    myProperty:
      foo: bar
  3. Observe that the schema reference #/definitions/Interface%3Csomething%3E is not resolved, resulting in a validation error.

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)

Metadata

Metadata

Labels

Type

No type

Projects

Status

✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions