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

not going inside custom resolver if absolute path is same but realtive path is different #350

Open
utkarsh1222 opened this issue May 30, 2024 · 0 comments

Comments

@utkarsh1222
Copy link

utkarsh1222 commented May 30, 2024

while dereferencing the schema my logic written inside custom resolver is not getting executed because I think its just checking the absolute path and returns the resolved value from the cache.
Code is:
$RefParser.dereference(schemaObject, {
abc: {
order: 1,
canRead: /^abc:/i,
read: async (file, callback) => {
const id = file.url.replace(/^abc:/, '');
const result = await api.fetchResource(id);
const resolvedSchema = structuredClone(result);
callback(null, resolvedSchema)
}
}
});

in this case if I am having two $ref like "abc:12345#/schema/firstSchema" and "abc:12345#/schema/secondSchema".
then first time it will go inside custom resolver but for the second ref it is not going.

Is there anyway I can prevent this because I wanted to add a check inside custom resolver itself to check if the schema mentioned in relative path exists or not, if not then it should return {} instead of throwing error.

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

1 participant