feat: add object and propName to onDereference callback #324
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an implementation proposal to add 2 new arguments to
dereference.onDereference
options.The 2 new arguments are:
parent
: The parent of the dereferenced objectparentPropName
: The prop name of the parent object whose value was dereferencedIn other words: the current 2nd
onDereference
argument (the inlined schema) would be the result ofobject[propName]
.Extra info
Exposing a callback with 4 arguments is probably sub optimal in terms of API. In a next major release the callback could be refactored to accept an object to provide named arguments.
The idea behind this PR was born while developing
openapi-ts-json-schema
, wherejson-schema-ref-parser
'sonDereference
callback is used to append meta data to the dereferenced objects. This would sensibly provide more flexibility and power to the callback.I'm aware it could be quite niche use case and I'll be fine whatever decision you are going to take about this PR.
Happy to update this PR based on you feedback, if the case.
Thank you so much for the priceless work you are doing here! 🙌
Cheers!