-
Notifications
You must be signed in to change notification settings - Fork 7
Custom bundling #4
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Quite a handful of code, but not more than there needs to be.
| if (!entry.inlineable && customRoots[entry.file] && customRoots[entry.file][entry.hash]) { | ||
| if (entry.hash === "#") { | ||
| set(schema, customRoots[entry.file]["#"], $Ref.dereference(entry.$ref, entry.value)); | ||
| entry.$ref.$ref = customRoots[entry.file]["#"]; | ||
| } | ||
| else { | ||
| let subschema = get(schema, customRoots[entry.file]["#"]); | ||
| let parsedHash = safePointerToPath(entry.hash); | ||
| let value = get(subschema, `#/${parsedHash.length === 1 ? parsedHash[0] : parsedHash.slice(0, parsedHash.length - 1).join("/")}`); | ||
| set(schema, customRoots[entry.file][entry.hash], parsedHash.length === 1 ? value : value[parsedHash[parsedHash.length - 1]]); | ||
| delete value[parsedHash[parsedHash.length - 1]]; | ||
| } | ||
|
|
||
| pathFromRoot = entry.pathFromRoot; | ||
| hash = customRoots[entry.file][entry.hash]; | ||
| entry.$ref.$ref = entry.pathFromRoot; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment (or more) here? I can't figure out what it's doing. Is this where it's rewriting the pointers to point at the bundled schemas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll leave a comment explaining what's happening here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wmhilton added! LMK what you think.
Co-authored-by: William Hilton <wmhilton@gmail.com>
Co-authored-by: William Hilton <wmhilton@gmail.com>
|
@marbemac ping, I want to have this in assuming the output meets the expectations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 let's get this into v1 and v2 - hopefully just works all around 🤞 . Likely to be some small things to tweak/fix that come out of it, but once that's done we can close this saga out! Nice work.
https://github.com/stoplightio/platform-internal/issues/4468
TODO:
Can be tried in the repo I sent on Slack.