@scalar/fastify-api-reference 0.4.0 → 0.4.1

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/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Scalar Fastify API Reference Plugin
2
2
 
3
+ ![Version](https://img.shields.io/npm/v/%40scalar/fastify-api-reference)
4
+ ![Downloads](https://img.shields.io/npm/dm/%40scalar/fastify-api-reference)
5
+ ![License](https://img.shields.io/npm/l/%40scalar%2Ffastify-api-reference)
6
+ [![Discord](https://img.shields.io/discord/1135330207960678410?style=flat&color=5865F2)](https://discord.gg/mw6FQRPh)
7
+
3
8
  This plugin provides an easy way to render a beautiful API reference based on a OpenAPI/Swagger file with Fastify.
4
9
 
5
10
  ## Installation
@@ -4,9 +4,9 @@ type ApiReferenceOptions = {
4
4
  specUrl?: string;
5
5
  spec?: Record<string, any>;
6
6
  };
7
- export type FastifyApiReferenceOptions = {
7
+ export type FastifyApiReferenceOptions = FastifyPluginCallback<Partial<RegisterOptions> & {
8
8
  apiReference: ApiReferenceOptions;
9
- } & RegisterOptions;
10
- declare const fastifyApiReference: FastifyPluginCallback<FastifyApiReferenceOptions>;
9
+ }>;
10
+ declare const fastifyApiReference: FastifyApiReferenceOptions;
11
11
  export default fastifyApiReference;
12
12
  //# sourceMappingURL=fastifyApiReference.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAE1E,KAAK,mBAAmB,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,YAAY,EAAE,mBAAmB,CAAA;CAClC,GAAG,eAAe,CAAA;AA0BnB,QAAA,MAAM,mBAAmB,EAAE,qBAAqB,CAAC,0BAA0B,CAwB1E,CAAA;AAED,eAAe,mBAAmB,CAAA"}
1
+ {"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAE1E,KAAK,mBAAmB,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG,qBAAqB,CAC5D,OAAO,CAAC,eAAe,CAAC,GAAG;IACzB,YAAY,EAAE,mBAAmB,CAAA;CAClC,CACF,CAAA;AA0BD,QAAA,MAAM,mBAAmB,EAAE,0BAwB1B,CAAA;AAED,eAAe,mBAAmB,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,24 @@
1
1
  {
2
2
  "name": "@scalar/fastify-api-reference",
3
- "version": "0.4.0",
4
- "author": "Scalar",
3
+ "description": "a fastify plugin to render an API reference from an automatically generated OpenAPI spec",
4
+ "keywords": [
5
+ "fastify",
6
+ "openapi",
7
+ "swagger",
8
+ "api",
9
+ "documentation"
10
+ ],
11
+ "version": "0.4.1",
12
+ "author": "Scalar (https://github.com/scalar)",
13
+ "homepage": "https://github.com/scalar/scalar",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/scalar/scalar.git",
17
+ "directory": "packages/fastify-api-reference"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/scalar/scalar/issues/new"
21
+ },
5
22
  "license": "MIT",
6
23
  "engines": {
7
24
  "node": ">=18"
@@ -1,7 +1,7 @@
1
1
  import Fastify from 'fastify'
2
2
  import { describe, expect, it } from 'vitest'
3
3
 
4
- import fastifyApiReference from './fastifyApiReference'
4
+ import fastifyApiReference from './index'
5
5
 
6
6
  describe('fastifyApiReference', () => {
7
7
  it('returns 200 OK', () =>
@@ -6,9 +6,11 @@ type ApiReferenceOptions = {
6
6
  spec?: Record<string, any>
7
7
  }
8
8
 
9
- export type FastifyApiReferenceOptions = {
10
- apiReference: ApiReferenceOptions
11
- } & RegisterOptions
9
+ export type FastifyApiReferenceOptions = FastifyPluginCallback<
10
+ Partial<RegisterOptions> & {
11
+ apiReference: ApiReferenceOptions
12
+ }
13
+ >
12
14
 
13
15
  const getHtmlMarkup = (options: ApiReferenceOptions) => {
14
16
  const htmlTag = options.specUrl
@@ -34,7 +36,7 @@ const getHtmlMarkup = (options: ApiReferenceOptions) => {
34
36
  `
35
37
  }
36
38
 
37
- const fastifyApiReference: FastifyPluginCallback<FastifyApiReferenceOptions> = (
39
+ const fastifyApiReference: FastifyApiReferenceOptions = (
38
40
  fastify,
39
41
  options,
40
42
  done,