Skip to content

Commit

Permalink
fix(types): fix plugin options (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored Jan 8, 2025
1 parent 79384b1 commit d54763d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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). |
Expand Down
7 changes: 7 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ declare namespace fastifySwagger {
openapi?: Partial<OpenAPIV3.Document | OpenAPIV3_1.Document>
hiddenTag?: string;
hideUntagged?: boolean;

/** Include HEAD routes in the definitions */
exposeHeadRoutes?: boolean;

/**
* Strips matching base path from routes in documentation
* @default true
Expand All @@ -127,6 +131,9 @@ declare namespace fastifySwagger {
*/
transformObject?: SwaggerTransformObject;

/** Overrides the Fastify decorator. */
decorator?: 'swagger' | (string & Record<never, never>);

refResolver?: {
/** Clone the input schema without changing it. Default to `false`. */
clone?: boolean;
Expand Down
16 changes: 16 additions & 0 deletions test/types/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,19 @@ expectType<string>(app.swagger({ yaml: true }))
expectType<OpenAPI.Document | string>(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
})

0 comments on commit d54763d

Please sign in to comment.