Skip to content

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

Open
@utkarsh1222

Description

@utkarsh1222

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions