You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/openapi/cli-plugin.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,26 @@ You must duplicate both description and example values. With `introspectComments
85
85
roles: RoleEnum[] = [];
86
86
```
87
87
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
+
exportclassSomeController {
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
+
88
108
#### Using the CLI plugin
89
109
90
110
To enable the plugin, open `nest-cli.json` (if you use [Nest CLI](/cli/overview)) and add the following `plugins` configuration:
<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>
147
169
</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>ApiProperty</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>.</td>
<p>If you need to add some custom logic around the serialization of responses on the client side, you can use a custom class that extends the <code>ClientProxy</code> class or one of its child classes. For modifying successful requests you can override the <code>serializeResponse</code> method, and for modifying any errors that go through this client you can override the <code>serializeError</code> method. To make use of this custom class, you can pass the class itself to the <code>ClientsModule.register()</code> method using the <code>customClass</code> property. Below is an example of a custom <code>ClientProxy</code> that serializes each error into an <code>RpcException</code>.</p>
0 commit comments