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

Upstream sub schema is resolved wrong #245

Open
n0rad opened this issue May 30, 2024 · 0 comments
Open

Upstream sub schema is resolved wrong #245

n0rad opened this issue May 30, 2024 · 0 comments

Comments

@n0rad
Copy link

n0rad commented May 30, 2024

When a local schema reference an public schema, it can find it, but when this public schema reference another public one, it's resolved wrong with a mix of local and public path in the lookup.

example:
local.json

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$ref": "https://public.website.com/schema/remote.json"
}

remote.json

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "test": {
      "$ref": "sub/test.json#/properties/enabled"
    }
  }
}

sub/test.json

{
  "type": "object",
  "properties": {
    "enabled": {
      "type": "boolean",
      "default": false
    }
  }
}

it fails with:

WARNING:root:Error loading schema from uri {/MY/LOCAL/PATH}https://public.website.com/schema/sub/test.json: [Errno 2] No such file or directory: '{/MY/LOCAL/PATH}https://public.website.com/schema/sub/test.json'
Traceback (most recent call last):
  File "/lib/python3.11/site-packages/json_schema_for_humans/schema/intermediate_representation.py", line 377, in _load_schema
    path_part_int = int(path_part)
                    ^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'properties'

I tried setting the $id of files to the public URL and tried to give the full URL for sub/test.json $ref, but it does not help

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

1 participant