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/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..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 @@ -501,6 +501,12 @@ 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("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..31fd8a32a838 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..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 = '3.0' + PowerShellVersion = '5.0' FunctionsToExport = $FunctionPath | Get-ChildItem -Filter *.ps1 | Get-FunctionsToExport