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

Support tokenized JSON Reference URIs #54

Closed
whitlockjc opened this issue Jan 5, 2016 · 11 comments
Closed

Support tokenized JSON Reference URIs #54

whitlockjc opened this issue Jan 5, 2016 · 11 comments

Comments

@whitlockjc
Copy link
Owner

Imagine your JSON document has i18n tokens in its JSON Reference URIs. It would be nice to be able to either pre-process a JSON Reference prior to generating its metadata via #getRefDetails/#findRefs and/or post-process the JSON Reference metadata after the fact to alter the metadata. While i18n is one example, any situation where you have dynamic URIs could benefit from this.

/cc @brettz9

@whitlockjc
Copy link
Owner Author

I could probably just get this done in 2.0.0. It won't hurt to push the release another day.

@brettz9
Copy link
Contributor

brettz9 commented Jan 5, 2016

Totally up to you... Your description looks good, though if you are implementing, I'm wondering whether your "post-process" idea involve altering the meta-data so the resolutions can immediately resume (as though the JSON reference had been well-formed in the first place). I guess I'm hoping for a "mid-process" capability to avoid repeating traversal of the JSON if that would be doable. But again, no need from my perspective to make it into this release.

@whitlockjc
Copy link
Owner Author

The idea of pre-processing is to do token replacement and such while post-processing might be some sort of failure recovery thing. As for "mid-process"...I'm not sure what you mean. We only process the document once every, even if you call APIs more than once. :)

@brettz9
Copy link
Contributor

brettz9 commented Jan 5, 2016

I just mean to avoid needing to both find all of the references once to do the variable substitution, and then searching the document again to find the fixed references to do the resolving.

@whitlockjc
Copy link
Owner Author

I think with pre-processing and/or post-processing, you could do it at one time.

@whitlockjc
Copy link
Owner Author

Well, the way I see implementing it.

@brettz9
Copy link
Contributor

brettz9 commented Jan 5, 2016

Ok, cool

@whitlockjc
Copy link
Owner Author

Let me know what you think. Here is the gist of it:

  • options.refPreProcessor allows you to pre-process a JSON Reference like object prior to #isRef being called on it.
  • options.refPostProcessor allows you to post-process a JSON Reference like object prior to options.filter and other filtering being ran against it

Neither of these functions modify the provided document. Feel free to look at the API documentation and tests to see how it works.

@brettz9
Copy link
Contributor

brettz9 commented Jan 5, 2016

Looks perfect, thanks very much!

@whitlockjc
Copy link
Owner Author

Do you have any time to play with the new APIs/options to give them a sanity check? Even if you just look over the API documentation that would be a huge help. If not, no biggie. I'll release tomorrow.

@brettz9
Copy link
Contributor

brettz9 commented Jan 6, 2016

Yeah, I looked over the docs, tests, and new code and it looks great from what I can see. (I also ran the tests which are working on my machine too.) Just don't forget the package.json and bower.json bumps before the tagged release...

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