-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(http): use smarter bundling #15
base: main
Are you sure you want to change the base?
Conversation
489c973
to
706bf40
Compare
706bf40
to
ff615cd
Compare
ff615cd
to
19f9188
Compare
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 man had a question but think I figured things out as I went along, slack me if I'm waaay off though 🤣 🚀
const $ref = schema.$ref; | ||
schema.$ref = rewriteRef($ref); | ||
if (schema.$ref === $ref) return; | ||
if (processedRefs.has($ref)) return; |
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.
Jakub - is this where you're short-circuiting so we don't try to rebundle already bundled refs? I guess I'm trying to work out why you need both 138 and 139 🤔
function rewriteRef(value: string) { | ||
return `#/${ROOT_KEY}${value.slice(1).replace(`/${ROOT_KEY}/`, '/')}`; | ||
} |
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.
I am positive this works and makes sense man but I'm struggling a bit - prolly just too early for me - why are you doing this rewriteRef, what's the overall interplay between traversed, seen, and processedRefs collection?
Ahhh maybe... yeah ok I think I'm seeing it - the rewrite points the ref from some external reference to the new, bundled reference. Which you only need to add to the document once, the first time you rewrite a ref to it... but you still need to rewrite each existing ref to point to the now bundled schema - yeah ok, think I've got it sussed a bit, let me know if I'm way off lol
Summary
This pull request includes several changes to the
packages/http
module to support more performant bundling.It exploits the today's behavior of http-spec, and the tooling used today, and is strictly tailored to them.
Some changes were needed to generators in
packages/http/src/mocker/generator/JSONSchema.ts
to properly persist the non-enumerable property.Checklist