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

Disabling proxies doesn't work recursively #48

Closed
plondino opened this issue Nov 3, 2022 · 3 comments
Closed

Disabling proxies doesn't work recursively #48

plondino opened this issue Nov 3, 2022 · 3 comments

Comments

@plondino
Copy link

plondino commented Nov 3, 2022

When set proxies=False, the $ref fields in the first document are converted to a regular dict, but if there is a $ref in the resolved document, it remains a jsonref proxy and the document won't serialize via vanilla json.dumps.

@plondino
Copy link
Author

plondino commented Nov 3, 2022

Here's a short script and files that reproduce the issue:

import json
import os
import pathlib
import sys
from typing import Union

import jsonref

PathLike = Union[str, bytes, os.PathLike]

MODEL = json.load(open('model.json'))


def load_schema_with_refs_from_path(schema_path: PathLike, proxies=True):
    base_uri = f'{schema_path.parent.as_uri()}/'
    return jsonref.loads(open(schema_path).read(),
                         base_uri=base_uri, proxies=proxies, jsonschema=False)


if __name__ == '__main__':
    schema_path = pathlib.Path(sys.argv[1]).absolute()
    schema_without_refs = json.load(schema_path.open())
    print(json.dumps(schema_without_refs))
    schema_with_refs = load_schema_with_refs_from_path(schema_path,
                                                       proxies=False)
    print(json.dumps(schema_with_refs))

Archive.zip

@gazpachoking
Copy link
Owner

Hmm. I'll take a peek

@gazpachoking
Copy link
Owner

Thanks for the report! I think we should be good to go in 1.0.1. It gets a bit confusing trying to handle the recursive data structures, hopefully I haven't missed anything.

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

2 participants