Skip to content

Commit 9403b4f

Browse files
shawncxmsxichen
andauthored
skip content type request parameter (#673)
Co-authored-by: xichen <[email protected]>
1 parent 56731da commit 9403b4f

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

powershell/autorest-configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ modelerfour:
1010
emit-yaml-tags: false
1111
lenient-model-deduplication: true
1212
additional-checks: false
13+
always-create-content-type-parameter: false
1314
```
1415
1516
> if the modeler is loaded already, use that one, otherwise grab it.

powershell/llcsharp/operation/method.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,15 @@ export class NewOperationMethod extends Method {
348348
// add body paramter if there should be one.
349349
if (this.operation.requests && this.operation.requests.length && this.operation.requests[0].parameters && this.operation.requests[0].parameters.length) {
350350
// this request does have a request body.
351-
const param = this.operation.requests[0].parameters[0];
352-
this.bodyParameter = new NewOperationBodyParameter(this, 'body', param.language.default.description, param.schema, param.required ?? false, this.state, {
353-
// TODO: temp solution. We need a class like NewKnowMediaType
354-
mediaType: knownMediaType(KnownMediaType.Json),
355-
contentType: KnownMediaType.Json
356-
});
357-
this.addParameter(this.bodyParameter);
351+
const param = this.operation.requests[0].parameters.find((p) => !p.origin || p.origin.indexOf('modelerfour:synthesized') < 0);
352+
if (param) {
353+
this.bodyParameter = new NewOperationBodyParameter(this, 'body', param.language.default.description, param.schema, param.required ?? false, this.state, {
354+
// TODO: temp solution. We need a class like NewKnowMediaType
355+
mediaType: knownMediaType(KnownMediaType.Json),
356+
contentType: KnownMediaType.Json
357+
});
358+
this.addParameter(this.bodyParameter);
359+
}
358360
}
359361

360362
for (const response of [...values(this.operation.responses), ...values(this.operation.exceptions)]) {

powershell/plugins/create-commands-v2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ export /* @internal */ class Inferrer {
408408

409409
// the body parameter
410410
// xichen: How to handle if has multiple requests?
411-
const body = (operation.requests && operation.requests[0].parameters) ? operation.requests[0].parameters[0] : null;
411+
const body = operation.requests?.[0].parameters?.find((p) => !p.origin || p.origin.indexOf('modelerfour:synthesized') < 0) || null;
412412
// skip-for-time-being, looks x-ms-requestBody-name is not supported any more
413413
//const bodyParameterName = (operation.requestBody && operation.requestBody.extensions) ? operation.requestBody.extensions['x-ms-requestBody-name'] || 'bodyParameter' : '';
414414
const bodyParameterName = body ? body.language.default.name : '';

0 commit comments

Comments
 (0)