Skip to content

Commit aed5be9

Browse files
authored
[PowerShell] add more fields to be customized (#6835)
* more fields to be customized * set powershell version * fix psData
1 parent 23f57a7 commit aed5be9

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

bin/configs/powershell.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ additionalProperties:
99
packageName: PSPetstore
1010
powershellGalleryUrl: https://www.powershellgallery.com/packages/PSPetstore
1111
apiNamePrefix: PS
12+
powershellVersion: "5.0"

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,12 @@ public PowerShellClientCodegen() {
501501
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."));
502502
cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC));
503503
cliOptions.add(new CliOption("discardReadOnly", "Set discardReadonly to true to generate the Initialize cmdlet without readonly parameters"));
504+
505+
// default value in the template
506+
additionalProperties.put("powershellVersion", "6.2"); // minimal PS version
507+
additionalProperties.put("author", "OpenAPI Generator Team");
508+
additionalProperties.put("companyName", "openapitools.org");
509+
additionalProperties.put("psData", null);
504510
}
505511

506512
public CodegenType getTag() {

modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,24 @@ $FunctionPath = 'Api', 'Model', 'Client' | ForEach-Object {Join-Path "$ScriptDir
4444
$Manifest = @{
4545
Path = "$ScriptDir\src\{{{packageName}}}\{{{packageName}}}.psd1"
4646

47-
Author = 'OpenAPI Generator Team'
48-
CompanyName = 'openapitools.org'
47+
Author = '{{{author}}}'
48+
CompanyName = '{{{companyName}}}'
4949
Description = '{{{packageName}}} - the PowerShell module for {{{appName}}}'
5050

51+
{{#psData}}
52+
PrivateData = @{
53+
PSData = @{
54+
{{{.}}}
55+
}
56+
}
57+
58+
{{/psData}}
5159
ModuleVersion = '{{{packageVersion}}}'
5260

5361
RootModule = '{{{packageName}}}.psm1'
5462
Guid = '{{packageGuid}}' # Has to be static, otherwise each new build will be considered different module
5563

56-
PowerShellVersion = '3.0'
64+
PowerShellVersion = '{{{powershellVersion}}}'
5765

5866
FunctionsToExport = $FunctionPath | Get-ChildItem -Filter *.ps1 | Get-FunctionsToExport
5967

modules/openapi-generator/src/main/resources/powershell/README.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This PowerShell module is automatically generated by the [OpenAPI Generator](htt
1818

1919
<a name="frameworks-supported"></a>
2020
## Frameworks supported
21-
- PowerShell 5.0 or later
21+
- PowerShell {{{powershellVersion}}} or later
2222

2323
<a name="dependencies"></a>
2424
## Dependencies

samples/client/petstore/powershell/Build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ $Manifest = @{
5959
RootModule = 'PSPetstore.psm1'
6060
Guid = 'a27b908d-2a20-467f-bc32-af6f3a654ac5' # Has to be static, otherwise each new build will be considered different module
6161

62-
PowerShellVersion = '3.0'
62+
PowerShellVersion = '5.0'
6363

6464
FunctionsToExport = $FunctionPath | Get-ChildItem -Filter *.ps1 | Get-FunctionsToExport
6565

0 commit comments

Comments
 (0)