@scalar/fastify-api-reference 1.25.118 → 1.25.120
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/CHANGELOG.md +15 -0
- package/README.md +13 -2
- package/dist/fastifyApiReference.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +10 -15
- package/dist/js/standalone.js +1852 -1854
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/getJavaScriptFile.d.ts.map +1 -1
- package/package.json +7 -5
package/dist/index.js
CHANGED
|
@@ -19645,11 +19645,7 @@ function getJavaScriptFile() {
|
|
|
19645
19645
|
path.resolve(`${dirname}/../../dist/js/standalone.js`)
|
|
19646
19646
|
].find((file) => fs.existsSync(file));
|
|
19647
19647
|
if (filePath === void 0) {
|
|
19648
|
-
throw new Error(
|
|
19649
|
-
`JavaScript file not found: ${path.resolve(
|
|
19650
|
-
`${dirname}/js/standalone.js`
|
|
19651
|
-
)}`
|
|
19652
|
-
);
|
|
19648
|
+
throw new Error(`JavaScript file not found: ${path.resolve(`${dirname}/js/standalone.js`)}`);
|
|
19653
19649
|
}
|
|
19654
19650
|
return fs.readFileSync(filePath, "utf8");
|
|
19655
19651
|
}
|
|
@@ -19665,10 +19661,7 @@ const getOpenApiDocumentEndpoints = (openApiDocumentEndpoints) => {
|
|
|
19665
19661
|
return { json, yaml };
|
|
19666
19662
|
};
|
|
19667
19663
|
const RELATIVE_JAVASCRIPT_PATH = "js/scalar.js";
|
|
19668
|
-
const getJavaScriptUrl = (routePrefix) => `${getRoutePrefix(routePrefix)}/${RELATIVE_JAVASCRIPT_PATH}`.replace(
|
|
19669
|
-
/\/\//g,
|
|
19670
|
-
"/"
|
|
19671
|
-
);
|
|
19664
|
+
const getJavaScriptUrl = (routePrefix) => `${getRoutePrefix(routePrefix)}/${RELATIVE_JAVASCRIPT_PATH}`.replace(/\/\//g, "/");
|
|
19672
19665
|
const defaultCss = `
|
|
19673
19666
|
.light-mode {
|
|
19674
19667
|
color-scheme: light;
|
|
@@ -19810,10 +19803,7 @@ const fastifyApiReference = fp(
|
|
|
19810
19803
|
const fileContent = getJavaScriptFile();
|
|
19811
19804
|
const hooks = {};
|
|
19812
19805
|
if (options.hooks) {
|
|
19813
|
-
const additionalHooks = [
|
|
19814
|
-
"onRequest",
|
|
19815
|
-
"preHandler"
|
|
19816
|
-
];
|
|
19806
|
+
const additionalHooks = ["onRequest", "preHandler"];
|
|
19817
19807
|
for (const hook of additionalHooks) {
|
|
19818
19808
|
if (options.hooks[hook]) hooks[hook] = options.hooks[hook];
|
|
19819
19809
|
}
|
|
@@ -19833,11 +19823,12 @@ const fastifyApiReference = fp(
|
|
|
19833
19823
|
// @ts-ignore We don’t know whether @fastify/swagger is loaded.
|
|
19834
19824
|
schema: schemaToHideRoute,
|
|
19835
19825
|
...hooks,
|
|
19826
|
+
...options.logLevel && { logLevel: options.logLevel },
|
|
19836
19827
|
async handler(_, reply) {
|
|
19837
19828
|
const spec = getLoadedSpecIfAvailable();
|
|
19838
19829
|
const filename = await getSpecFilenameSlug(spec);
|
|
19839
19830
|
const json = JSON.parse(await spec.toJson());
|
|
19840
|
-
return reply.header("Content-Type",
|
|
19831
|
+
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);
|
|
19841
19832
|
}
|
|
19842
19833
|
});
|
|
19843
19834
|
const openApiSpecUrlYaml = `${getRoutePrefix(options.routePrefix)}${getOpenApiDocumentEndpoints(options.openApiDocumentEndpoints).yaml}`;
|
|
@@ -19847,11 +19838,12 @@ const fastifyApiReference = fp(
|
|
|
19847
19838
|
// @ts-ignore We don’t know whether @fastify/swagger is loaded.
|
|
19848
19839
|
schema: schemaToHideRoute,
|
|
19849
19840
|
...hooks,
|
|
19841
|
+
...options.logLevel && { logLevel: options.logLevel },
|
|
19850
19842
|
async handler(_, reply) {
|
|
19851
19843
|
const spec = getLoadedSpecIfAvailable();
|
|
19852
19844
|
const filename = await getSpecFilenameSlug(spec);
|
|
19853
19845
|
const yaml = await spec.toYaml();
|
|
19854
|
-
return reply.header("Content-Type",
|
|
19846
|
+
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);
|
|
19855
19847
|
}
|
|
19856
19848
|
});
|
|
19857
19849
|
const doesNotIgnoreTrailingSlash = fastify.initialConfig.ignoreTrailingSlash !== true;
|
|
@@ -19862,6 +19854,7 @@ const fastifyApiReference = fp(
|
|
|
19862
19854
|
// @ts-ignore We don't know whether @fastify/swagger is loaded.
|
|
19863
19855
|
schema: schemaToHideRoute,
|
|
19864
19856
|
...hooks,
|
|
19857
|
+
...options.logLevel && { logLevel: options.logLevel },
|
|
19865
19858
|
handler(_, reply) {
|
|
19866
19859
|
return reply.redirect(getRoutePrefix(options.routePrefix) + "/", 302);
|
|
19867
19860
|
}
|
|
@@ -19874,6 +19867,7 @@ const fastifyApiReference = fp(
|
|
|
19874
19867
|
// @ts-ignore We don’t know whether @fastify/swagger is loaded.
|
|
19875
19868
|
schema: schemaToHideRoute,
|
|
19876
19869
|
...hooks,
|
|
19870
|
+
...options.logLevel && { logLevel: options.logLevel },
|
|
19877
19871
|
handler(_, reply) {
|
|
19878
19872
|
const currentUrl = new URL(_.url, `${_.protocol}://${_.hostname}`);
|
|
19879
19873
|
if (!currentUrl.pathname.endsWith("/")) {
|
|
@@ -19906,6 +19900,7 @@ const fastifyApiReference = fp(
|
|
|
19906
19900
|
// @ts-ignore We don’t know whether @fastify/swagger is loaded.
|
|
19907
19901
|
schema: schemaToHideRoute,
|
|
19908
19902
|
...hooks,
|
|
19903
|
+
...options.logLevel && { logLevel: options.logLevel },
|
|
19909
19904
|
handler(_, reply) {
|
|
19910
19905
|
return reply.header("Content-Type", "application/javascript; charset=utf-8").send(fileContent);
|
|
19911
19906
|
}
|