@scalar/fastify-api-reference 0.6.37 → 0.6.39

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # @scalar/fastify-api-reference
2
2
 
3
+ ## 0.6.39
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [d5fccba9]
8
+ - @scalar/api-reference@0.8.3
9
+
10
+ ## 0.6.38
11
+
12
+ ### Patch Changes
13
+
14
+ - 4685f391: feat: use new universal configuration object
15
+ - 4685f391: feat: introducing the new universal configuration object
16
+ - Updated dependencies [3b042270]
17
+ - Updated dependencies [4685f391]
18
+ - Updated dependencies [8ac1ad69]
19
+ - Updated dependencies [28191084]
20
+ - Updated dependencies [e01134d4]
21
+ - @scalar/api-reference@0.8.2
22
+
3
23
  ## 0.6.37
4
24
 
5
25
  ### Patch Changes
package/README.md CHANGED
@@ -23,7 +23,9 @@ fastify.register(require('@scalar/fastify-api-reference'), {
23
23
  routePrefix: '/reference',
24
24
  apiReference: {
25
25
  title: 'Our API Reference',
26
- specUrl: '/swagger.json',
26
+ spec: {
27
+ url: '/swagger.json',
28
+ },
27
29
  },
28
30
  })
29
31
  ```
@@ -34,7 +36,9 @@ With the [@fastify/swagger](https://github.com/fastify/fastify-swagger) you can
34
36
  await fastify.register(require('@scalar/fastify-api-reference'), {
35
37
  routePrefix: '/reference',
36
38
  apiReference: {
37
- spec: () => fastify.swagger(),
39
+ spec: {
40
+ content: () => fastify.swagger(),
41
+ },
38
42
  },
39
43
  })
40
44
  ```
@@ -53,7 +57,11 @@ Or, if you just have a static OpenAPI spec, you can directly pass it, too:
53
57
  await fastify.register(require('@scalar/fastify-api-reference'), {
54
58
  routePrefix: '/reference',
55
59
  apiReference: {
56
- spec: { … },
60
+ spec: {
61
+ content: { … }
62
+ },
57
63
  },
58
64
  })
