Skip to content

Commit 59f30f5

Browse files
author
Uros Kukic
committed
docs(openapi) fix reusable custom decorator explanation
Ensure that when creating a reusable decorator `SwaggerModule` will create a definition for the used model by adding it as an extra model in the definition of the decorator.
1 parent d9170e2 commit 59f30f5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

content/openapi/operations.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ export const ApiPaginatedResponse = <TModel extends Type<any>>(
258258
model: TModel,
259259
) => {
260260
return applyDecorators(
261+
ApiExtraModels(model),
261262
ApiOkResponse({
262263
schema: {
263264
allOf: [
@@ -279,6 +280,8 @@ export const ApiPaginatedResponse = <TModel extends Type<any>>(
279280

280281
> info **Hint** `Type<any>` interface and `applyDecorators` function are imported from the `@nestjs/common` package.
281282
283+
To ensure that `SwaggerModule` will generate a definition for our model, we must add it as an extra model, like we did earlier with the `PaginatedDto` in the controller.
284+
282285
With this in place, we can use the custom `@ApiPaginatedResponse()` decorator on our endpoint:
283286

284287
```ts

0 commit comments

Comments
 (0)