Support relative symlinks as schema paths by h3ndrk · Pull Request #2780 · glideapps/quicktype

Description

This PR allows quicktype to resolve schemas behind a relative symbolic link.

Related Issue

I did not create a issue before fixing it, but here are the steps to reproduce:

echo '{}' > schema.json
mkdir schemas
ln -s ../schema.json schemas/schema.json
quicktype --debug all --lang python --src-lang schema -o generated.py schemas/schema.json
# resolving # relative to schemas/schema.json# (schemas/schema.json#)
# trying to fetch schemas/schema.json
# couldn't fetch schemas/schema.json
# trying to fetch schemas/schema.json
# couldn't fetch schemas/schema.json
# Error: Internal error: .

Motivation and Context

Absolute symbolic links are already supported, but relative links are not supported yet. This PR adds support for them.

Previous Behaviour / Output

resolving # relative to schemas/schema.json# (schemas/schema.json#)
trying to fetch schemas/schema.json
couldn't fetch schemas/schema.json
trying to fetch schemas/schema.json
couldn't fetch schemas/schema.json
Error: Internal error: .

New Behaviour / Output

Only debug output, but no errors anymore regarding schema fetching.

How Has This Been Tested?

For simplicity reasons I only included an empty schema in the steps to reproduce. Other than that, use the steps to reproduce to test.