@scalar/fastify-api-reference 1.25.116 → 1.25.119

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
@@ -18524,7 +18524,7 @@ function resolveUri(uri2, options, file, filesystem, resolve2, errors2) {
18524
18524
  code: "INVALID_REFERENCE",
18525
18525
  message: ERRORS.INVALID_REFERENCE.replace("%s", uri2)
18526
18526
  });
18527
- return;
18527
+ return void 0;
18528
18528
  }
18529
18529
  const [prefix, path2] = uri2.split("#", 2);
18530
18530
  const isDifferentFile = prefix !== file.filename;
@@ -18540,7 +18540,7 @@ function resolveUri(uri2, options, file, filesystem, resolve2, errors2) {
18540
18540
  code: "EXTERNAL_REFERENCE_NOT_FOUND",
18541
18541
  message: ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace("%s", prefix)
18542
18542
  });
18543
- return;
18543
+ return void 0;
18544
18544
  }
18545
18545
  if (path2 === void 0) {
18546
18546
  return externalReference.specification;
@@ -18561,6 +18561,7 @@ function resolveUri(uri2, options, file, filesystem, resolve2, errors2) {
18561
18561
  message: ERRORS.INVALID_REFERENCE.replace("%s", uri2)
18562
18562
  });
18563
18563
  }
18564
+ return void 0;
18564
18565
  }
18565
18566
  const eq = (x) => (y) => x === y;
18566
18567
  const not = (fn) => (x) => !fn(x);
@@ -19150,7 +19151,7 @@ function upgradeFromThreeToThreeOne(originalSpecification) {
19150
19151
  }
19151
19152
  specification = traverse(specification, (schema2) => {
19152
19153
  if (schema2.type !== "undefined" && schema2.nullable === true) {
19153
- schema2.type = ["null", schema2.type];
19154
+ schema2.type = [schema2.type, "null"];
19154
19155
  delete schema2.nullable;
19155
19156
  }
19156
19157
  return schema2;
@@ -19626,6 +19627,7 @@ const fetchUrls = (customConfiguration) => {
19626
19627
  return await response.text();
19627
19628
  } catch (error2) {
19628
19629
  console.error("[fetchUrls]", error2.message, `(${value})`);
19630
+ return void 0;
19629
19631
  }
19630
19632
  }
19631
19633
  };
@@ -19643,11 +19645,7 @@ function getJavaScriptFile() {
19643
19645
  path.resolve(`${dirname}/../../dist/js/standalone.js`)
19644
19646
  ].find((file) => fs.existsSync(file));
19645
19647
  if (filePath === void 0) {
19646
- throw new Error(
19647
- `JavaScript file not found: ${path.resolve(
19648
- `${dirname}/js/standalone.js`
19649
- )}`
19650
- );
19648
+ throw new Error(`JavaScript file not found: ${path.resolve(`${dirname}/js/standalone.js`)}`);
19651
19649
  }
19652
19650
  return fs.readFileSync(filePath, "utf8");
19653
19651
  }
@@ -19663,10 +19661,7 @@ const getOpenApiDocumentEndpoints = (openApiDocumentEndpoints) => {
19663
19661
  return { json, yaml };
19664
19662
  };
19665
19663
  const RELATIVE_JAVASCRIPT_PATH = "js/scalar.js";
19666
- const getJavaScriptUrl = (routePrefix) => `${getRoutePrefix(routePrefix)}/${RELATIVE_JAVASCRIPT_PATH}`.replace(
19667
- /\/\//g,
19668
- "/"
19669
- );
19664
+ const getJavaScriptUrl = (routePrefix) => `${getRoutePrefix(routePrefix)}/${RELATIVE_JAVASCRIPT_PATH}`.replace(/\/\//g, "/");
19670
19665
  const defaultCss = `
19671
19666
  .light-mode {
19672
19667
  color-scheme: light;
@@ -19793,9 +19788,8 @@ const fastifyApiReference = fp(
19793
19788
  if (fastify.hasPlugin("@fastify/swagger")) {
19794
19789
  return {
19795
19790
  type: "swagger",
19796
- get: () => {
19797
- return fastify.swagger();
19798
- }
19791
+ // @ts-ignore We know that @fastify/swagger is loaded.
19792
+ get: () => fastify.swagger()
19799
19793
  };
19800
19794
  }
19801
19795
  return void 0;
@@ -19809,12 +19803,9 @@ const fastifyApiReference = fp(
19809
19803
  const fileContent = getJavaScriptFile();
19810
19804
  const hooks = {};
19811
19805
  if (options.hooks) {
19812
- const additionalHooks = [
19813
- "onRequest",
19814
- "preHandler"
19815
- ];
19806
+ const additionalHooks = ["onRequest", "preHandler"];
19816
19807
  for (const hook of additionalHooks) {
19817
- hooks[hook] = options.hooks[hook];
19808
+ if (options.hooks[hook]) hooks[hook] = options.hooks[hook];
19818
19809
  }
19819
19810
  }
19820
19811
  const getLoadedSpecIfAvailable = () => {
@@ -19836,7 +19827,7 @@ const fastifyApiReference = fp(
19836
19827
  const spec = getLoadedSpecIfAvailable();
19837
19828
  const filename = await getSpecFilenameSlug(spec);
19838
19829
  const json = JSON.parse(await spec.toJson());
19839
- return reply.header("Content-Type", `application/json`).header("Content-Disposition", `filename=${filename}.json`).header("Access-Control-Allow-Origin", "*").header("Access-Control-Allow-Methods", "*").send(json);
19830
+ return reply.header("Content-Type", "application/json").header("Content-Disposition", `filename=${filename}.json`).header("Access-Control-Allow-Origin", "*").header("Access-Control-Allow-Methods", "*").send(json);
19840
19831
  }
19841
19832
  });
19842
19833
  const openApiSpecUrlYaml = `${getRoutePrefix(options.routePrefix)}${getOpenApiDocumentEndpoints(options.openApiDocumentEndpoints).yaml}`;
@@ -19850,7 +19841,7 @@ const fastifyApiReference = fp(
19850
19841
  const spec = getLoadedSpecIfAvailable();
19851
19842
  const filename = await getSpecFilenameSlug(spec);
19852
19843
  const yaml = await spec.toYaml();
19853
- return reply.header("Content-Type", `application/yaml`).header("Content-Disposition", `filename=${filename}.yaml`).header("Access-Control-Allow-Origin", "*").header("Access-Control-Allow-Methods", "*").send(yaml);
19844
+ return reply.header("Content-Type", "application/yaml").header("Content-Disposition", `filename=${filename}.yaml`).header("Access-Control-Allow-Origin", "*").header("Access-Control-Allow-Methods", "*").send(yaml);
19854
19845
  }
19855
19846
  });
19856
19847
  const doesNotIgnoreTrailingSlash = fastify.initialConfig.ignoreTrailingSlash !== true;