From d54763d8064e36bf5a2eb7415476efee64f09a98 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Wed, 8 Jan 2025 15:31:35 +0100 Subject: [PATCH] fix(types): fix plugin options (#851) --- README.md | 1 - index.d.ts | 7 +++++++ test/types/types.test.ts | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 35f6ee54..ecfb00dc 100644 --- a/README.md +++ b/README.md @@ -234,7 +234,6 @@ An example of using `@fastify/swagger` with `static` mode enabled can be found [ | ---------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- | | hiddenTag | X-HIDDEN | Tag to control hiding of routes. | | hideUntagged | false | If `true` remove routes without tags from resulting Swagger/OpenAPI schema file. | - | initOAuth | {} | Configuration options for [Swagger UI initOAuth](https://swagger.io/docs/open-source-tools/swagger-ui/usage/oauth2/). | | openapi | {} | [OpenAPI configuration](https://swagger.io/specification/#oasObject). | | stripBasePath | true | Strips base path from routes in docs. | | swagger | {} | [Swagger configuration](https://swagger.io/specification/v2/#swaggerObject). | diff --git a/index.d.ts b/index.d.ts index 3e7aefc6..6a7329d2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -112,6 +112,10 @@ declare namespace fastifySwagger { openapi?: Partial hiddenTag?: string; hideUntagged?: boolean; + + /** Include HEAD routes in the definitions */ + exposeHeadRoutes?: boolean; + /** * Strips matching base path from routes in documentation * @default true @@ -127,6 +131,9 @@ declare namespace fastifySwagger { */ transformObject?: SwaggerTransformObject; + /** Overrides the Fastify decorator. */ + decorator?: 'swagger' | (string & Record); + refResolver?: { /** Clone the input schema without changing it. Default to `false`. */ clone?: boolean; diff --git a/test/types/types.test.ts b/test/types/types.test.ts index 8adeb06c..0f970424 100644 --- a/test/types/types.test.ts +++ b/test/types/types.test.ts @@ -241,3 +241,19 @@ expectType(app.swagger({ yaml: true })) expectType(app.swagger({ yaml: Boolean(process.env.YAML) })) expectType<(arg: string)=>string>(formatParamUrl) + +app.register(fastifySwagger, { + decorator: 'swagger' +}) + +app.register(fastifySwagger, { + decorator: 'customSwagger' +}) + +app.register(fastifySwagger, { + exposeHeadRoutes: true +}) + +app.register(fastifySwagger, { + exposeHeadRoutes: false +})