Skip to content

Bundling of Draft-07 schemas with relative URI references does not work #657

@michalstutzmann

Description

@michalstutzmann

Here's a example with Draft-07 of the JSON Schema spec:

$ jsonschema --version
14.9.0

$ cat schema.schema.json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "test.schema.json",
  "allOf": [
    {
      "$ref": "../dependency.schema.json"
    }
  ]
}

$ cat ../dependency.schema.json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "dependency.schema.json"
}

$ jsonschema bundle schema.schema.json --resolve ../dependency.schema.json
error: Could not resolve the reference to an external schema
  at identifier ../dependency.schema.json
  at file (...)schema.schema.json

This is likely because you forgot to import such schema using `--resolve/-r`

I'm not entirely sure if such references are allowed by the spec. However, the Draft-07 specifies that a $ref can contain URI reference. URI reference can be a relative reference: https://datatracker.ietf.org/doc/html/rfc3986#section-4.1, https://datatracker.ietf.org/doc/html/rfc3986#section-4.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions