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

Cannot find a way to use a custom ref resolver #150

Open
alasdairhurst opened this issue Dec 12, 2018 · 2 comments
Open

Cannot find a way to use a custom ref resolver #150

alasdairhurst opened this issue Dec 12, 2018 · 2 comments

Comments

@alasdairhurst
Copy link

I have a swagger document with references which are valid JSON schema references (URIs), These are references to an internal library of schemas which understands this URI with a "schema://" protocol. Currently, I don't see any way of providing a function to resolve references myself. The preprocessor would be the only visible place to do this, although the output of the preprocessor has to be something which is still not dereferenced, otherwise you will end up getting the following error: (there should probably be a check on the return value of refPreProcessor to validate that the value is still ref-like.

{code}
TypeError: Cannot read property 'reference' of undefined
at getRefType (C:\git\s\node_modules\json-refs\index.js:156:33)
at refFilter (C:\git\s\node_modules\json-refs\index.js:258:77)
at C:\git\s\node_modules\json-refs\index.js:269:82
at C:\git\s\node_modules\json-refs\index.js:269:82
at Object.filter (C:\git\s\node_modules\json-refs\index.js:269:82)
at C:\git\s\node_modules\json-refs\index.js:606:24
at walk (C:\git\s\node_modules\json-refs\index.js:436:23)
at walkItem (C:\git\s\node_modules\json-refs\index.js:430:5)
at C:\git\s\node_modules\json-refs\index.js:450:11
at C:\git\s\node_modules\lodash\lodash.js:4911:15
{code}

I'd like to be able to provide an async function/promise/function with callback with similar parameters to refPreProcessor, so that I can resolve specific references myself and then fall back to json-refs if this was not possible (for example by returning/resolving with the original ref-like object).

@whitlockjc
Copy link
Owner

I will get started on whitlockjc/path-loader#1, update json-refs to use the new version of path-loader and then you could pass on options.jsonRefs.loaderOptions to use a custom loader.

@alasdairhurst
Copy link
Author

alasdairhurst commented Dec 13, 2018

Issue # 1, nice.

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

2 participants