From 4e953d74d4525b09dc4fbaac85949cf9965e2a62 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 6 Apr 2020 02:25:12 +0800 Subject: [PATCH] use allVars to cover all properties --- .../PowerShellExperimentalClientCodegen.java | 4 ++-- .../resources/powershell-experimental/model.mustache | 12 ++++++------ .../src/PSPetstore/Client/PSConfiguration.ps1 | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellExperimentalClientCodegen.java index e4aa8748c36d..8581afb94138 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellExperimentalClientCodegen.java @@ -818,7 +818,7 @@ public Map postProcessModels(Map objs) { Map mo = (Map) _mo; CodegenModel cm = (CodegenModel) mo.get("model"); - for (CodegenProperty cp : cm.vars) { + for (CodegenProperty cp : cm.allVars) { cp.vendorExtensions.put("x-powershell-data-type", getPSDataType(cp)); } } @@ -952,7 +952,7 @@ private String constructExampleCode(CodegenModel codegenModel, HashMap propertyExamples = new ArrayList<>(); - for (CodegenProperty codegenProperty : codegenModel.vars) { + for (CodegenProperty codegenProperty : codegenModel.allVars) { propertyExamples.add("-" + codegenProperty.name + " " + constructExampleCode(codegenProperty, modelMaps, processedModelMap)); } example += StringUtils.join(propertyExamples, " "); diff --git a/modules/openapi-generator/src/main/resources/powershell-experimental/model.mustache b/modules/openapi-generator/src/main/resources/powershell-experimental/model.mustache index 2c39a00660f5..c050cc30593c 100644 --- a/modules/openapi-generator/src/main/resources/powershell-experimental/model.mustache +++ b/modules/openapi-generator/src/main/resources/powershell-experimental/model.mustache @@ -10,11 +10,11 @@ {{#description}}{{{description}}}{{/description}}{{^description}}No description available.{{/description}} -{{#vars}} +{{#allVars}} .PARAMETER {{{name}}} {{#description}}{{{description}}}{{/description}}{{^description}}No description available.{{/description}} -{{/vars}} +{{/allVars}} .OUTPUTS {{{classname}}} @@ -23,13 +23,13 @@ function Initialize-{{{apiNamePrefix}}}{{{classname}}} { [CmdletBinding()] Param ( -{{#vars}} +{{#allVars}} [Parameter(Position = {{vendorExtensions.x-index}}, ValueFromPipelineByPropertyName = $true{{#required}}, Mandatory = $true{{/required}})] [{{vendorExtensions.x-powershell-data-type}}] {{=<% %>=}} ${<%name%>}<%^-last%>,<%/-last%> <%={{ }}=%> -{{/vars}} +{{/allVars}} ) Process { @@ -38,9 +38,9 @@ function Initialize-{{{apiNamePrefix}}}{{{classname}}} { $PSO = [PSCustomObject]@{ {{=<< >>=}} - <<#vars>> + <<#allVars>> "<>" = ${<>} - <> + <> <<={{ }}=>> } diff --git a/samples/client/petstore/powershell-experimental/src/PSPetstore/Client/PSConfiguration.ps1 b/samples/client/petstore/powershell-experimental/src/PSPetstore/Client/PSConfiguration.ps1 index ccd55c338c86..aaaed8bda676 100644 --- a/samples/client/petstore/powershell-experimental/src/PSPetstore/Client/PSConfiguration.ps1 +++ b/samples/client/petstore/powershell-experimental/src/PSPetstore/Client/PSConfiguration.ps1 @@ -291,7 +291,7 @@ Get the host setting in the form of array of hashtables. System.Collections.Hashtable[] #> function Get-PSHostSetting { - return @( + return ,@( @{ "Url" = "http://{server}.swagger.io:{port}/v2"; "Description" = "petstore server";