Skip to content

Commit cdb9d46

Browse files
author
Stefan Radacovsky
committed
docs(@nestjs/swagger): describe ApiSchema decorator
1 parent d59e116 commit cdb9d46

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

content/openapi/decorators.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ All of the available OpenAPI decorators have an `Api` prefix to distinguish them
2222
| `@ApiProperty()` | Model |
2323
| `@ApiPropertyOptional()` | Model |
2424
| `@ApiHideProperty()` | Model |
25+
| `@ApiSchema()` | Model |
2526
| `@ApiExtension()` | Method |

content/openapi/types-and-parameters.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,15 @@ pets: Pet[];
288288
> info **Hint** The `getSchemaPath()` function is imported from `@nestjs/swagger`.
289289

290290
Both `Cat` and `Dog` must be defined as extra models using the `@ApiExtraModels()` decorator (at the class-level).
291+
292+
### Schema
293+
294+
As you might have noticed the name of the generated model schema matches the name of the model class e.g. `CreateCatDto` will generate `CreateCatDto` schema. If you want to change the generated schema name then use `@ApiSchema()` decorator.
295+
296+
For example:
297+
```typescript
298+
@ApiSchema({ name: 'CreateCatRequest' })
299+
class CreateCatDto {}
300+
```
301+
302+
The above model will translate into schema with name `CreateCatRequest`.

0 commit comments

Comments
 (0)