Skip to content

Conversation

@P0lip
Copy link

@P0lip P0lip commented Nov 10, 2020

https://github.com/stoplightio/platform-internal/issues/4468

TODO:

  • docs 😆
  • better typings + jsdoc

Can be tried in the repo I sent on Slack.

@P0lip P0lip requested review from a team and marbemac November 10, 2020 23:21
@P0lip P0lip self-assigned this Nov 10, 2020
Copy link

@billiegoose billiegoose left a 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.

Comment on lines 259 to 275
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;
}

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?

Copy link
Author

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.

Copy link
Author

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.

@P0lip P0lip added the enhancement New feature or request label Nov 16, 2020
@P0lip
Copy link
Author

P0lip commented Nov 16, 2020

@marbemac ping, I want to have this in assuming the output meets the expectations.

@P0lip P0lip marked this pull request as ready for review November 16, 2020 13:06
Copy link

@marbemac marbemac left a 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.

@P0lip P0lip merged commit df72735 into master Nov 18, 2020
@P0lip P0lip deleted the custom-bundling branch November 18, 2020 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants