[REQ][PowerShell] Improve generated PowerShell examples (#9836)

* Implement new PowerShell example structure

Signed-off-by: Simeon Gerginov <sgerginov@vmware.com>

* Modify documentation template to work with the new PowerShell example format

Signed-off-by: Simeon Gerginov <sgerginov@vmware.com>

* Update PowerShell Generator documentation with the new properties

Signed-off-by: Simeon Gerginov <sgerginov@vmware.com>

* Update PowerShell samples with the new PowerShell example format

Signed-off-by: Simeon Gerginov <sgerginov@vmware.com>

* Fix issues with array of models as parameters

Signed-off-by: Simeon Gerginov <simeongerginov1@gmail.com>

* Change string value generation to include the prefix 'My'

Signed-off-by: Simeon Gerginov <simeongerginov1@gmail.com>

* Remove multiple new lines and trim leading and trailing spaces in PowerShell example

Signed-off-by: Simeon Gerginov <simeongerginov1@gmail.com>
This commit is contained in:
SimeonGerginov
2021-07-03 17:27:06 +03:00
committed by GitHub
parent 32a3eb1655
commit 3663831b4d
6 changed files with 360 additions and 177 deletions

View File

@@ -28,11 +28,13 @@ $Configuration = Get-Configuration
# Configure OAuth2 access token for authorization: petstore_auth
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
$Pet = (Initialize-Pet -Id 123 -Category (Initialize-Category -Id 123 -Name "Name_example") -Name "Name_example" -PhotoUrls @("PhotoUrls_example") -Tags @((Initialize-Tag -Id 123 -Name "Name_example")) -Status "available") # Pet | Pet object that needs to be added to the store
$Category = Initialize-Category -Id 0 -Name "MyName"
$Tag = Initialize-Tag -Id 0 -Name "MyName"
$Pet = Initialize-Pet -Id 0 -Category $Category -Name "doggie" -PhotoUrls "MyPhotoUrls" -Tags $Tag -Status "available" # Pet | Pet object that needs to be added to the store
# Add a new pet to the store
try {
$Result = Add-PSPet -Pet $Pet
$Result = Add-PSPet -Pet $Pet
} catch {
Write-Host ("Exception occured when calling Add-PSPet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
@@ -43,7 +45,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**Pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
**Pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type
@@ -75,12 +77,12 @@ $Configuration = Get-Configuration
# Configure OAuth2 access token for authorization: petstore_auth
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
$PetId = 987 # Int64 | Pet id to delete
$ApiKey = "ApiKey_example" # String | (optional)
$PetId = 789 # Int64 | Pet id to delete
$ApiKey = "MyApiKey" # String | (optional)
# Deletes a pet
try {
$Result = Remove-Pet -PetId $PetId -ApiKey $ApiKey
$Result = Remove-Pet -PetId $PetId -ApiKey $ApiKey
} catch {
Write-Host ("Exception occured when calling Remove-Pet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
@@ -91,8 +93,8 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**PetId** | **Int64**| Pet id to delete |
**ApiKey** | **String**| | [optional]
**PetId** | **Int64**| Pet id to delete |
**ApiKey** | **String**| | [optional]
### Return type
@@ -125,11 +127,11 @@ $Configuration = Get-Configuration
# Configure OAuth2 access token for authorization: petstore_auth
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
$Status = @("available") # String[] | Status values that need to be considered for filter
$Status = "available" # String[] | Status values that need to be considered for filter
# Finds Pets by status
try {
$Result = Find-PSPetsByStatus -Status $Status
$Result = Find-PSPetsByStatus -Status $Status
} catch {
Write-Host ("Exception occured when calling Find-PSPetsByStatus: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
@@ -140,7 +142,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**Status** | [**String[]**](String.md)| Status values that need to be considered for filter |
**Status** | [**String[]**](String.md)| Status values that need to be considered for filter |
### Return type
@@ -173,11 +175,11 @@ $Configuration = Get-Configuration
# Configure OAuth2 access token for authorization: petstore_auth
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
$Tags = @("Inner_example") # String[] | Tags to filter by
$Tags = "MyTags" # String[] | Tags to filter by
# Finds Pets by tags
try {
$Result = Find-PSPetsByTags -Tags $Tags
$Result = Find-PSPetsByTags -Tags $Tags
} catch {
Write-Host ("Exception occured when calling Find-PSPetsByTags: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
@@ -188,7 +190,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**Tags** | [**String[]**](String.md)| Tags to filter by |
**Tags** | [**String[]**](String.md)| Tags to filter by |
### Return type
@@ -223,11 +225,11 @@ $Configuration.ApiKey.api_key = "YOUR_API_KEY"
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
#$Configuration.ApiKeyPrefix.api_key = "Bearer"
$PetId = 987 # Int64 | ID of pet to return
$PetId = 789 # Int64 | ID of pet to return
# Find pet by ID
try {
$Result = Get-PSPetById -PetId $PetId
$Result = Get-PSPetById -PetId $PetId
} catch {
Write-Host ("Exception occured when calling Get-PSPetById: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
@@ -238,7 +240,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**PetId** | **Int64**| ID of pet to return |
**PetId** | **Int64**| ID of pet to return |
### Return type
@@ -269,11 +271,13 @@ $Configuration = Get-Configuration
# Configure OAuth2 access token for authorization: petstore_auth
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
$Pet = (Initialize-Pet -Id 123 -Category (Initialize-Category -Id 123 -Name "Name_example") -Name "Name_example" -PhotoUrls @("PhotoUrls_example") -Tags @((Initialize-Tag -Id 123 -Name "Name_example")) -Status "available") # Pet | Pet object that needs to be added to the store
$Category = Initialize-Category -Id 0 -Name "MyName"
$Tag = Initialize-Tag -Id 0 -Name "MyName"
$Pet = Initialize-Pet -Id 0 -Category $Category -Name "doggie" -PhotoUrls "MyPhotoUrls" -Tags $Tag -Status "available" # Pet | Pet object that needs to be added to the store
# Update an existing pet
try {
$Result = Update-PSPet -Pet $Pet
$Result = Update-PSPet -Pet $Pet
} catch {
Write-Host ("Exception occured when calling Update-PSPet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
@@ -284,7 +288,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**Pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
**Pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type
@@ -317,13 +321,13 @@ $Configuration = Get-Configuration
# Configure OAuth2 access token for authorization: petstore_auth
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
$PetId = 987 # Int64 | ID of pet that needs to be updated
$Name = "Name_example" # String | Updated name of the pet (optional)
$Status = "Status_example" # String | Updated status of the pet (optional)
$PetId = 789 # Int64 | ID of pet that needs to be updated
$Name = "MyName" # String | Updated name of the pet (optional)
$Status = "MyStatus" # String | Updated status of the pet (optional)
# Updates a pet in the store with form data
try {
$Result = Update-PSPetWithForm -PetId $PetId -Name $Name -Status $Status
$Result = Update-PSPetWithForm -PetId $PetId -Name $Name -Status $Status
} catch {
Write-Host ("Exception occured when calling Update-PSPetWithForm: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
@@ -334,9 +338,9 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**PetId** | **Int64**| ID of pet that needs to be updated |
**Name** | **String**| Updated name of the pet | [optional]
**Status** | **String**| Updated status of the pet | [optional]
**PetId** | **Int64**| ID of pet that needs to be updated |
**Name** | **String**| Updated name of the pet | [optional]
**Status** | **String**| Updated status of the pet | [optional]
### Return type
@@ -369,13 +373,13 @@ $Configuration = Get-Configuration
# Configure OAuth2 access token for authorization: petstore_auth
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
$PetId = 987 # Int64 | ID of pet to update
$AdditionalMetadata = "AdditionalMetadata_example" # String | Additional data to pass to server (optional)
$File = 987 # System.IO.FileInfo | file to upload (optional)
$PetId = 789 # Int64 | ID of pet to update
$AdditionalMetadata = "MyAdditionalMetadata" # String | Additional data to pass to server (optional)
$File = # System.IO.FileInfo | file to upload (optional)
# uploads an image
try {
$Result = Invoke-PSUploadFile -PetId $PetId -AdditionalMetadata $AdditionalMetadata -File $File
$Result = Invoke-PSUploadFile -PetId $PetId -AdditionalMetadata $AdditionalMetadata -File $File
} catch {
Write-Host ("Exception occured when calling Invoke-PSUploadFile: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
@@ -386,9 +390,9 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**PetId** | **Int64**| ID of pet to update |
**AdditionalMetadata** | **String**| Additional data to pass to server | [optional]
**File** | **System.IO.FileInfo****System.IO.FileInfo**| file to upload | [optional]
**PetId** | **Int64**| ID of pet to update |
**AdditionalMetadata** | **String**| Additional data to pass to server | [optional]
**File** | **System.IO.FileInfo****System.IO.FileInfo**| file to upload | [optional]
### Return type