forked from loafle/openapi-generator-original
better readme, type mapping, new option (#5740)
This commit is contained in:
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/powershell-experimental -i modules/openapi-generator/src/test/resources/3_0/powershell/petstore.yaml -g powershell-experimental -o samples/client/petstore/powershell-experimental --additional-properties packageGuid=a27b908d-2a20-467f-bc32-af6f3a654ac5,packageName=PSPetstore,apiNamePrefix=PS,packageVersion=0.1.2 -c ./bin/powershell-config.json $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/powershell-experimental -i modules/openapi-generator/src/test/resources/3_0/powershell/petstore.yaml -g powershell-experimental -o samples/client/petstore/powershell-experimental --additional-properties powershellGalleryUrl=https://www.powershellgallery.com/packages/PSPetstore,packageGuid=a27b908d-2a20-467f-bc32-af6f3a654ac5,packageName=PSPetstore,apiNamePrefix=PS,packageVersion=0.1.2 -c ./bin/powershell-config.json $@"
|
||||
|
||||
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
||||
|
||||
@@ -5,10 +5,11 @@ sidebar_label: powershell-experimental
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|apiNamePrefix|Prefix that will be appended to all API names ('tags'). Default: empty string. e.g. Pet => Pet.| |null|
|
||||
|apiNamePrefix|Prefix that will be appended to all PS objects. Default: empty string. e.g. Pet => PSPet.| |null|
|
||||
|packageGuid|GUID for PowerShell module (e.g. a27b908d-2a20-467f-bc32-af6f3a654ac5). A random GUID will be generated by default.| |null|
|
||||
|packageName|Client package name (e.g. org.openapitools.client).| |PSOpenAPITools|
|
||||
|packageName|Client package name (e.g. PSTwitter).| |PSOpenAPITools|
|
||||
|packageVersion|Package version (e.g. 0.1.2).| |0.1.2|
|
||||
|powershellGalleryUrl|URL to the module in PowerShell Gallery (e.g. https://www.powershellgallery.com/packages/PSTwitter/).| |null|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ public class PowerShellExperimentalClientCodegen extends DefaultCodegen implemen
|
||||
protected String modelTestPath = "tests/Model";
|
||||
protected HashSet nullablePrimitives;
|
||||
protected HashSet powershellVerbs;
|
||||
protected String powershellGalleryUrl;
|
||||
|
||||
/**
|
||||
* Constructs an instance of `PowerShellExperimentalClientCodegen`.
|
||||
@@ -308,19 +309,23 @@ public class PowerShellExperimentalClientCodegen extends DefaultCodegen implemen
|
||||
typeMapping.put("long", "Int64");
|
||||
typeMapping.put("double", "Double");
|
||||
typeMapping.put("number", "Decimal");
|
||||
typeMapping.put("date-time", "System.DateTime");
|
||||
typeMapping.put("date", "System.DateTime");
|
||||
typeMapping.put("object", "String");
|
||||
typeMapping.put("object", "System.Hashtable");
|
||||
typeMapping.put("file", "System.IO.FileInfo");
|
||||
typeMapping.put("ByteArray", "System.Byte[]");
|
||||
typeMapping.put("binary", "System.IO.FileInfo");
|
||||
typeMapping.put("date", "System.DateTime");
|
||||
typeMapping.put("date-time", "System.DateTime");
|
||||
typeMapping.put("Date", "System.DateTime");
|
||||
typeMapping.put("DateTime", "System.DateTime");
|
||||
typeMapping.put("UUID", "String");
|
||||
typeMapping.put("URI", "String");
|
||||
|
||||
cliOptions.clear();
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Client package name (e.g. org.openapitools.client).").defaultValue(this.packageName));
|
||||
cliOptions.add(new CliOption("powershellGalleryUrl", "URL to the module in PowerShell Gallery (e.g. https://www.powershellgallery.com/packages/PSTwitter/)."));
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Client package name (e.g. PSTwitter).").defaultValue(this.packageName));
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Package version (e.g. 0.1.2).").defaultValue(this.packageVersion));
|
||||
cliOptions.add(new CliOption(CodegenConstants.OPTIONAL_PROJECT_GUID, "GUID for PowerShell module (e.g. a27b908d-2a20-467f-bc32-af6f3a654ac5). A random GUID will be generated by default."));
|
||||
cliOptions.add(new CliOption(CodegenConstants.API_NAME_PREFIX, CodegenConstants.API_NAME_PREFIX_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.API_NAME_PREFIX, "Prefix that will be appended to all PS objects. Default: empty string. e.g. Pet => PSPet."));
|
||||
|
||||
}
|
||||
|
||||
@@ -354,14 +359,30 @@ public class PowerShellExperimentalClientCodegen extends DefaultCodegen implemen
|
||||
this.packageGuid = packageGuid;
|
||||
}
|
||||
|
||||
public void setPowershellGalleryUrl(String powershellGalleryUrl) {
|
||||
this.powershellGalleryUrl = powershellGalleryUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey("powershellGalleryUrl")) {
|
||||
setPowershellGalleryUrl((String) additionalProperties.get("powershellGalleryUrl"));
|
||||
} else {
|
||||
additionalProperties.put("powershellGalleryUrl", powershellGalleryUrl);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(powershellGalleryUrl)) {
|
||||
additionalProperties.put("powershellGalleryId", powershellGalleryUrl.replaceFirst(".*/([^/?]+).*", "$1"));
|
||||
//additionalProperties.put("powershellGalleryId", "something");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_PROJECT_GUID)) {
|
||||
setPackageGuid((String) additionalProperties.get(CodegenConstants.OPTIONAL_PROJECT_GUID));
|
||||
} else {
|
||||
additionalProperties.put("packageGuid", packageGuid);
|
||||
}
|
||||
additionalProperties.put("packageGuid", packageGuid);
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||
this.setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
||||
|
||||
@@ -25,14 +25,22 @@ This PowerShell module is automatically generated by the [OpenAPI Generator](htt
|
||||
|
||||
<a name="installation"></a>
|
||||
## Installation
|
||||
Run the following command to build the PowerShell module locally:
|
||||
- `Build.ps1`
|
||||
|
||||
Then import module from the .\src\{{{packageName}}} folder:
|
||||
{{#powershellGalleryUrl}}
|
||||
To install from PowerShell Gallery ({{{powershellGalleryUrl}}})
|
||||
```powershell
|
||||
Import-Module -Name {{{powershellGalleryId}}}
|
||||
```
|
||||
{{/powershellGalleryUrl}}
|
||||
|
||||
To install from the source, run the following command to build and install the PowerShell module locally:
|
||||
```powershell
|
||||
Build.ps1
|
||||
Import-Module -Name '.\src\{{{packageName}}}'
|
||||
```
|
||||
|
||||
To avoid function name collision, one can use `-Prefix`, e.g. `Import-Module -Name '.\src\{{{packageName}}}' -Prefix prefix`
|
||||
|
||||
To uninstall the module, simply run:
|
||||
```powershell
|
||||
Remove-Module -FullyQualifiedName @{ModuleName = "{{{packageName}}}"; ModuleVersion = "{{{packageVersion}}}"}
|
||||
|
||||
@@ -17,14 +17,20 @@ This PowerShell module is automatically generated by the [OpenAPI Generator](htt
|
||||
|
||||
<a name="installation"></a>
|
||||
## Installation
|
||||
Run the following command to build the PowerShell module locally:
|
||||
- `Build.ps1`
|
||||
|
||||
Then import module from the .\src\PSPetstore folder:
|
||||
To install from PowerShell Gallery (https://www.powershellgallery.com/packages/PSPetstore)
|
||||
```powershell
|
||||
Import-Module -Name PSPetstore
|
||||
```
|
||||
|
||||
To install from the source, run the following command to build and install the PowerShell module locally:
|
||||
```powershell
|
||||
Build.ps1
|
||||
Import-Module -Name '.\src\PSPetstore'
|
||||
```
|
||||
|
||||
To avoid function name collision, one can use `-Prefix`, e.g. `Import-Module -Name '.\src\PSPetstore' -Prefix prefix`
|
||||
|
||||
To uninstall the module, simply run:
|
||||
```powershell
|
||||
Remove-Module -FullyQualifiedName @{ModuleName = "PSPetstore"; ModuleVersion = "0.1.2"}
|
||||
|
||||
Reference in New Issue
Block a user