@scalar/fastify-api-reference 1.29.3 → 1.31.0
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 +21 -0
- package/dist/fastifyApiReference.d.ts.map +1 -1
- package/dist/fastifyApiReference.js +6 -11
- package/dist/js/standalone.js +6525 -6416
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @scalar/fastify-api-reference
|
|
2
2
|
|
|
3
|
+
## 1.31.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [1e87feb]
|
|
8
|
+
- @scalar/openapi-parser@0.13.0
|
|
9
|
+
- @scalar/core@0.3.1
|
|
10
|
+
- @scalar/openapi-types@0.3.1
|
|
11
|
+
- @scalar/types@0.2.1
|
|
12
|
+
|
|
13
|
+
## 1.30.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- edf694b: refactor!: use openapi-parser utils, remove the deprecated pipeline syntax
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [edf694b]
|
|
22
|
+
- @scalar/openapi-parser@0.12.0
|
|
23
|
+
|
|
3
24
|
## 1.29.3
|
|
4
25
|
|
|
5
26
|
## 1.29.2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI9F,OAAO,KAAK,EAAmC,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAyC1F;;GAEG;AACH,eAAO,MAAM,WAAW,s4EAwEvB,CAAA;AASD,QAAA,MAAM,mBAAmB,sIAoMxB,CAAA;AAED,eAAe,mBAAmB,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { openapi } from '@scalar/openapi-parser';
|
|
2
|
-
import { fetchUrls } from '@scalar/openapi-parser/plugins/fetch-urls';
|
|
3
1
|
import fp from 'fastify-plugin';
|
|
4
2
|
import { slug } from 'github-slugger';
|
|
5
3
|
import { getJavaScriptFile } from './utils/getJavaScriptFile.js';
|
|
4
|
+
import { normalize, toJson, toYaml } from '@scalar/openapi-parser';
|
|
6
5
|
import { getHtmlDocument } from './packages/core/dist/libs/html-rendering/html-rendering.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -163,11 +162,7 @@ const fastifyApiReference = fp(async (fastify, options) => {
|
|
|
163
162
|
}
|
|
164
163
|
}
|
|
165
164
|
}
|
|
166
|
-
const
|
|
167
|
-
return openapi().load(specSource.get(), { plugins: [fetchUrls()] });
|
|
168
|
-
};
|
|
169
|
-
const getSpecFilenameSlug = async (loadedSpec) => {
|
|
170
|
-
const spec = await loadedSpec?.get();
|
|
165
|
+
const getSpecFilenameSlug = async (spec) => {
|
|
171
166
|
// Same GitHub Slugger and default file name as in `@scalar/api-reference`, when generating the download
|
|
172
167
|
return slug(spec?.specification?.info?.title ?? 'spec');
|
|
173
168
|
};
|
|
@@ -180,9 +175,9 @@ const fastifyApiReference = fp(async (fastify, options) => {
|
|
|
180
175
|
...hooks,
|
|
181
176
|
...(options.logLevel && { logLevel: options.logLevel }),
|
|
182
177
|
async handler(_, reply) {
|
|
183
|
-
const spec =
|
|
178
|
+
const spec = normalize(specSource.get());
|
|
184
179
|
const filename = await getSpecFilenameSlug(spec);
|
|
185
|
-
const json = JSON.parse(
|
|
180
|
+
const json = JSON.parse(toJson(spec)); // parsing minifies the JSON
|
|
186
181
|
return reply
|
|
187
182
|
.header('Content-Type', 'application/json')
|
|
188
183
|
.header('Content-Disposition', `filename=${filename}.json`)
|
|
@@ -200,9 +195,9 @@ const fastifyApiReference = fp(async (fastify, options) => {
|
|
|
200
195
|
...hooks,
|
|
201
196
|
...(options.logLevel && { logLevel: options.logLevel }),
|
|
202
197
|
async handler(_, reply) {
|
|
203
|
-
const spec =
|
|
198
|
+
const spec = normalize(specSource.get());
|
|
204
199
|
const filename = await getSpecFilenameSlug(spec);
|
|
205
|
-
const yaml =
|
|
200
|
+
const yaml = toYaml(spec);
|
|
206
201
|
return reply
|
|
207
202
|
.header('Content-Type', 'application/yaml')
|
|
208
203
|
.header('Content-Disposition', `filename=${filename}.yaml`)
|