59
65
  ```
66
+
67
+ The fastify plugin takes our universal configuration object, [read more about configuration](https://github.com/scalar/scalar/tree/main/packages/api-reference#props) in the core package README.
@@ -1,3 +1,4 @@
1
+ import { type ReferenceConfiguration } from '@scalar/api-reference';
1
2
  import type { FastifyPluginAsync } from 'fastify';
2
3
  export type ApiReferenceOptions = {
3
4
  /**
@@ -6,10 +7,8 @@ export type ApiReferenceOptions = {
6
7
  * @default '/'
7
8
  */
8
9
  routePrefix: string;
9
- apiReference?: {
10
- specUrl?: string;
11
- spec?: Record<string, any> | (() => Record<string, any>);
12
- title?: string;
10
+ apiReference?: ReferenceConfiguration & {
11
+ pageTitle?: string;
13
12
  };
14
13
  };
15
14
  declare const _default: FastifyPluginAsync<ApiReferenceOptions>;
@@ -1 +1 @@
1
- {"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAKjD,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE;QACb,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;QACxD,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;CACF,CAAA;;AAkFD,wBAAsC"}
1
+ {"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAEnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAKjD,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,sBAAsB,GAAG;QACtC,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;CACF,CAAA;;AAkFD,wBAAsC"}
package/dist/index.cjs CHANGED
@@ -7,11 +7,11 @@ const schemaToHideRoute = {
7
7
  hide: true
8
8
  };
9
9
  const fastifyApiReference = async (fastify, options) => {
10
- var _a, _b;
10
+ var _a, _b, _c, _d;
11
11
  const hasSwaggerPlugin = fastify.hasPlugin("@fastify/swagger");
12
- if (!((_a = options.apiReference) == null ? void 0 : _a.spec) && !((_b = options.apiReference) == null ? void 0 : _b.specUrl) && !hasSwaggerPlugin) {
12
+ if (!((_b = (_a = options.apiReference) == null ? void 0 : _a.spec) == null ? void 0 : _b.content) && !((_d = (_c = options.apiReference) == null ? void 0 : _c.spec) == null ? void 0 : _d.url) && !hasSwaggerPlugin) {
13
13
  console.warn(
14
- "[@scalar/fastify-api-reference] You didn’t provide a spec or specUrl and @fastify/swagger could not be find either. Please provide one of these options."
14
+ "[@scalar/fastify-api-reference] You didn’t provide a spec.content or spec.url and @fastify/swagger could not be find either. Please provide one of these options."
15
15
  );
16
16
  return;
17
17
  }
@@ -22,16 +22,16 @@ const fastifyApiReference = async (fastify, options) => {
22
22
  // @ts-ignore
23
23
  schema: schemaToHideRoute,
24
24
  async handler(_, reply) {
25
- var _a2, _b2;
25
+ var _a2, _b2, _c2, _d2;
26
26
  reply.header("Content-Type", "text/html; charset=utf-8");
27
27
  let mergedOptions = options;
28
- if (!((_a2 = options.apiReference) == null ? void 0 : _a2.spec) && !((_b2 = options.apiReference) == null ? void 0 : _b2.specUrl) && hasSwaggerPlugin) {
28
+ if (!((_b2 = (_a2 = options.apiReference) == null ? void 0 : _a2.spec) == null ? void 0 : _b2.content) && !((_d2 = (_c2 = options.apiReference) == null ? void 0 : _c2.spec) == null ? void 0 : _d2.url) && hasSwaggerPlugin) {
29
29
  mergedOptions = {
30
30
  ...options,
31
31
  apiReference: {
32
32
  ...options.apiReference,
33
33
  // @ts-ignore
34
- spec: () => fastify.swagger()
34
+ spec: { content: () => fastify.swagger() }
35
35
  }
36
36
  };
37
37
  }
package/dist/index.js CHANGED
@@ -15,11 +15,11 @@ const schemaToHideRoute = {
15
15
  hide: true
16
16
  };
17
17
  const fastifyApiReference = async (fastify, options) => {
18
- var _a, _b;
18
+ var _a, _b, _c, _d;
19
19
  const hasSwaggerPlugin = fastify.hasPlugin("@fastify/swagger");
20
- if (!((_a = options.apiReference) == null ? void 0 : _a.spec) && !((_b = options.apiReference) == null ? void 0 : _b.specUrl) && !hasSwaggerPlugin) {
20
+ if (!((_b = (_a = options.apiReference) == null ? void 0 : _a.spec) == null ? void 0 : _b.content) && !((_d = (_c = options.apiReference) == null ? void 0 : _c.spec) == null ? void 0 : _d.url) && !hasSwaggerPlugin) {
21
21
  console.warn(
22
- "[@scalar/fastify-api-reference] You didn’t provide a spec or specUrl and @fastify/swagger could not be find either. Please provide one of these options."
22
+ "[@scalar/fastify-api-reference] You didn’t provide a spec.content or spec.url and @fastify/swagger could not be find either. Please provide one of these options."
23
23
  );
24
24
  return;
25
25
  }
@@ -30,16 +30,16 @@ const fastifyApiReference = async (fastify, options) => {
30
30
  // @ts-ignore
31
31
  schema: schemaToHideRoute,
32
32
  async handler(_, reply) {
33
- var _a2, _b2;
33
+ var _a2, _b2, _c2, _d2;
34
34
  reply.header("Content-Type", "text/html; charset=utf-8");
35
35
  let mergedOptions = options;
36
- if (!((_a2 = options.apiReference) == null ? void 0 : _a2.spec) && !((_b2 = options.apiReference) == null ? void 0 : _b2.specUrl) && hasSwaggerPlugin) {
36
+ if (!((_b2 = (_a2 = options.apiReference) == null ? void 0 : _a2.spec) == null ? void 0 : _b2.content) && !((_d2 = (_c2 = options.apiReference) == null ? void 0 : _c2.spec) == null ? void 0 : _d2.url) && hasSwaggerPlugin) {
37
37
  mergedOptions = {
38
38
  ...options,
39
39
  apiReference: {
40
40
  ...options.apiReference,
41
41
  // @ts-ignore
42
- spec: () => fastify.swagger()
42
+ spec: { content: () => fastify.swagger() }
43
43
  }
44
44
  };
45
45
  }