forked from loafle/openapi-generator-original
[Python] Add echo_api test object serialization for multipart requests (#18176)
* [python] echo add test object serialization for multipart requests * [echo api] update samples * [echo api] update samples
This commit is contained in:
@@ -105,6 +105,83 @@ function Test-FormIntegerBooleanString {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
Test form parameter(s) for multipart schema
|
||||
|
||||
.DESCRIPTION
|
||||
|
||||
No description available.
|
||||
|
||||
.PARAMETER Marker
|
||||
No description available.
|
||||
|
||||
.PARAMETER WithHttpInfo
|
||||
|
||||
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
|
||||
|
||||
.OUTPUTS
|
||||
|
||||
String
|
||||
#>
|
||||
function Test-FormObjectMultipart {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
|
||||
[PSCustomObject]
|
||||
${Marker},
|
||||
[Switch]
|
||||
$WithHttpInfo
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: Test-FormObjectMultipart' | Write-Debug
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$LocalVarAccepts = @()
|
||||
$LocalVarContentTypes = @()
|
||||
$LocalVarQueryParameters = @{}
|
||||
$LocalVarHeaderParameters = @{}
|
||||
$LocalVarFormParameters = @{}
|
||||
$LocalVarPathParameters = @{}
|
||||
$LocalVarCookieParameters = @{}
|
||||
$LocalVarBodyParameter = $null
|
||||
|
||||
$Configuration = Get-Configuration
|
||||
# HTTP header 'Accept' (if needed)
|
||||
$LocalVarAccepts = @('text/plain')
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
$LocalVarContentTypes = @('multipart/form-data')
|
||||
|
||||
$LocalVarUri = '/form/object/multipart'
|
||||
|
||||
if (!$Marker) {
|
||||
throw "Error! The required parameter `Marker` missing when calling test_form_object_multipart."
|
||||
}
|
||||
$LocalVarFormParameters['marker'] = $Marker
|
||||
|
||||
$LocalVarResult = Invoke-ApiClient -Method 'POST' `
|
||||
-Uri $LocalVarUri `
|
||||
-Accepts $LocalVarAccepts `
|
||||
-ContentTypes $LocalVarContentTypes `
|
||||
-Body $LocalVarBodyParameter `
|
||||
-HeaderParameters $LocalVarHeaderParameters `
|
||||
-QueryParameters $LocalVarQueryParameters `
|
||||
-FormParameters $LocalVarFormParameters `
|
||||
-CookieParameters $LocalVarCookieParameters `
|
||||
-ReturnType "String" `
|
||||
-IsBodyNullable $false
|
||||
|
||||
if ($WithHttpInfo.IsPresent) {
|
||||
return $LocalVarResult
|
||||
} else {
|
||||
return $LocalVarResult["Response"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
Test form parameter(s) for oneOf schema
|
||||
|
||||
.DESCRIPTION
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
#
|
||||
# Echo Server API
|
||||
# Echo Server API
|
||||
# Version: 0.1.0
|
||||
# Contact: team@openapitools.org
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
No summary available.
|
||||
|
||||
.DESCRIPTION
|
||||
|
||||
No description available.
|
||||
|
||||
.PARAMETER Name
|
||||
No description available.
|
||||
.OUTPUTS
|
||||
|
||||
TestFormObjectMultipartRequestMarker<PSCustomObject>
|
||||
#>
|
||||
|
||||
function Initialize-TestFormObjectMultipartRequestMarker {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${Name}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Creating PSCustomObject: PSOpenAPITools => TestFormObjectMultipartRequestMarker' | Write-Debug
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
|
||||
$PSO = [PSCustomObject]@{
|
||||
"name" = ${Name}
|
||||
}
|
||||
|
||||
|
||||
return $PSO
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
Convert from JSON to TestFormObjectMultipartRequestMarker<PSCustomObject>
|
||||
|
||||
.DESCRIPTION
|
||||
|
||||
Convert from JSON to TestFormObjectMultipartRequestMarker<PSCustomObject>
|
||||
|
||||
.PARAMETER Json
|
||||
|
||||
Json object
|
||||
|
||||
.OUTPUTS
|
||||
|
||||
TestFormObjectMultipartRequestMarker<PSCustomObject>
|
||||
#>
|
||||
function ConvertFrom-JsonToTestFormObjectMultipartRequestMarker {
|
||||
Param(
|
||||
[AllowEmptyString()]
|
||||
[string]$Json
|
||||
)
|
||||
|
||||
Process {
|
||||
'Converting JSON to PSCustomObject: PSOpenAPITools => TestFormObjectMultipartRequestMarker' | Write-Debug
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$JsonParameters = ConvertFrom-Json -InputObject $Json
|
||||
|
||||
# check if Json contains properties not defined in TestFormObjectMultipartRequestMarker
|
||||
$AllProperties = ("name")
|
||||
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
|
||||
if (!($AllProperties.Contains($name))) {
|
||||
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
|
||||
}
|
||||
}
|
||||
|
||||
if (!([bool]($JsonParameters.PSobject.Properties.name -match "name"))) { #optional property not found
|
||||
$Name = $null
|
||||
} else {
|
||||
$Name = $JsonParameters.PSobject.Properties["name"].value
|
||||
}
|
||||
|
||||
$PSO = [PSCustomObject]@{
|
||||
"name" = ${Name}
|
||||
}
|
||||
|
||||
return $PSO
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user