Skip to content

Upstream sub schema is resolved wrong #245

Open
@n0rad

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions