diff --git a/src/plugins/azgenerator/CodeModelAzImpl.ts b/src/plugins/azgenerator/CodeModelAzImpl.ts index 57c2ada0e..cbb4c4bb5 100644 --- a/src/plugins/azgenerator/CodeModelAzImpl.ts +++ b/src/plugins/azgenerator/CodeModelAzImpl.ts @@ -34,6 +34,7 @@ export class CodeModelCliImpl implements CodeModelAz { suboptions: Property[]; subOperationGroups: Operation[]; submethodparameters: Parameter[]; + substack: Array<[Parameter[], number]>; currentSubOptionIndex: number; paramActionNameReference: Map; private _testScenario: any[]; @@ -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(); @@ -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; } } @@ -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; @@ -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; } } diff --git a/src/plugins/azgenerator/TemplateAzureCliActions.ts b/src/plugins/azgenerator/TemplateAzureCliActions.ts index 88c16aa52..e8afd0dda 100644 --- a/src/plugins/azgenerator/TemplateAzureCliActions.ts +++ b/src/plugins/azgenerator/TemplateAzureCliActions.ts @@ -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:"); @@ -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"); } diff --git a/src/plugins/azgenerator/TemplateAzureCliHelp.ts b/src/plugins/azgenerator/TemplateAzureCliHelp.ts index 9e34666d0..eff1a82dd 100644 --- a/src/plugins/azgenerator/TemplateAzureCliHelp.ts +++ b/src/plugins/azgenerator/TemplateAzureCliHelp.ts @@ -230,8 +230,9 @@ function GetActionOptions( model: CodeModelAz, param: Parameter, keyToMatch: str } } while (model.SelectNextMethodParameter()); } + model.ExitSubMethodParameters(); } - model.ExitSubMethodParameters(); + return options; } diff --git a/src/plugins/azgenerator/TemplateAzureCliParams.ts b/src/plugins/azgenerator/TemplateAzureCliParams.ts index 7c0029b2f..6b4d5d83d 100644 --- a/src/plugins/azgenerator/TemplateAzureCliParams.ts +++ b/src/plugins/azgenerator/TemplateAzureCliParams.ts @@ -379,7 +379,8 @@ function GetActionOptions(model: CodeModelAz, param: Parameter, keyToMatch: stri } } while (model.SelectNextMethodParameter()); } + model.ExitSubMethodParameters(); } - model.ExitSubMethodParameters(); + return options; } \ No newline at end of file