Skip to content

Commit 38bca50

Browse files
Merge pull request #3157 from ccaspers/document-description-in-api-schema
docs(@nestjs/swagger): document description support in @ApiSchema
2 parents f864332 + 151fdd6 commit 38bca50

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

content/openapi/types-and-parameters.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ pets: Pet[];
345345

346346
Both `Cat` and `Dog` must be defined as extra models using the `@ApiExtraModels()` decorator (at the class-level).
347347

348-
#### Schema name
348+
#### Schema name and description
349349

350350
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.
351351

@@ -357,3 +357,19 @@ class CreateCatDto {}
357357
```
358358

359359
The model above will be translated into the `CreateCatRequest` schema.
360+
361+
By default, no description is added to the generated schema. You can add one using the `description` attribute:
362+
363+
```typescript
364+
@ApiSchema({ description: 'Description of the CreateCatDto schema' })
365+
class CreateCatDto {}
366+
```
367+
368+
That way, the description will be included in the schema, as follows:
369+
370+
```yaml
371+
schemas:
372+
CreateCatDto:
373+
type: object
374+
description: Description of the CreateCatDto schema
375+
```

0 commit comments

Comments
 (0)