From 9501ce3f367eb311fb10990a669b43980df34f17 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 2 Jul 2020 16:25:32 +0800 Subject: [PATCH 1/3] more fields to be customized --- .../codegen/languages/PowerShellClientCodegen.java | 8 ++++++++ .../main/resources/powershell/Build.ps1.mustache | 14 +++++++++++--- .../src/main/resources/powershell/README.mustache | 2 +- samples/client/petstore/powershell/Build.ps1 | 2 +- samples/client/petstore/powershell/README.md | 2 +- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java index 2b3e4922838b..99b349860d85 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java @@ -501,6 +501,14 @@ public PowerShellClientCodegen() { cliOptions.add(new CliOption("commonVerbs", "PS common verb mappings. e.g. Delete=Remove:Patch=Update to map Delete with Remove and Patch with Update accordingly.")); cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC)); cliOptions.add(new CliOption("discardReadOnly", "Set discardReadonly to true to generate the Initialize cmdlet without readonly parameters")); + + // default value in the template + additionalProperties.put("powershellVersion", "6.2"); // minimal PS version + additionalProperties.put("author", "OpenAPI Generator Team"); + additionalProperties.put("companyName", "openapitools.org"); + //additionalProperties.put("tags", "\"PowerShell\", \"OpenAPI-Generator\", \"REST\", \"API\""); + additionalProperties.put("PSData", null); + } public CodegenType getTag() { diff --git a/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache b/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache index ed875bc5e827..311249a7cdb9 100644 --- a/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache +++ b/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache @@ -44,16 +44,24 @@ $FunctionPath = 'Api', 'Model', 'Client' | ForEach-Object {Join-Path "$ScriptDir $Manifest = @{ Path = "$ScriptDir\src\{{{packageName}}}\{{{packageName}}}.psd1" - Author = 'OpenAPI Generator Team' - CompanyName = 'openapitools.org' + Author = '{{{author}}}' + CompanyName = '{{{companyName}}}' Description = '{{{packageName}}} - the PowerShell module for {{{appName}}}' + {{#PSData}} + PrivateData = @{ + PSData = @{ + {{{.}}} + } + } + + {{/PSData}} ModuleVersion = '{{{packageVersion}}}' RootModule = '{{{packageName}}}.psm1' Guid = '{{packageGuid}}' # Has to be static, otherwise each new build will be considered different module - PowerShellVersion = '3.0' + PowerShellVersion = '{{{powershellVersion}}}' FunctionsToExport = $FunctionPath | Get-ChildItem -Filter *.ps1 | Get-FunctionsToExport diff --git a/modules/openapi-generator/src/main/resources/powershell/README.mustache b/modules/openapi-generator/src/main/resources/powershell/README.mustache index 357274b65430..92a130fbddd5 100644 --- a/modules/openapi-generator/src/main/resources/powershell/README.mustache +++ b/modules/openapi-generator/src/main/resources/powershell/README.mustache @@ -18,7 +18,7 @@ This PowerShell module is automatically generated by the [OpenAPI Generator](htt ## Frameworks supported -- PowerShell 5.0 or later +- PowerShell {{{powershellVersion}}} or later ## Dependencies diff --git a/samples/client/petstore/powershell/Build.ps1 b/samples/client/petstore/powershell/Build.ps1 index 72aa4fe183b6..32fbc11ccd56 100644 --- a/samples/client/petstore/powershell/Build.ps1 +++ b/samples/client/petstore/powershell/Build.ps1 @@ -59,7 +59,7 @@ $Manifest = @{ RootModule = 'PSPetstore.psm1' Guid = 'a27b908d-2a20-467f-bc32-af6f3a654ac5' # Has to be static, otherwise each new build will be considered different module - PowerShellVersion = '3.0' + PowerShellVersion = '6.2' FunctionsToExport = $FunctionPath | Get-ChildItem -Filter *.ps1 | Get-FunctionsToExport diff --git a/samples/client/petstore/powershell/README.md b/samples/client/petstore/powershell/README.md index 6d3c70607d9a..3450b341144c 100644 --- a/samples/client/petstore/powershell/README.md +++ b/samples/client/petstore/powershell/README.md @@ -10,7 +10,7 @@ This PowerShell module is automatically generated by the [OpenAPI Generator](htt ## Frameworks supported -- PowerShell 5.0 or later +- PowerShell 6.2 or later ## Dependencies From 3bf007dee0b095982f15b67b6862b98f47513b0e Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 2 Jul 2020 17:25:23 +0800 Subject: [PATCH 2/3] set powershell version --- bin/configs/powershell.yaml | 1 + samples/client/petstore/powershell/Build.ps1 | 2 +- samples/client/petstore/powershell/README.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/configs/powershell.yaml b/bin/configs/powershell.yaml index 2ef633c994f4..62a6dab02e14 100644 --- a/bin/configs/powershell.yaml +++ b/bin/configs/powershell.yaml @@ -9,3 +9,4 @@ additionalProperties: packageName: PSPetstore powershellGalleryUrl: https://www.powershellgallery.com/packages/PSPetstore apiNamePrefix: PS + powershellVersion: "5.0" diff --git a/samples/client/petstore/powershell/Build.ps1 b/samples/client/petstore/powershell/Build.ps1 index 32fbc11ccd56..c6cc0b75d958 100644 --- a/samples/client/petstore/powershell/Build.ps1 +++ b/samples/client/petstore/powershell/Build.ps1 @@ -59,7 +59,7 @@ $Manifest = @{ RootModule = 'PSPetstore.psm1' Guid = 'a27b908d-2a20-467f-bc32-af6f3a654ac5' # Has to be static, otherwise each new build will be considered different module - PowerShellVersion = '6.2' + PowerShellVersion = '5.0' FunctionsToExport = $FunctionPath | Get-ChildItem -Filter *.ps1 | Get-FunctionsToExport diff --git a/samples/client/petstore/powershell/README.md b/samples/client/petstore/powershell/README.md index 3450b341144c..6d3c70607d9a 100644 --- a/samples/client/petstore/powershell/README.md +++ b/samples/client/petstore/powershell/README.md @@ -10,7 +10,7 @@ This PowerShell module is automatically generated by the [OpenAPI Generator](htt ## Frameworks supported -- PowerShell 6.2 or later +- PowerShell 5.0 or later ## Dependencies From e1185c1c0815794ed115dbec3cc78286de57f25a Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 2 Jul 2020 20:40:45 +0800 Subject: [PATCH 3/3] fix psData --- .../codegen/languages/PowerShellClientCodegen.java | 4 +--- .../src/main/resources/powershell/Build.ps1.mustache | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java index 99b349860d85..7f166b6a241e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java @@ -506,9 +506,7 @@ public PowerShellClientCodegen() { additionalProperties.put("powershellVersion", "6.2"); // minimal PS version additionalProperties.put("author", "OpenAPI Generator Team"); additionalProperties.put("companyName", "openapitools.org"); - //additionalProperties.put("tags", "\"PowerShell\", \"OpenAPI-Generator\", \"REST\", \"API\""); - additionalProperties.put("PSData", null); - + additionalProperties.put("psData", null); } public CodegenType getTag() { diff --git a/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache b/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache index 311249a7cdb9..31fd8a32a838 100644 --- a/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache +++ b/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache @@ -48,14 +48,14 @@ $Manifest = @{ CompanyName = '{{{companyName}}}' Description = '{{{packageName}}} - the PowerShell module for {{{appName}}}' - {{#PSData}} + {{#psData}} PrivateData = @{ PSData = @{ {{{.}}} } } - {{/PSData}} + {{/psData}} ModuleVersion = '{{{packageVersion}}}' RootModule = '{{{packageName}}}.psm1'