Describe the bug
If file A refers to file B via url, and file B refers to file C using a relative path, datamodel-codegen searches local file system (from A) for file C instead of adding the relative path to the url of file B.
To Reproduce
I cloned
https://github.com/ga4gh-beacon/beacon-v2/tree/main
and tried converting the json schema file (file A in the description above)
https://github.com/ga4gh-beacon/beacon-v2/blob/main/models/json/beacon-v2-default-model/analyses/defaultSchema.json
to pydantic.
this file refers to file B using url like this:
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/common/beaconCommonComponents.json#/definitions/Info"
File B refers to file C using relative path like this:
"$ref": "./ontologyTerm.json",
File C is available at
https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/common/ontologyTerm.json
but instead of finding this (by adding it to the url of file B), I get error
FileNotFoundError: [Errno 2] No such file or directory: '/Users/sondre/beacon-v2-main/models/json/beacon-v2-default-model/analyses/ontologyTerm.json'
i.e. the relative path is added to the path of file A.
Used commandline:
$ datamodel-codegen --input defaultSchema.json
Expected behavior
I think it should add the relative path to the file containing the relative path
Version:
Additional context
I forked and made a workaround, but i figured i should still let you know
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too