-
Notifications
You must be signed in to change notification settings - Fork 382
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
Set Default Working Directory to Schema Root #417
Comments
since at least at the moment this repo seems to be abandonden and my pr has been lying around for 2 months i decided to publish my fork (will deprecate it as soon as the $ref issues get resolved in this repo). Let me know if this fixes your issue as well. |
Hey @relief-melone - Do you know if the same works for CLI? I'm trying to
This is not working. I'm receiving the following error:
|
sorry for the late reply. i am using it in the cli and i think it sould work. Have you installed the original or my fork? If it's my fork feel free to create an issue. would be great if you provided a repo to reproduce the behaviour too |
Dup of #324. Sorry for the delayed response. Feel free to update the PR per requested changes! |
Set Default Working Directory to Schema Root
References should be resolved by the directory of the schema itself, not the script/program caller. Currently, the cwd is resetting on every de-reference, thus making it virtually impossible to compile multi-file schemas without first de-referencing them with the
$RefParser
library. This ruins the ability to reuse definition interfaces, and bloats code. Either way, defaulting to schema root would conform with the RFC, trivially.I don't think this should be too difficult to change because the $RefParser library does this by default.
Example of Issue (exposition):
Assume a working tree like the following.
And the file
schemas/bits/review_partial.json
being:And the file
schemas/helpers/object_id.json
being:schemas/bits/review_partial.json
outside the directory (say, at the root), will not result in a schema-relative reference.cwd
setting toschema/bits
, this initial reference will resolve, but the reference inschemas/helpers/object_id.json
will ALSO resolve withcwd
ofschemas/bits
, which, it isn't in, and thus the reference fails to resolve toschemas/helpers/token_wrapper.json
$RefParser
LibraryNote that the parser will auto resolve based on the schema root if invoked on the file. Take the last example: by default, the following will bundle the schema. This is required before passing it to this library, which, as I said ruins the possibility of interface definition re-use, and makes it much more difficult to invoke, especially without experience with JSON references.
The text was updated successfully, but these errors were encountered: