Skip to content

Commit d6c09cb

Browse files
Merge pull request #2014 from nartc/add-swagger-plugin-options
docs(openapi): add docs about missing cli plugin options
2 parents 2524c46 + 96b635a commit d6c09cb

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
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>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>
179+
</tr>
148180
<tr>
149181
<td><code>introspectComments</code></td>
150182
<td><code>false</code></td>

src/app/homepage/pages/microservices/custom-transport/custom-transport.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ <h4 appAnchor id="message-serialization"><span>Message serialization</span></h4>
197197
<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>
198198

199199
<span class="filename">
200-
{{ 'error-handling.proxy' | extension: appb95b5d8490d1d2e5a8dfa4408547e4314e16a15a.isJsActive }}
201-
<app-tabs #appb95b5d8490d1d2e5a8dfa4408547e4314e16a15a></app-tabs>
200+
{{ 'error-handling.proxy' | extension: app0de82fc4a8bf2d269aeca1e7e184438efcf3e0d8.isJsActive }}
201+
<app-tabs #app0de82fc4a8bf2d269aeca1e7e184438efcf3e0d8></app-tabs>
202202
</span><pre><code class="language-typescript">
203203
import &#123; ClientTcp, RpcException &#125; from &#39;@nestjs/microservices&#39;;
204204

@@ -210,8 +210,8 @@ <h4 appAnchor id="message-serialization"><span>Message serialization</span></h4>
210210
</code></pre><p>and then use it in the <code>ClientsModule</code> like so:</p>
211211

212212
<span class="filename">
213-
{{ 'app.module' | extension: appc6380cff174d3675b3c6660600efaf7aec5d9272.isJsActive }}
214-
<app-tabs #appc6380cff174d3675b3c6660600efaf7aec5d9272></app-tabs>
213+
{{ 'app.module' | extension: app2750dd81614c4ebfea443f3fdb1c35cf2c1bdc85.isJsActive }}
214+
<app-tabs #app2750dd81614c4ebfea443f3fdb1c35cf2c1bdc85></app-tabs>
215215
</span><pre><code class="language-typescript">
216216
@Module(&#123;
217217
imports: [

0 commit comments

Comments
 (0)