@scalar/fastify-api-reference 1.25.80 → 1.25.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -18466,50 +18466,44 @@ function resolveReferences(input, options, file, errors2) {
18466
18466
  const clonedInput = structuredClone(input);
18467
18467
  const filesystem = makeFilesystem(clonedInput);
18468
18468
  const entrypoint = getEntrypoint(filesystem);
18469
- resolve2((file == null ? void 0 : file.specification) ?? entrypoint.specification, filesystem, file ?? entrypoint, options == null ? void 0 : options.onDereference);
18470
- resolve2((file == null ? void 0 : file.specification) ?? entrypoint.specification, filesystem, file ?? entrypoint, options == null ? void 0 : options.onDereference);
18469
+ resolve2((file == null ? void 0 : file.specification) ?? entrypoint.specification, filesystem, file ?? entrypoint);
18471
18470
  errors2 = errors2.filter((error2, index, self) => index === self.findIndex((t) => t.message === error2.message && t.code === error2.code));
18472
18471
  return {
18473
18472
  valid: errors2.length === 0,
18474
18473
  errors: errors2,
18475
18474
  schema: (file ?? getEntrypoint(filesystem)).specification
18476
18475
  };
18477
- function resolve2(schema2, resolveFilesystem, resolveFile, onResolve) {
18478
- let result;
18479
- Object.entries(schema2 ?? {}).forEach(([_, value]) => {
18480
- if (schema2.$ref !== void 0) {
18481
- const target = resolveUri(schema2.$ref, options, resolveFile, resolveFilesystem, errors2);
18482
- if (target === void 0) {
18483
- return void 0;
18484
- }
18485
- onResolve == null ? void 0 : onResolve({ schema: schema2, ref: schema2.$ref });
18486
- delete schema2.$ref;
18487
- if (typeof target === "object") {
18488
- Object.keys(target).forEach((key) => {
18489
- if (schema2[key] === void 0) {
18490
- schema2[key] = target[key];
18491
- }
18492
- });
18476
+ function resolve2(schema2, resolveFilesystem, resolveFile, resolved = /* @__PURE__ */ new WeakSet()) {
18477
+ var _a;
18478
+ let result = { errors: [] };
18479
+ if (schema2 === null || resolved.has(schema2))
18480
+ return result;
18481
+ resolved.add(schema2);
18482
+ function resolveExternal(externalFile) {
18483
+ resolve2(externalFile.specification, resolveFilesystem, externalFile, resolved);
18484
+ return externalFile;
18485
+ }
18486
+ while (schema2.$ref !== void 0) {
18487
+ const target = resolveUri(schema2.$ref, options, resolveFile, resolveFilesystem, resolveExternal, errors2);
18488
+ if (typeof target !== "object" || target === null)
18489
+ break;
18490
+ (_a = options == null ? void 0 : options.onDereference) == null ? void 0 : _a.call(options, { schema: schema2, ref: schema2.$ref });
18491
+ delete schema2.$ref;
18492
+ for (const key of Object.keys(target)) {
18493
+ if (schema2[key] === void 0) {
18494
+ schema2[key] = target[key];
18493
18495
  }
18494
18496
  }
18495
- if (typeof value === "object" && !isCircular(value)) {
18496
- result = resolve2(value, resolveFilesystem, resolveFile, onResolve);
18497
+ }
18498
+ for (const value of Object.values(schema2)) {
18499
+ if (typeof value === "object" && value !== null) {
18500
+ result = resolve2(value, resolveFilesystem, resolveFile, resolved);
18497
18501
  }
18498
- });
18499
- return {
18500
- errors: (result == null ? void 0 : result.errors) ?? []
18501
- };
18502
- }
18503
- }
18504
- function isCircular(schema2) {
18505
- try {
18506
- JSON.stringify(schema2);
18507
- return false;
18508
- } catch (error2) {
18509
- return true;
18502
+ }
18503
+ return result;
18510
18504
  }
18511
18505
  }
18512
- function resolveUri(uri2, options, file, filesystem, errors2) {
18506
+ function resolveUri(uri2, options, file, filesystem, resolve2, errors2) {
18513
18507
  if (typeof uri2 !== "string") {
18514
18508
  if (options == null ? void 0 : options.throwOnError) {
18515
18509
  throw new Error(ERRORS.INVALID_REFERENCE.replace("%s", uri2));
@@ -18536,11 +18530,10 @@ function resolveUri(uri2, options, file, filesystem, errors2) {
18536
18530
  });
18537
18531
  return;
18538
18532
  }
18539
- const result = resolveReferences(filesystem, options, externalReference, errors2);
18540
18533
  if (path2 === void 0) {
18541
- return result.schema;
18534
+ return externalReference.specification;
18542
18535
  }
18543
- return resolveUri(`#${path2}`, options, externalReference, filesystem, errors2);
18536
+ return resolveUri(`#${path2}`, options, resolve2(externalReference), filesystem, resolve2, errors2);
18544
18537
  }
18545
18538
  const segments = getSegmentsFromPath(path2);
18546
18539
  try {