William Cheng 457aff8496
[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
2020-03-19 15:53:11 +08:00

5.3 KiB

PSPetstore.PSPetstore/Api.PSStoreApi

All URIs are relative to http://petstore.swagger.io/v2

Method HTTP request Description
Invoke-PSDeleteOrder DELETE /store/order/{orderId} Delete purchase order by ID
Get-PSInventory GET /store/inventory Returns pet inventories by status
Get-PSOrderById GET /store/order/{orderId} Find purchase order by ID
Invoke-PSPlaceOrder POST /store/order Place an order for a pet

Invoke-PSDeleteOrder

void Invoke-PSDeleteOrder
        [-OrderId]

Delete purchase order by ID

For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors

Example

Import-Module -Name PSPetstore

$OrderId = "OrderId_example" # String | ID of the order that needs to be deleted (default to null)

# Delete purchase order by ID
try {
    Invoke-PSDeleteOrder -OrderId $OrderId
} catch {
    Write-Host ($_.ErrorDetails | ConvertFrom-Json)
    Write-Host ($_.Exception.Response.Headers | ConvertTo-Json)
}

Parameters

Name Type Description Notes
OrderId String ID of the order that needs to be deleted [default to null]

Return type

void (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

Get-PSInventory

{String, Int32} Get-PSInventory

Returns pet inventories by status

Returns a map of status codes to quantities

Example

Import-Module -Name PSPetstore

$Configuration = Get-PSPetstoreConfiguration
# Configure API key authorization: api_key
$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"


# Returns pet inventories by status
try {
    {String, Int32} $Result = Get-PSInventory
} catch {
    Write-Host ($_.ErrorDetails | ConvertFrom-Json)
    Write-Host ($_.Exception.Response.Headers | ConvertTo-Json)
}

Parameters

This endpoint does not need any parameter.

Return type

{String, Int32}

Authorization

api_key

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

Get-PSOrderById

Order Get-PSOrderById
        [-OrderId]

Find purchase order by ID

For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions

Example

Import-Module -Name PSPetstore

$OrderId = 987 # Int64 | ID of pet that needs to be fetched (default to null)

# Find purchase order by ID
try {
    Order $Result = Get-PSOrderById -OrderId $OrderId
} catch {
    Write-Host ($_.ErrorDetails | ConvertFrom-Json)
    Write-Host ($_.Exception.Response.Headers | ConvertTo-Json)
}

Parameters

Name Type Description Notes
OrderId Int64 ID of pet that needs to be fetched [default to null]

Return type

Order

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/xml, application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

Invoke-PSPlaceOrder

Order Invoke-PSPlaceOrder
        [-Order]

Place an order for a pet

Example

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

# Place an order for a pet
try {
    Order $Result = Invoke-PSPlaceOrder -Order $Order
} catch {
    Write-Host ($_.ErrorDetails | ConvertFrom-Json)
    Write-Host ($_.Exception.Response.Headers | ConvertTo-Json)
}

Parameters

Name Type Description Notes
Order Order order placed for purchasing the pet

Return type

Order

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/xml, application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]