use prepare instead of new (#5773)

This commit is contained in:
William Cheng 2020-04-01 09:24:07 +08:00 committed by GitHub
parent 01d07694fb
commit 24513091b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 65 additions and 73 deletions

View File

@ -804,7 +804,7 @@ public class PowerShellExperimentalClientCodegen extends DefaultCodegen implemen
processedModelMap.put(model, 1); processedModelMap.put(model, 1);
} }
example = "(New-" + codegenModel.name; example = "(Prepare-" + codegenModel.name;
List<String> propertyExamples = new ArrayList<>(); List<String> propertyExamples = new ArrayList<>();
for (CodegenProperty codegenProperty : codegenModel.vars) { for (CodegenProperty codegenProperty : codegenModel.vars) {
propertyExamples.add(" -" + codegenProperty.name + " " + constructExampleCode(codegenProperty, modelMaps, processedModelMap)); propertyExamples.add(" -" + codegenProperty.name + " " + constructExampleCode(codegenProperty, modelMaps, processedModelMap));

View File

@ -20,7 +20,7 @@
{{{classname}}}<PSCustomObject> {{{classname}}}<PSCustomObject>
#> #>
function New-{{{apiNamePrefix}}}{{{classname}}} { function Prepare-{{{apiNamePrefix}}}{{{classname}}} {
[CmdletBinding()] [CmdletBinding()]
Param ( Param (
{{#vars}} {{#vars}}

View File

@ -10,20 +10,19 @@ Name | Type | Description | Notes
## Examples ## Examples
- Create a new object - Prepare the resource
```powershell ```powershell
New-{{{packageName}}}{{{classname}}} {{#vars}} -{{name}} {{example}}{{#hasMore}} ` Prepare-{{{packageName}}}{{{classname}}} {{#vars}} -{{name}} {{example}}{{#hasMore}} `
{{/hasMore}} {{/hasMore}}
{{/vars}} {{/vars}}
``` ```
- Convert the object to JSON - Convert the resource to JSON
```powershell ```powershell
${{className}} | Convert-ToJSON ${{className}} | Convert-ToJSON
``` ```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
{{/model}} {{/model}}

View File

@ -9,18 +9,17 @@ Name | Type | Description | Notes
## Examples ## Examples
- Create a new object - Prepare the resource
```powershell ```powershell
New-PSPetstoreApiResponse -Code null ` Prepare-PSPetstoreApiResponse -Code null `
-Type null ` -Type null `
-Message null -Message null
``` ```
- Convert the object to JSON - Convert the resource to JSON
```powershell ```powershell
$ | Convert-ToJSON $ | Convert-ToJSON
``` ```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -8,17 +8,16 @@ Name | Type | Description | Notes
## Examples ## Examples
- Create a new object - Prepare the resource
```powershell ```powershell
New-PSPetstoreCategory -Id null ` Prepare-PSPetstoreCategory -Id null `
-Name null -Name null
``` ```
- Convert the object to JSON - Convert the resource to JSON
```powershell ```powershell
$ | Convert-ToJSON $ | Convert-ToJSON
``` ```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -8,17 +8,16 @@ Name | Type | Description | Notes
## Examples ## Examples
- Create a new object - Prepare the resource
```powershell ```powershell
New-PSPetstoreInlineObject -Name null ` Prepare-PSPetstoreInlineObject -Name null `
-Status null -Status null
``` ```
- Convert the object to JSON - Convert the resource to JSON
```powershell ```powershell
$ | Convert-ToJSON $ | Convert-ToJSON
``` ```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -8,17 +8,16 @@ Name | Type | Description | Notes
## Examples ## Examples
- Create a new object - Prepare the resource
```powershell ```powershell
New-PSPetstoreInlineObject1 -AdditionalMetadata null ` Prepare-PSPetstoreInlineObject1 -AdditionalMetadata null `
-File null -File null
``` ```
- Convert the object to JSON - Convert the resource to JSON
```powershell ```powershell
$ | Convert-ToJSON $ | Convert-ToJSON
``` ```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -12,9 +12,9 @@ Name | Type | Description | Notes
## Examples ## Examples
- Create a new object - Prepare the resource
```powershell ```powershell
New-PSPetstoreOrder -Id null ` Prepare-PSPetstoreOrder -Id null `
-PetId null ` -PetId null `
-Quantity null ` -Quantity null `
-ShipDate null ` -ShipDate null `
@ -22,11 +22,10 @@ New-PSPetstoreOrder -Id null `
-Complete null -Complete null
``` ```
- Convert the object to JSON - Convert the resource to JSON
```powershell ```powershell
$ | Convert-ToJSON $ | Convert-ToJSON
``` ```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -29,7 +29,7 @@ $Configuration = Get-PSPetstoreConfiguration
# Configure OAuth2 access token for authorization: petstore_auth # Configure OAuth2 access token for authorization: petstore_auth
$Configuration["AccessToken"] = "YOUR_ACCESS_TOKEN"; $Configuration["AccessToken"] = "YOUR_ACCESS_TOKEN";
$Pet = (New-Pet -Id 123 -Category (New-Category -Id 123 -Name "Name_example") -Name "Name_example" -PhotoUrls @("PhotoUrls_example") -Tags @((New-Tag -Id 123 -Name "Name_example")) -Status "Status_example") # Pet | Pet object that needs to be added to the store $Pet = (Prepare-Pet -Id 123 -Category (Prepare-Category -Id 123 -Name "Name_example") -Name "Name_example" -PhotoUrls @("PhotoUrls_example") -Tags @((Prepare-Tag -Id 123 -Name "Name_example")) -Status "Status_example") # Pet | Pet object that needs to be added to the store
# Add a new pet to the store # Add a new pet to the store
try { try {
@ -275,7 +275,7 @@ $Configuration = Get-PSPetstoreConfiguration
# Configure OAuth2 access token for authorization: petstore_auth # Configure OAuth2 access token for authorization: petstore_auth
$Configuration["AccessToken"] = "YOUR_ACCESS_TOKEN"; $Configuration["AccessToken"] = "YOUR_ACCESS_TOKEN";
$Pet = (New-Pet -Id 123 -Category (New-Category -Id 123 -Name "Name_example") -Name "Name_example" -PhotoUrls @("PhotoUrls_example") -Tags @((New-Tag -Id 123 -Name "Name_example")) -Status "Status_example") # Pet | Pet object that needs to be added to the store $Pet = (Prepare-Pet -Id 123 -Category (Prepare-Category -Id 123 -Name "Name_example") -Name "Name_example" -PhotoUrls @("PhotoUrls_example") -Tags @((Prepare-Tag -Id 123 -Name "Name_example")) -Status "Status_example") # Pet | Pet object that needs to be added to the store
# Update an existing pet # Update an existing pet
try { try {

View File

@ -157,7 +157,7 @@ Place an order for a pet
```powershell ```powershell
Import-Module -Name PSPetstore Import-Module -Name PSPetstore
$Order = (New-Order -Id 123 -PetId 123 -Quantity 123 -ShipDate Get-Date -Status "Status_example" -Complete $false) # Order | order placed for purchasing the pet $Order = (Prepare-Order -Id 123 -PetId 123 -Quantity 123 -ShipDate Get-Date -Status "Status_example" -Complete $false) # Order | order placed for purchasing the pet
# Place an order for a pet # Place an order for a pet
try { try {

View File

@ -33,7 +33,7 @@ $Configuration["ApiKey"]["AUTH_KEY"] = "YOUR_API_KEY"
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
#$Configuration["ApiKeyPrefix"]["AUTH_KEY"] = "Bearer" #$Configuration["ApiKeyPrefix"]["AUTH_KEY"] = "Bearer"
$User = (New-User -Id 123 -Username "Username_example" -FirstName "FirstName_example" -LastName "LastName_example" -Email "Email_example" -Password "Password_example" -Phone "Phone_example" -UserStatus 123) # User | Created user object $User = (Prepare-User -Id 123 -Username "Username_example" -FirstName "FirstName_example" -LastName "LastName_example" -Email "Email_example" -Password "Password_example" -Phone "Phone_example" -UserStatus 123) # User | Created user object
# Create user # Create user
try { try {
@ -82,7 +82,7 @@ $Configuration["ApiKey"]["AUTH_KEY"] = "YOUR_API_KEY"
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
#$Configuration["ApiKeyPrefix"]["AUTH_KEY"] = "Bearer" #$Configuration["ApiKeyPrefix"]["AUTH_KEY"] = "Bearer"
$User = @((New-User -Id 123 -Username "Username_example" -FirstName "FirstName_example" -LastName "LastName_example" -Email "Email_example" -Password "Password_example" -Phone "Phone_example" -UserStatus 123)) # User[] | List of user object $User = @((Prepare-User -Id 123 -Username "Username_example" -FirstName "FirstName_example" -LastName "LastName_example" -Email "Email_example" -Password "Password_example" -Phone "Phone_example" -UserStatus 123)) # User[] | List of user object
# Creates list of users with given input array # Creates list of users with given input array
try { try {

View File

@ -12,9 +12,9 @@ Name | Type | Description | Notes
## Examples ## Examples
- Create a new object - Prepare the resource
```powershell ```powershell
New-PSPetstorePet -Id null ` Prepare-PSPetstorePet -Id null `
-Category null ` -Category null `
-Name doggie ` -Name doggie `
-PhotoUrls null ` -PhotoUrls null `
@ -22,11 +22,10 @@ New-PSPetstorePet -Id null `
-Status null -Status null
``` ```
- Convert the object to JSON - Convert the resource to JSON
```powershell ```powershell
$ | Convert-ToJSON $ | Convert-ToJSON
``` ```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -8,17 +8,16 @@ Name | Type | Description | Notes
## Examples ## Examples
- Create a new object - Prepare the resource
```powershell ```powershell
New-PSPetstoreTag -Id null ` Prepare-PSPetstoreTag -Id null `
-Name null -Name null
``` ```
- Convert the object to JSON - Convert the resource to JSON
```powershell ```powershell
$ | Convert-ToJSON $ | Convert-ToJSON
``` ```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -14,9 +14,9 @@ Name | Type | Description | Notes
## Examples ## Examples
- Create a new object - Prepare the resource
```powershell ```powershell
New-PSPetstoreUser -Id null ` Prepare-PSPetstoreUser -Id null `
-Username null ` -Username null `
-FirstName null ` -FirstName null `
-LastName null ` -LastName null `
@ -26,11 +26,10 @@ New-PSPetstoreUser -Id null `
-UserStatus null -UserStatus null
``` ```
- Convert the object to JSON - Convert the resource to JSON
```powershell ```powershell
$ | Convert-ToJSON $ | Convert-ToJSON
``` ```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -28,7 +28,7 @@ No description available.
ApiResponse<PSCustomObject> ApiResponse<PSCustomObject>
#> #>
function New-PSApiResponse { function Prepare-PSApiResponse {
[CmdletBinding()] [CmdletBinding()]
Param ( Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]

View File

@ -25,7 +25,7 @@ No description available.
Category<PSCustomObject> Category<PSCustomObject>
#> #>
function New-PSCategory { function Prepare-PSCategory {
[CmdletBinding()] [CmdletBinding()]
Param ( Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]

View File

@ -25,7 +25,7 @@ Updated status of the pet
InlineObject<PSCustomObject> InlineObject<PSCustomObject>
#> #>
function New-PSInlineObject { function Prepare-PSInlineObject {
[CmdletBinding()] [CmdletBinding()]
Param ( Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]

View File

@ -25,7 +25,7 @@ file to upload
InlineObject1<PSCustomObject> InlineObject1<PSCustomObject>
#> #>
function New-PSInlineObject1 { function Prepare-PSInlineObject1 {
[CmdletBinding()] [CmdletBinding()]
Param ( Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]

View File

@ -37,7 +37,7 @@ No description available.
Order<PSCustomObject> Order<PSCustomObject>
#> #>
function New-PSOrder { function Prepare-PSOrder {
[CmdletBinding()] [CmdletBinding()]
Param ( Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]

View File

@ -37,7 +37,7 @@ pet status in the store
Pet<PSCustomObject> Pet<PSCustomObject>
#> #>
function New-PSPet { function Prepare-PSPet {
[CmdletBinding()] [CmdletBinding()]
Param ( Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]

View File

@ -25,7 +25,7 @@ No description available.
Tag<PSCustomObject> Tag<PSCustomObject>
#> #>
function New-PSTag { function Prepare-PSTag {
[CmdletBinding()] [CmdletBinding()]
Param ( Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]

View File

@ -43,7 +43,7 @@ User Status
User<PSCustomObject> User<PSCustomObject>
#> #>
function New-PSUser { function Prepare-PSUser {
[CmdletBinding()] [CmdletBinding()]
Param ( Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]

View File

@ -3,7 +3,7 @@
# #
# Generated by: OpenAPI Generator Team # Generated by: OpenAPI Generator Team
# #
# Generated on: 3/31/20 # Generated on: 4/1/20
# #
@{ @{
@ -75,11 +75,12 @@ FunctionsToExport = 'Add-PSPet', 'Remove-Pet', 'Find-PSPetsByStatus', 'Find-PSPe
'Get-PSOrderById', 'Invoke-PSPlaceOrder', 'New-PSUser', 'Get-PSOrderById', 'Invoke-PSPlaceOrder', 'New-PSUser',
'New-PSUsersWithArrayInput', 'New-PSUsersWithListInput', 'New-PSUsersWithArrayInput', 'New-PSUsersWithListInput',
'Remove-PSUser', 'Get-PSUserByName', 'Invoke-PSLoginUser', 'Remove-PSUser', 'Get-PSUserByName', 'Invoke-PSLoginUser',
'Invoke-PSLogoutUser', 'Update-PSUser', 'New-PSApiResponse', 'Invoke-PSLogoutUser', 'Update-PSUser', 'Prepare-PSApiResponse',
'New-PSCategory', 'New-PSInlineObject', 'New-PSInlineObject1', 'Prepare-PSCategory', 'Prepare-PSInlineObject',
'New-PSOrder', 'New-PSPet', 'New-PSTag', 'New-PSUser', 'Prepare-PSInlineObject1', 'Prepare-PSOrder', 'Prepare-PSPet',
'Get-PSConfiguration', 'Set-PSConfiguration', 'Prepare-PSTag', 'Prepare-PSUser', 'Get-PSConfiguration',
'Set-PSConfigurationApiKey', 'Set-PSConfigurationApiKeyPrefix', 'Set-PSConfiguration', 'Set-PSConfigurationApiKey',
'Set-PSConfigurationApiKeyPrefix',
'Set-PSConfigurationDefaultHeader', 'Get-PSHostSettings', 'Set-PSConfigurationDefaultHeader', 'Get-PSHostSettings',
'Get-PSUrlFromHostSettings' 'Get-PSUrlFromHostSettings'

View File

@ -6,8 +6,8 @@
# #
Describe -tag 'PSPetstore' -name 'PSStoreApi' { Describe -tag 'PSPetstore' -name 'PSStoreApi' {
Context 'Invoke-PSDeleteOrder' { Context 'Remove-PSOrder' {
It 'Test Invoke-PSDeleteOrder' { It 'Test Remove-PSOrder' {
#$TestResult = Invoke-PetApiGetPetById -OrderId "TEST_VALUE" #$TestResult = Invoke-PetApiGetPetById -OrderId "TEST_VALUE"
#$TestResult | Should BeOfType TODO #$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0 #$TestResult.property | Should Be 0

View File

@ -6,32 +6,32 @@
# #
Describe -tag 'PSPetstore' -name 'PSUserApi' { Describe -tag 'PSPetstore' -name 'PSUserApi' {
Context 'Invoke-PSCreateUser' { Context 'New-PSUser' {
It 'Test Invoke-PSCreateUser' { It 'Test New-PSUser' {
#$TestResult = Invoke-PetApiGetPetById -User "TEST_VALUE" #$TestResult = Invoke-PetApiGetPetById -User "TEST_VALUE"
#$TestResult | Should BeOfType TODO #$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0 #$TestResult.property | Should Be 0
} }
} }
Context 'Invoke-PSCreateUsersWithArrayInput' { Context 'New-PSUsersWithArrayInput' {
It 'Test Invoke-PSCreateUsersWithArrayInput' { It 'Test New-PSUsersWithArrayInput' {
#$TestResult = Invoke-PetApiGetPetById -User "TEST_VALUE" #$TestResult = Invoke-PetApiGetPetById -User "TEST_VALUE"
#$TestResult | Should BeOfType TODO #$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0 #$TestResult.property | Should Be 0
} }
} }
Context 'Invoke-PSCreateUsersWithListInput' { Context 'New-PSUsersWithListInput' {
It 'Test Invoke-PSCreateUsersWithListInput' { It 'Test New-PSUsersWithListInput' {
#$TestResult = Invoke-PetApiGetPetById -User "TEST_VALUE" #$TestResult = Invoke-PetApiGetPetById -User "TEST_VALUE"
#$TestResult | Should BeOfType TODO #$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0 #$TestResult.property | Should Be 0
} }
} }
Context 'Invoke-PSDeleteUser' { Context 'Remove-PSUser' {
It 'Test Invoke-PSDeleteUser' { It 'Test Remove-PSUser' {
#$TestResult = Invoke-PetApiGetPetById -Username "TEST_VALUE" #$TestResult = Invoke-PetApiGetPetById -Username "TEST_VALUE"
#$TestResult | Should BeOfType TODO #$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0 #$TestResult.property | Should Be 0

View File

@ -11,13 +11,13 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' {
$Id = 38369 $Id = 38369
# Add pet # Add pet
$Pet = New-PSPet -Id $Id -Name 'PowerShell' -Category ( $Pet = Prepare-PSPet -Id $Id -Name 'PowerShell' -Category (
New-PSCategory -Id $Id -Name 'PSCategory' Prepare-PSCategory -Id $Id -Name 'PSCategory'
) -PhotoUrls @( ) -PhotoUrls @(
'http://example.com/foo', 'http://example.com/foo',
'http://example.com/bar' 'http://example.com/bar'
) -Tags ( ) -Tags (
New-PSTag -Id $Id -Name 'PSTag' Prepare-PSTag -Id $Id -Name 'PSTag'
) -Status Available ) -Status Available
$Result = Add-PSPet -Pet $Pet $Result = Add-PSPet -Pet $Pet
@ -36,13 +36,13 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' {
$Result."status" | Should Be "Pending" $Result."status" | Should Be "Pending"
# Update (put) # Update (put)
$NewPet = New-PSPet -Id $Id -Name 'PowerShell2' -Category ( $NewPet = Prepare-PSPet -Id $Id -Name 'PowerShell2' -Category (
New-PSCategory -Id $Id -Name 'PSCategory2' Prepare-PSCategory -Id $Id -Name 'PSCategory2'
) -PhotoUrls @( ) -PhotoUrls @(
'http://example.com/foo2', 'http://example.com/foo2',
'http://example.com/bar2' 'http://example.com/bar2'
) -Tags ( ) -Tags (
New-PSTag -Id $Id -Name 'PSTag2' Prepare-PSTag -Id $Id -Name 'PSTag2'
) -Status Sold ) -Status Sold
$Result = Update-PSPet -Pet $NewPet $Result = Update-PSPet -Pet $NewPet