Relative references not working correctly.
It'll be easiest to explain with example: I have a folder structure:
│ index.js
│
├───test1
│ test1.json
│ test11.json
│
└───test2
test2.json
test1.json contains:
{
"MyProp": "Test1",
"$ref": "../test2/test2.json#/Prop",
"Test11": [
{
"$ref": "../test1/test11.json#/MyProp"
}
]
}
trying to deference test1.json fails, with an error that is not really true:
'Error: Error resolving $ref pointer "c:/refparserTest/test1/test11.json#/MyProp". \n' +
'"c:/refparserTest/test1/test11.json" not found.\n'
while you can see that /test1/test11.json actually exists, the path is correct.
I've tried few other ways:
"$ref": "test11.json#/MyProp" will use a wrong directory.
"$ref": "./../test1/test11.json#/MyProp" also wont work.
"$ref": "./test1/test11.json#/MyProp" will report wrong path also: test2/test1/test11.json
I am having a similar problem:
When I try to reach a file in another folder using a relative path it just ends with a weird error. Assuming the root dir is called test for example referencing test2.json from your index.js results into: Error resolving $ref pointer "/test2/test2.json" while I clearly typed in "$ref": "./test2/test2.json" and then it should reach /test/test2/test2.json. When I try to reach it through absolute paths other weird things happen.
I use node in docker, maybe there is the issue?
After some investigation with my coworker, it looks like "$ref": "../test2/test2.json#/Prop", is being dereferenced successfully, but after that the root path is not being changed back to test1.json and it tries to dereference "$ref": "../test1/test11.json#/MyProp" in test2.json scope, and fails cause "Test11" variable path doesnt exists there.
@OsaPL I'm also facing this issue... Just wondering if there's a reason why you didn't create a PR for the fix in your fork? Thanks
There was a PR but I had trouble adding tests (mainly to my lack of knowledge and time). https://github.com/APIDevTools/json-schema-ref-parser/pull/261