You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// We need to create a new object that will hold the $ref. We don't set a $ref yet because we don't want it to be remapped by remapRefs.
213
+
// the $ref will be set to "#" since we to point at the root of the bundled document
214
+
constfragment: {$ref?: string}={};
215
+
// we set the clone document in the bundled object so that we can later set the $ref in the bundled document
216
+
set(bundledObj,inventoryPath,clonedDocument);
217
+
// now, we replace the bundleRoot of the cloned document with a reference to the bundled document
218
+
// this is to avoid excessive data duplication - we can safely point at root here
219
+
// Example. Say, we had a document like this:
220
+
// {
221
+
// "openapi": "3.1.0"
222
+
// "components": {
223
+
// "schemas": {
224
+
// "User": {
225
+
// "$ref": "#",
226
+
// }
227
+
// }
228
+
// }
229
+
// what we replace in the cloned document is the "components" object (the path we provided to bundleTarget equals "#/components") with a reference to the bundled document
230
+
// so that the data we insert looks as follows
231
+
// {
232
+
// "openapi": "3.1.0"
233
+
// "components": { // fragment const from above
234
+
// "$ref": "#" // note the $ref is actually set at the very end of this function
235
+
// }
236
+
// }
237
+
set(clonedDocument,bundleRoot,fragment);
238
+
// we remap all the refs in the cloned document because we resected it and the $refs are now pointing to the wrong place
0 commit comments