Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(oas/swagger): provide examples of the example and examples keys #3026

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions content/openapi/types-and-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,31 @@ CatBreed:

> info **Hint** Any **decorator** that takes `enum` as a property will also take `enumName`.

#### Examples Of Properties

You can set a single example for a property by utilizing the `example` key like this:

```typescript
@ApiProperty({
example: 'persian',
})
breed: string;
```

If you want to give multiple examples, you can utilize the `examples` key by passing in an object structured like this:

```typescript
@ApiProperty({
examples: {
Persian: { value: 'persian' },
Tabby: { value: 'tabby' },
Siamese: { value: 'siamese' },
'Scottish Fold': { value: 'scottish_fold' },
},
})
breed: string;
```

#### Raw definitions

In some specific scenarios (e.g., deeply nested arrays, matrices), you may want to describe your type by hand.
Expand Down