Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
fix-submethodparameters-multilayer (#386)
Browse files Browse the repository at this point in the history
* fix-submethodparameters-multilayer

* bugfix of hidden
  • Loading branch information
qiaozha authored May 27, 2020
1 parent a72d51c commit 2387952
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
23 changes: 20 additions & 3 deletions src/plugins/azgenerator/CodeModelAzImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class CodeModelCliImpl implements CodeModelAz {
suboptions: Property[];
subOperationGroups: Operation[];
submethodparameters: Parameter[];
substack: Array<[Parameter[], number]>;
currentSubOptionIndex: number;
paramActionNameReference: Map<Schema, string>;
private _testScenario: any[];
Expand All @@ -54,6 +55,7 @@ export class CodeModelCliImpl implements CodeModelAz {
this.suboptions = null;
this.currentSubOptionIndex = -1;
this.submethodparameters = null;
this.substack = new Array<[Parameter[], number]>();
this._clientBaseUrlBound = this.options['client-base-url-bound'];
this._clientSubscriptionBound = this.options['client-subscription-bound'];
//this.sortOperationByAzCommand();
Expand Down Expand Up @@ -864,7 +866,15 @@ export class CodeModelCliImpl implements CodeModelAz {
return false;
}
else {
if (isNullOrUndefined(this.substack)) {
this.substack = new Array<[Parameter[], number]>();
}
// reserve previous status
if (!isNullOrUndefined(this.submethodparameters)) {
this.substack.push([this.submethodparameters, this.currentSubOptionIndex]);
}
this.submethodparameters = subParams;
this.currentSubOptionIndex = 0;
return true;
}
}
Expand Down Expand Up @@ -913,8 +923,15 @@ export class CodeModelCliImpl implements CodeModelAz {

public ExitSubMethodParameters(): boolean {
if (this.submethodparameters != null) {
this.submethodparameters = null;
this.currentSubOptionIndex = -1;
if (this.substack.length > 0) {
let lastsub = this.substack.last;
this.submethodparameters = lastsub[0];
this.currentSubOptionIndex = lastsub[1];
this.substack.pop();
} else {
this.submethodparameters = null;
this.currentSubOptionIndex = -1;
}
return true;
}
return false;
Expand Down Expand Up @@ -1287,7 +1304,7 @@ export class CodeModelCliImpl implements CodeModelAz {
parameter.language['az'].hidden = true;
}
} else {
parameter.language['az'].hidden = this.MethodParameter['hidden'] ?? shouldHidden ?? false;
parameter.language['az'].hidden = parameter['hidden'] ?? shouldHidden ?? false;
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/plugins/azgenerator/TemplateAzureCliActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function GetAction(model: CodeModelAz, actionName: string, param: Parameter, key
}
} while (model.SelectNextMethodParameter(true));
}
model.ExitSubMethodParameters();
}

output.push(" for k in properties:");
Expand Down Expand Up @@ -135,8 +136,9 @@ function GetAction(model: CodeModelAz, actionName: string, param: Parameter, key
ifkv = "elif";
} while (model.SelectNextMethodParameter());
}
model.ExitSubMethodParameters();
}
model.ExitSubMethodParameters();

if (!foundProperties && preParamType == SchemaType.Dictionary) {
output.push(" d[k] = v");
}
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/azgenerator/TemplateAzureCliHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,9 @@ function GetActionOptions( model: CodeModelAz, param: Parameter, keyToMatch: str
}
} while (model.SelectNextMethodParameter());
}
model.ExitSubMethodParameters();
}
model.ExitSubMethodParameters();

return options;
}

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/azgenerator/TemplateAzureCliParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ function GetActionOptions(model: CodeModelAz, param: Parameter, keyToMatch: stri
}
} while (model.SelectNextMethodParameter());
}
model.ExitSubMethodParameters();
}
model.ExitSubMethodParameters();

return options;
}

0 comments on commit 2387952

Please sign in to comment.