Skip to content

Commit f523bd1

Browse files
Merge branch 'radacovsky-document-ApiSchema-decorator'
2 parents 291c813 + ca823e8 commit f523bd1

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

content/openapi/decorators.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
All of the available OpenAPI decorators have an `Api` prefix to distinguish them from the core decorators. Below is a full list of the exported decorators along with a designation of the level at which the decorator may be applied.
44

55
| | |
6-
| ------------------------- |---------------------|
6+
| ------------------------- | ------------------- |
77
| `@ApiBasicAuth()` | Method / Controller |
88
| `@ApiBearerAuth()` | Method / Controller |
99
| `@ApiBody()` | Method |
@@ -19,6 +19,7 @@ All of the available OpenAPI decorators have an `Api` prefix to distinguish them
1919
| `@ApiOperation()` | Method |
2020
| `@ApiParam()` | Method / Controller |
2121
| `@ApiProduces()` | Method / Controller |
22+
| `@ApiSchema()` | Model |
2223
| `@ApiProperty()` | Model |
2324
| `@ApiPropertyOptional()` | Model |
2425
| `@ApiQuery()` | Method / Controller |

content/openapi/types-and-parameters.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,16 @@ pets: Pet[];
324324
> info **Hint** The `getSchemaPath()` function is imported from `@nestjs/swagger`.
325325

326326
Both `Cat` and `Dog` must be defined as extra models using the `@ApiExtraModels()` decorator (at the class-level).
327+
328+
#### Schema name
329+
330+
As you may have noticed, the name of the generated schema is based on the name of the original model class (for example, the `CreateCatDto` model generates a `CreateCatDto` schema). If you'd like to change the schema name, you can use the `@ApiSchema()` decorator.
331+
332+
Here’s an example:
333+
334+
```typescript
335+
@ApiSchema({ name: 'CreateCatRequest' })
336+
class CreateCatDto {}
337+
```
338+
339+
The model above will be translated into the `CreateCatRequest` schema.

0 commit comments

Comments
 (0)