Skip to content
Permalink
Browse files

[Powershell] refactor the client generator (#5629)

* add api client

* add local variables

* add configuration

* add header/query/form parameter support

* add partial header

* add auth, fix parameters type

* fix accept, content type

* url query string

* fix path, header

* remove dep on C# client

* fix method naming with package name

* fix object

* convert result from json

* better response handling

* remove tostring method

* fix model doc

* fix default module

* generate api test files

* better api, model tests

* fix add pet

* add appveyor

* fix accept, content type

* add petstore tests

* fix form parameters

* test delete

* better file handling (upload)

* better code sample

* add package version, better doc

* delete unused files

* fix header parameters

* clean up api client

* update samples

* support query parameter

* better method and parameter naming

* minor formatting change

* better doc, fix cookie parameter

* better doc

* add api prefix support

* better api nam prefix option

* fix configuration

* throw errors for required parameter

* fix authentication

* add try catch block to sample code

* rename model

* use debug, clean up comment

* revise code

* move bin script

* update doc

* add new file

* better map support
  • Loading branch information
wing328 committed Mar 19, 2020
1 parent dc36d59 commit 457aff84964a0c91896a3af118e187e79b3940d6
Showing with 6,848 additions and 0 deletions.
  1. +32 −0 bin/openapi3/powershell-experimental-petstore.sh
  2. +3 −0 bin/powershell-config.json
  3. +1 −0 docs/generators.md
  4. +212 −0 docs/generators/powershell-experimental.md
  5. +821 −0 ...nerator/src/main/java/org/openapitools/codegen/languages/PowerShellExperimentalClientCodegen.java
  6. +1 −0 ...les/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
  7. +66 −0 modules/openapi-generator/src/main/resources/powershell-experimental/Build.ps1.mustache
  8. +15 −0 modules/openapi-generator/src/main/resources/powershell-experimental/Get-CommonParameters.mustache
  9. +20 −0 modules/openapi-generator/src/main/resources/powershell-experimental/Org.OpenAPITools.psm1.mustache
  10. +38 −0 modules/openapi-generator/src/main/resources/powershell-experimental/Out-DebugParameter.mustache
  11. +104 −0 modules/openapi-generator/src/main/resources/powershell-experimental/README.mustache
  12. +27 −0 ...api-generator/src/main/resources/powershell-experimental/about_Org.OpenAPITools.help.txt.mustache
  13. +179 −0 modules/openapi-generator/src/main/resources/powershell-experimental/api.mustache
  14. +168 −0 modules/openapi-generator/src/main/resources/powershell-experimental/api_client.mustache
  15. +87 −0 modules/openapi-generator/src/main/resources/powershell-experimental/api_doc.mustache
  16. +15 −0 modules/openapi-generator/src/main/resources/powershell-experimental/api_test.mustache
  17. +10 −0 modules/openapi-generator/src/main/resources/powershell-experimental/appveyor.mustache
  18. +114 −0 modules/openapi-generator/src/main/resources/powershell-experimental/configuration.mustache
  19. +32 −0 modules/openapi-generator/src/main/resources/powershell-experimental/model.mustache
  20. +30 −0 modules/openapi-generator/src/main/resources/powershell-experimental/model_doc.mustache
  21. +14 −0 modules/openapi-generator/src/main/resources/powershell-experimental/model_test.mustache
  22. +15 −0 modules/openapi-generator/src/main/resources/powershell-experimental/partial_header.mustache
  23. +741 −0 modules/openapi-generator/src/test/resources/3_0/powershell/petstore.yaml
  24. +23 −0 samples/client/petstore/powershell-experimental/.openapi-generator-ignore
  25. +1 −0 samples/client/petstore/powershell-experimental/.openapi-generator/VERSION
  26. +72 −0 samples/client/petstore/powershell-experimental/Build.ps1
  27. +112 −0 samples/client/petstore/powershell-experimental/README.md
  28. +54 −0 samples/client/petstore/powershell-experimental/Test1.ps1
  29. +16 −0 samples/client/petstore/powershell-experimental/appveyor.yml
  30. +26 −0 samples/client/petstore/powershell-experimental/docs/ApiResponse.md
  31. +24 −0 samples/client/petstore/powershell-experimental/docs/Category.md
  32. +24 −0 samples/client/petstore/powershell-experimental/docs/InlineObject.md
  33. +24 −0 samples/client/petstore/powershell-experimental/docs/InlineObject1.md
  34. +32 −0 samples/client/petstore/powershell-experimental/docs/Order.md
  35. +415 −0 samples/client/petstore/powershell-experimental/docs/PSPetApi.md
  36. +191 −0 samples/client/petstore/powershell-experimental/docs/PSStoreApi.md
  37. +403 −0 samples/client/petstore/powershell-experimental/docs/PSUserApi.md
  38. +32 −0 samples/client/petstore/powershell-experimental/docs/Pet.md
  39. +24 −0 samples/client/petstore/powershell-experimental/docs/Tag.md
  40. +36 −0 samples/client/petstore/powershell-experimental/docs/User.md
  41. BIN samples/client/petstore/powershell-experimental/plus.gif
  42. +433 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSPetApi.ps1
  43. +190 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSStoreApi.ps1
  44. +410 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSUserApi.ps1
  45. +120 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/Client/PSConfiguration.ps1
  46. +34 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/Model/ApiResponse.ps1
  47. +30 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/Model/Category.ps1
  48. +30 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/Model/InlineObject.ps1
  49. +30 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/Model/InlineObject1.ps1
  50. +46 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/Model/Order.ps1
  51. +46 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/Model/Pet.ps1
  52. +30 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/Model/Tag.ps1
  53. +54 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/Model/User.ps1
  54. +133 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/PSPetstore.psd1
  55. +26 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/PSPetstore.psm1
  56. +21 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/Private/Get-CommonParameters.ps1
  57. +44 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/Private/Out-DebugParameter.ps1
  58. +174 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/Private/PSApiClient.ps1
  59. +19 −0 samples/client/petstore/powershell-experimental/src/PSPetstore/en-US/about_PSPetstore.help.txt
  60. +16 −0 samples/client/petstore/powershell-experimental/tests/ApiResponse.Tests.ps1
  61. +16 −0 samples/client/petstore/powershell-experimental/tests/Category.Tests.ps1
  62. +31 −0 samples/client/petstore/powershell-experimental/tests/Configuration.Tests.ps1
  63. +16 −0 samples/client/petstore/powershell-experimental/tests/InlineObject.Tests.ps1
  64. +16 −0 samples/client/petstore/powershell-experimental/tests/InlineObject1.Tests.ps1
  65. +16 −0 samples/client/petstore/powershell-experimental/tests/New-ApiResponse.Tests.ps1
  66. +16 −0 samples/client/petstore/powershell-experimental/tests/New-Category.Tests.ps1
  67. +16 −0 samples/client/petstore/powershell-experimental/tests/New-InlineObject.Tests.ps1
  68. +16 −0 samples/client/petstore/powershell-experimental/tests/New-InlineObject1.Tests.ps1
  69. +16 −0 samples/client/petstore/powershell-experimental/tests/New-Order.Tests.ps1
  70. +16 −0 samples/client/petstore/powershell-experimental/tests/New-Pet.Tests.ps1
  71. +16 −0 samples/client/petstore/powershell-experimental/tests/New-Tag.Tests.ps1
  72. +16 −0 samples/client/petstore/powershell-experimental/tests/New-User.Tests.ps1
  73. +16 −0 samples/client/petstore/powershell-experimental/tests/Order.Tests.ps1
  74. +73 −0 samples/client/petstore/powershell-experimental/tests/PSPetApi.Tests.ps1
  75. +41 −0 samples/client/petstore/powershell-experimental/tests/PSStoreApi.Tests.ps1
  76. +73 −0 samples/client/petstore/powershell-experimental/tests/PSUserApi.Tests.ps1
  77. +16 −0 samples/client/petstore/powershell-experimental/tests/Pet.Tests.ps1
  78. +73 −0 samples/client/petstore/powershell-experimental/tests/PetApi.Tests.ps1
  79. +63 −0 samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1
  80. +41 −0 samples/client/petstore/powershell-experimental/tests/StoreApi.Tests.ps1
  81. +16 −0 samples/client/petstore/powershell-experimental/tests/Tag.Tests.ps1
  82. +16 −0 samples/client/petstore/powershell-experimental/tests/User.Tests.ps1
  83. +73 −0 samples/client/petstore/powershell-experimental/tests/UserApi.Tests.ps1
  84. BIN samples/client/petstore/powershell-experimental/tests/plus.gif
@@ -0,0 +1,32 @@
#!/bin/sh

SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"

while [ -h "$SCRIPT" ] ; do
ls=$(ls -ld "$SCRIPT")
link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=$(dirname "$SCRIPT")/"$link"
fi
done

if [ ! -d "${APP_DIR}" ]; then
APP_DIR=$(dirname "$SCRIPT")/..
APP_DIR=$(cd "${APP_DIR}"; pwd)
fi

executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"

if [ ! -f "$executable" ]
then
mvn -B clean package
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 $@"

java ${JAVA_OPTS} -jar ${executable} ${ags}
@@ -0,0 +1,3 @@
{
"skipFormModel": true
}
@@ -46,6 +46,7 @@ The following generators are available:
* [perl](generators/perl.md)
* [php](generators/php.md)
* [powershell](generators/powershell.md)
* [powershell-experimental (beta)](generators/powershell-experimental.md)
* [python](generators/python.md)
* [python-experimental (experimental)](generators/python-experimental.md)
* [r](generators/r.md)
@@ -0,0 +1,212 @@
---
title: Config Options for powershell-experimental
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|
|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|
|packageVersion|Package version (e.g. 0.1.2).| |0.1.2|

## IMPORT MAPPING

| Type/Alias | Imports |
| ---------- | ------- |
|Array|java.util.List|
|ArrayList|java.util.ArrayList|
|BigDecimal|java.math.BigDecimal|
|Date|java.util.Date|
|DateTime|org.joda.time.*|
|File|java.io.File|
|HashMap|java.util.HashMap|
|List|java.util.*|
|LocalDate|org.joda.time.*|
|LocalDateTime|org.joda.time.*|
|LocalTime|org.joda.time.*|
|Map|java.util.Map|
|Set|java.util.*|
|Timestamp|java.sql.Timestamp|
|URI|java.net.URI|
|UUID|java.util.UUID|


## INSTANTIATION TYPES

| Type/Alias | Instantiated By |
| ---------- | --------------- |


## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>Boolean</li>
<li>Byte</li>
<li>Byte[]</li>
<li>Char</li>
<li>Decimal</li>
<li>Double</li>
<li>Guid</li>
<li>Int16</li>
<li>Int32</li>
<li>Int64</li>
<li>ProgressRecord</li>
<li>SByte</li>
<li>SecureString</li>
<li>Single</li>
<li>String</li>
<li>System.DateTime</li>
<li>System.IO.FileInfo</li>
<li>TimeSpan</li>
<li>UInt16</li>
<li>UInt32</li>
<li>UInt64</li>
<li>Uri</li>
<li>Version</li>
<li>XmlDocument</li>
</ul>

## RESERVED WORDS

<ul class="column-ul">
<li>Begin</li>
<li>Break</li>
<li>Catch</li>
<li>Continue</li>
<li>Data</li>
<li>Do</li>
<li>Dynamicparam</li>
<li>Else</li>
<li>Elseif</li>
<li>End</li>
<li>Exit</li>
<li>Filter</li>
<li>Finally</li>
<li>For</li>
<li>Foreach</li>
<li>From</li>
<li>Function</li>
<li>If</li>
<li>In</li>
<li>Local</li>
<li>Param</li>
<li>Private</li>
<li>Process</li>
<li>Return</li>
<li>Switch</li>
<li>Throw</li>
<li>Trap</li>
<li>Try</li>
<li>Until</li>
<li>Where</li>
<li>While</li>
</ul>

## FEATURE SET


### Client Modification Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasePath|✗|ToolingExtension
|Authorizations|✗|ToolingExtension
|UserAgent|✗|ToolingExtension

### Data Type Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Custom|✗|OAS2,OAS3
|Int32|✓|OAS2,OAS3
|Int64|✓|OAS2,OAS3
|Float|✓|OAS2,OAS3
|Double|✓|OAS2,OAS3
|Decimal|✓|ToolingExtension
|String|✓|OAS2,OAS3
|Byte|✓|OAS2,OAS3
|Binary|✓|OAS2,OAS3
|Boolean|✓|OAS2,OAS3
|Date|✓|OAS2,OAS3
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Array|✓|OAS2,OAS3
|Maps|✓|ToolingExtension
|CollectionFormat|✓|OAS2
|CollectionFormatMulti|✓|OAS2
|Enum|✓|OAS2,OAS3
|ArrayOfEnum|✓|ToolingExtension
|ArrayOfModel|✓|ToolingExtension
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|ArrayOfCollectionOfModel|✓|ToolingExtension
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|MapOfEnum|✓|ToolingExtension
|MapOfModel|✓|ToolingExtension
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|MapOfCollectionOfModel|✓|ToolingExtension
|MapOfCollectionOfEnum|✓|ToolingExtension

### Documentation Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Readme|✓|ToolingExtension
|Model|✓|ToolingExtension
|Api|✓|ToolingExtension

### Global Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Host|✓|OAS2,OAS3
|BasePath|✓|OAS2,OAS3
|Info|✓|OAS2,OAS3
|Schemes|✗|OAS2,OAS3
|PartialSchemes|✓|OAS2,OAS3
|Consumes|✓|OAS2
|Produces|✓|OAS2
|ExternalDocumentation|✓|OAS2,OAS3
|Examples|✓|OAS2,OAS3
|XMLStructureDefinitions|✗|OAS2,OAS3
|MultiServer|✗|OAS3
|ParameterizedServer|✗|OAS3
|ParameterStyling|✗|OAS3
|Callbacks|✗|OAS3
|LinkObjects|✗|OAS3

### Parameter Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Path|✓|OAS2,OAS3
|Query|✓|OAS2,OAS3
|Header|✓|OAS2,OAS3
|Body|✓|OAS2
|FormUnencoded|✓|OAS2
|FormMultipart|✓|OAS2
|Cookie|✗|OAS3

### Schema Support Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Simple|✓|OAS2,OAS3
|Composite|✓|OAS2,OAS3
|Polymorphism|✗|OAS2,OAS3
|Union|✗|OAS3

### Security Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasicAuth|✓|OAS2,OAS3
|ApiKey|✓|OAS2,OAS3
|OpenIDConnect|✗|OAS3
|BearerToken|✗|OAS3
|OAuth2_Implicit|✓|OAS2,OAS3
|OAuth2_Password|✗|OAS2,OAS3
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|OAuth2_AuthorizationCode|✗|OAS2,OAS3

### Wire Format Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
|XML|✓|OAS2,OAS3
|PROTOBUF|✗|ToolingExtension
|Custom|✗|OAS2,OAS3

0 comments on commit 457aff8

Please sign in to comment.
You can’t perform that action at this time.