Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions powershell/autorest-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ modelerfour:
emit-yaml-tags: false
lenient-model-deduplication: true
additional-checks: false
always-create-content-type-parameter: false
```

> if the modeler is loaded already, use that one, otherwise grab it.
Expand Down
16 changes: 9 additions & 7 deletions powershell/llcsharp/operation/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,15 @@ export class NewOperationMethod extends Method {
// add body paramter if there should be one.
if (this.operation.requests && this.operation.requests.length && this.operation.requests[0].parameters && this.operation.requests[0].parameters.length) {
// this request does have a request body.
const param = this.operation.requests[0].parameters[0];
this.bodyParameter = new NewOperationBodyParameter(this, 'body', param.language.default.description, param.schema, param.required ?? false, this.state, {
// TODO: temp solution. We need a class like NewKnowMediaType
mediaType: knownMediaType(KnownMediaType.Json),
contentType: KnownMediaType.Json
});
this.addParameter(this.bodyParameter);
const param = this.operation.requests[0].parameters.find((p) => !p.origin || p.origin.indexOf('modelerfour:synthesized') < 0);
if (param) {
this.bodyParameter = new NewOperationBodyParameter(this, 'body', param.language.default.description, param.schema, param.required ?? false, this.state, {
// TODO: temp solution. We need a class like NewKnowMediaType
mediaType: knownMediaType(KnownMediaType.Json),
contentType: KnownMediaType.Json
});
this.addParameter(this.bodyParameter);
}
}

for (const response of [...values(this.operation.responses), ...values(this.operation.exceptions)]) {
Expand Down
2 changes: 1 addition & 1 deletion powershell/plugins/create-commands-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export /* @internal */ class Inferrer {

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