Skip to content

Commit f23712b

Browse files
Chau TranChau Tran
authored andcommitted
docs(openapi): add docs about missing cli plugin options
1 parent 2524c46 commit f23712b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

content/openapi/cli-plugin.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,26 @@ You must duplicate both description and example values. With `introspectComments
8585
roles: RoleEnum[] = [];
8686
```
8787

88+
There are `dtoKeyOfComment` and `controllerKeyOfComment` plugin options that you can use to customize how the plugin will set the value for `ApiProperty` and `ApiOperation` decorators respectively. Take a look at the following example:
89+
90+
```typescript
91+
export class SomeController {
92+
/**
93+
* Create some resource
94+
*/
95+
@Post()
96+
create() {}
97+
}
98+
```
99+
100+
By default, these options are set to `"description"`. This means the plugin will assign `"Create some resource"` to `description` key on the `ApiOperation` operator. Like so:
101+
102+
```ts
103+
@ApiOperation({ description: "Create some resource" })
104+
```
105+
106+
> info **Hint** For models, the same logic applies but to `ApiProperty` decorator instead.
107+
88108
#### Using the CLI plugin
89109

90110
To enable the plugin, open `nest-cli.json` (if you use [Nest CLI](/cli/overview)) and add the following `plugins` configuration:
@@ -120,6 +140,8 @@ export interface PluginOptions {
120140
dtoFileNameSuffix?: string[];
121141
controllerFileNameSuffix?: string[];
122142
classValidatorShim?: boolean;
143+
dtoKeyOfComment?: string;
144+
controllerKeyOfComment?: string;
123145
introspectComments?: boolean;
124146
}
125147
```
@@ -145,6 +167,16 @@ export interface PluginOptions {
145167
<td><code>true</code></td>
146168
<td>If set to true, the module will reuse <code>class-validator</code> validation decorators (e.g. <code>@Max(10)</code> will add <code>max: 10</code> to schema definition) </td>
147169
</tr>
170+
<tr>
171+
<td><code>dtoKeyOfComment</code></td>
172+
<td><code>'description'</code></td>
173+
<td>The property key to set the comment text to on <code>ApiOperation</code>. Eg: <code>@ApiOperation({ description: 'comment' })</code></td>
174+
</tr>
175+
<tr>
176+
<td><code>controllerKeyOfComment</code></td>
177+
<td><code>'description'</code></td>
178+
<td>The property key to set the comment text to on <code>ApiOperation</code>. Eg: <code>@ApiOperation({ description: 'comment' })</code></td>
179+
</tr>
148180
<tr>
149181
<td><code>introspectComments</code></td>
150182
<td><code>false</code></td>

0 commit comments

Comments
 (0)