Compare commits

..

2 Commits

14 changed files with 320 additions and 257 deletions

View File

@@ -585,7 +585,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
List<CodegenProperty> allOf = composedSchemas.getAllOf();
if (allOf != null) {
for (CodegenProperty property : allOf) {
property.name = patchPropertyName(model, property.baseType);
property.name = patchPropertyName(model, camelize(property.baseType));
patchPropertyVendorExtensions(property);
}
}
@@ -594,7 +594,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
if (anyOf != null) {
removePropertiesDeclaredInComposedTypes(objs, model, anyOf);
for (CodegenProperty property : anyOf) {
property.name = patchPropertyName(model, property.baseType);
property.name = patchPropertyName(model, camelize(property.baseType));
property.isNullable = true;
patchPropertyVendorExtensions(property);
}
@@ -604,7 +604,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
if (oneOf != null) {
removePropertiesDeclaredInComposedTypes(objs, model, oneOf);
for (CodegenProperty property : oneOf) {
property.name = patchPropertyName(model, property.baseType);
property.name = patchPropertyName(model, camelize(property.baseType));
property.isNullable = true;
patchPropertyVendorExtensions(property);
}

View File

@@ -36,10 +36,7 @@ function Invoke-{{{apiNamePrefix}}}ApiClient {
$Configuration = Get-{{{apiNamePrefix}}}Configuration
$RequestUri = $Configuration["BaseUrl"] + $Uri
$DefaultHeaders = $Configuration["DefaultHeaders"]
# should make sure that SkipCertificateCheck is not set for PowerShell 5
$SkipCertificateCheck = $Configuration["SkipCertificateCheck"]
$Proxy = $Configuration["Proxy"]
# cookie parameters
foreach ($Parameter in $CookieParameters.GetEnumerator()) {
@@ -59,17 +56,19 @@ function Invoke-{{{apiNamePrefix}}}ApiClient {
$HeaderParameters['Accept'] = $Accept
}
# Content-Type and multipart handling
$ContentType = SelectHeaders -Headers $ContentTypes
[string]$MultiPartBoundary = $null
$ContentType= SelectHeaders -Headers $ContentTypes
if ($ContentType) {
$HeaderParameters['Content-Type'] = $ContentType
if ($ContentType -eq 'multipart/form-data') {
$MultiPart = $true
[string]$MultiPartBoundary = [System.Guid]::NewGuid()
$MultiPartBoundary = "---------------------------$MultiPartBoundary"
$HeaderParameters['Content-Type'] = "$ContentType; boundary=$MultiPartBoundary"
}
}
# add default headers if any
foreach ($header in $DefaultHeaders.GetEnumerator()) {
foreach ($header in $Configuration["DefaultHeaders"].GetEnumerator()) {
$HeaderParameters[$header.Name] = $header.Value
}
@@ -90,7 +89,30 @@ function Invoke-{{{apiNamePrefix}}}ApiClient {
# include form parameters in the request body
if ($FormParameters -and $FormParameters.Count -gt 0) {
$RequestBody = $FormParameters
if (![string]::IsNullOrEmpty($MultiPartBoundary)) {
$RequestBody = ""
$LF = "`r`n"
$FormParameters.Keys | ForEach-Object {
$value = $FormParameters[$_]
$isFile = $value.GetType().FullName -eq "System.IO.FileInfo"
$RequestBody += "--$MultiPartBoundary$LF"
$RequestBody += "Content-Disposition: form-data; name=`"$_`""
if ($isFile) {
$fileName = $value.Name
$RequestBody += "; filename=`"$fileName`"$LF"
$RequestBody += "Content-Type: application/octet-stream$LF$LF"
$RequestBody += Get-Content -Path $value.FullName
} else {
$RequestBody += "$LF$LF"
$RequestBody += ([string]$value)
}
$RequestBody += "$LF--$MultiPartBoundary"
}
$RequestBody += "--"
} else {
$RequestBody = $FormParameters
}
}
if ($Body -or $IsBodyNullable) {
@@ -119,55 +141,54 @@ function Invoke-{{{apiNamePrefix}}}ApiClient {
}
{{/hasHttpSignatureMethods}}
# use splatting to pass parameters
$Params = @{}
$Params.Uri = $UriBuilder.Uri
$Params.Method = $Method
$Params.Headers = $HeaderParameters
$Params.ErrorAction = 'Stop'
if ($SkipCertificateCheck -eq $true) {
$Params.SkipCertificateCheck = $true
}
if ($null -ne $Proxy) {
$effectiveProxy = $Proxy.GetProxy($UriBuilder.Uri)
# do not set proxy if it is null or same as target Uri
if ($null -ne $effectiveProxy -and $effectiveProxy.AbsoluteUri -ne $UriBuilder.Uri) {
$Params.Proxy = $effectiveProxy.AbsoluteUri
$Params.ProxyUseDefaultCredentials = $true
}
}
# use Invoke-RestApi if Content-Type is 'multipart/form-data', Invoke-WebRequest otherwise
if ($MultiPart) {
if ($PSVersionTable.PSVersion.Major -eq 5) {
# preset null return values as not supported by Invoke-RestMethod on PS5
$ResponseHeaders = $null
$ResponseStatusCode = $null
if ($null -eq $Configuration["Proxy"]) {
# skip certification check, no proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-SkipCertificateCheck
} else {
# preset return variables
$Params.ResponseHeadersVariable = "ResponseHeaders"
$Params.StatusCodeVariable = "ResponseStatusCode"
# skip certification check, use proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-SkipCertificateCheck `
-Proxy $Configuration["Proxy"].GetProxy($UriBuilder.Uri) `
-ProxyUseDefaultCredentials
}
$Params.Form = $FormParameters
$Response = Invoke-RestMethod @Params
} else {
if ($null -eq $Configuration["Proxy"]) {
# perform certification check, no proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing
} else {
# perform certification check, use proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-Proxy $Configuration["Proxy"].GetProxy($UriBuilder.Uri) `
-ProxyUseDefaultCredentials
}
}
return @{
Response = $Response
StatusCode = $ResponseStatusCode
Headers = $ResponseHeaders
}
} else {
$Params.Body = $RequestBody
$Params.UseBasicParsing = $true
$Response = Invoke-WebRequest @Params
return @{
Response = DeserializeResponse -Response $Response.Content -ReturnType $ReturnType -ContentTypes $Response.Headers["Content-Type"]
StatusCode = $Response.StatusCode
Headers = $Response.Headers
}
return @{
Response = DeserializeResponse -Response $Response.Content -ReturnType $ReturnType -ContentTypes $Response.Headers["Content-Type"]
StatusCode = $Response.StatusCode
Headers = $Response.Headers
}
}

View File

@@ -43,10 +43,7 @@ function Invoke-ApiClient {
$Configuration = Get-Configuration
$RequestUri = $Configuration["BaseUrl"] + $Uri
$DefaultHeaders = $Configuration["DefaultHeaders"]
# should make sure that SkipCertificateCheck is not set for PowerShell 5
$SkipCertificateCheck = $Configuration["SkipCertificateCheck"]
$Proxy = $Configuration["Proxy"]
# cookie parameters
foreach ($Parameter in $CookieParameters.GetEnumerator()) {
@@ -66,17 +63,19 @@ function Invoke-ApiClient {
$HeaderParameters['Accept'] = $Accept
}
# Content-Type and multipart handling
$ContentType = SelectHeaders -Headers $ContentTypes
[string]$MultiPartBoundary = $null
$ContentType= SelectHeaders -Headers $ContentTypes
if ($ContentType) {
$HeaderParameters['Content-Type'] = $ContentType
if ($ContentType -eq 'multipart/form-data') {
$MultiPart = $true
[string]$MultiPartBoundary = [System.Guid]::NewGuid()
$MultiPartBoundary = "---------------------------$MultiPartBoundary"
$HeaderParameters['Content-Type'] = "$ContentType; boundary=$MultiPartBoundary"
}
}
# add default headers if any
foreach ($header in $DefaultHeaders.GetEnumerator()) {
foreach ($header in $Configuration["DefaultHeaders"].GetEnumerator()) {
$HeaderParameters[$header.Name] = $header.Value
}
@@ -97,7 +96,30 @@ function Invoke-ApiClient {
# include form parameters in the request body
if ($FormParameters -and $FormParameters.Count -gt 0) {
$RequestBody = $FormParameters
if (![string]::IsNullOrEmpty($MultiPartBoundary)) {
$RequestBody = ""
$LF = "`r`n"
$FormParameters.Keys | ForEach-Object {
$value = $FormParameters[$_]
$isFile = $value.GetType().FullName -eq "System.IO.FileInfo"
$RequestBody += "--$MultiPartBoundary$LF"
$RequestBody += "Content-Disposition: form-data; name=`"$_`""
if ($isFile) {
$fileName = $value.Name
$RequestBody += "; filename=`"$fileName`"$LF"
$RequestBody += "Content-Type: application/octet-stream$LF$LF"
$RequestBody += Get-Content -Path $value.FullName
} else {
$RequestBody += "$LF$LF"
$RequestBody += ([string]$value)
}
$RequestBody += "$LF--$MultiPartBoundary"
}
$RequestBody += "--"
} else {
$RequestBody = $FormParameters
}
}
if ($Body -or $IsBodyNullable) {
@@ -107,55 +129,54 @@ function Invoke-ApiClient {
}
}
# use splatting to pass parameters
$Params = @{}
$Params.Uri = $UriBuilder.Uri
$Params.Method = $Method
$Params.Headers = $HeaderParameters
$Params.ErrorAction = 'Stop'
if ($SkipCertificateCheck -eq $true) {
$Params.SkipCertificateCheck = $true
}
if ($null -ne $Proxy) {
$effectiveProxy = $Proxy.GetProxy($UriBuilder.Uri)
# do not set proxy if it is null or same as target Uri
if ($null -ne $effectiveProxy -and $effectiveProxy.AbsoluteUri -ne $UriBuilder.Uri) {
$Params.Proxy = $effectiveProxy.AbsoluteUri
$Params.ProxyUseDefaultCredentials = $true
}
}
# use Invoke-RestApi if Content-Type is 'multipart/form-data', Invoke-WebRequest otherwise
if ($MultiPart) {
if ($PSVersionTable.PSVersion.Major -eq 5) {
# preset null return values as not supported by Invoke-RestMethod on PS5
$ResponseHeaders = $null
$ResponseStatusCode = $null
if ($null -eq $Configuration["Proxy"]) {
# skip certification check, no proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-SkipCertificateCheck
} else {
# preset return variables
$Params.ResponseHeadersVariable = "ResponseHeaders"
$Params.StatusCodeVariable = "ResponseStatusCode"
# skip certification check, use proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-SkipCertificateCheck `
-Proxy $Configuration["Proxy"].GetProxy($UriBuilder.Uri) `
-ProxyUseDefaultCredentials
}
$Params.Form = $FormParameters
$Response = Invoke-RestMethod @Params
} else {
if ($null -eq $Configuration["Proxy"]) {
# perform certification check, no proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing
} else {
# perform certification check, use proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-Proxy $Configuration["Proxy"].GetProxy($UriBuilder.Uri) `
-ProxyUseDefaultCredentials
}
}
return @{
Response = $Response
StatusCode = $ResponseStatusCode
Headers = $ResponseHeaders
}
} else {
$Params.Body = $RequestBody
$Params.UseBasicParsing = $true
$Response = Invoke-WebRequest @Params
return @{
Response = DeserializeResponse -Response $Response.Content -ReturnType $ReturnType -ContentTypes $Response.Headers["Content-Type"]
StatusCode = $Response.StatusCode
Headers = $Response.Headers
}
return @{
Response = DeserializeResponse -Response $Response.Content -ReturnType $ReturnType -ContentTypes $Response.Headers["Content-Type"]
StatusCode = $Response.StatusCode
Headers = $Response.Headers
}
}

View File

@@ -32,19 +32,19 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="OneOfString" /> class.
/// </summary>
/// <param name="varString"></param>
internal OneOfString(string varString)
/// <param name="string"></param>
internal OneOfString(string @string)
{
VarString = varString;
String = @string;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Gets or Sets VarString
/// Gets or Sets String
/// </summary>
public string VarString { get; set; }
public string String { get; set; }
/// <summary>
/// Gets or Sets additional properties

View File

@@ -32,20 +32,20 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class.
/// </summary>
/// <param name="varBool"></param>
internal PolymorphicProperty(bool varBool)
/// <param name="bool"></param>
internal PolymorphicProperty(bool @bool)
{
VarBool = varBool;
Bool = @bool;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class.
/// </summary>
/// <param name="varString"></param>
internal PolymorphicProperty(string varString)
/// <param name="string"></param>
internal PolymorphicProperty(string @string)
{
VarString = varString;
String = @string;
OnCreated();
}
@@ -72,14 +72,14 @@ namespace Org.OpenAPITools.Model
partial void OnCreated();
/// <summary>
/// Gets or Sets VarBool
/// Gets or Sets Bool
/// </summary>
public bool? VarBool { get; set; }
public bool? Bool { get; set; }
/// <summary>
/// Gets or Sets VarString
/// Gets or Sets String
/// </summary>
public string VarString { get; set; }
public string String { get; set; }
/// <summary>
/// Gets or Sets Object
@@ -159,11 +159,11 @@ namespace Org.OpenAPITools.Model
if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1)
{
Utf8JsonReader utf8JsonReaderVarBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderVarBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderVarString = utf8JsonReader;
ClientUtils.TryDeserialize<string>(ref utf8JsonReaderVarString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderString = utf8JsonReader;
ClientUtils.TryDeserialize<string>(ref utf8JsonReaderString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderObject = utf8JsonReader;
ClientUtils.TryDeserialize<Object>(ref utf8JsonReaderObject, jsonSerializerOptions, out varObject);

View File

@@ -34,19 +34,19 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="OneOfString" /> class.
/// </summary>
/// <param name="varString"></param>
internal OneOfString(string varString)
/// <param name="string"></param>
internal OneOfString(string @string)
{
VarString = varString;
String = @string;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Gets or Sets VarString
/// Gets or Sets String
/// </summary>
public string? VarString { get; set; }
public string? String { get; set; }
/// <summary>
/// Gets or Sets additional properties

View File

@@ -34,20 +34,20 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class.
/// </summary>
/// <param name="varBool"></param>
internal PolymorphicProperty(bool varBool)
/// <param name="bool"></param>
internal PolymorphicProperty(bool @bool)
{
VarBool = varBool;
Bool = @bool;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class.
/// </summary>
/// <param name="varString"></param>
internal PolymorphicProperty(string varString)
/// <param name="string"></param>
internal PolymorphicProperty(string @string)
{
VarString = varString;
String = @string;
OnCreated();
}
@@ -74,14 +74,14 @@ namespace Org.OpenAPITools.Model
partial void OnCreated();
/// <summary>
/// Gets or Sets VarBool
/// Gets or Sets Bool
/// </summary>
public bool? VarBool { get; set; }
public bool? Bool { get; set; }
/// <summary>
/// Gets or Sets VarString
/// Gets or Sets String
/// </summary>
public string? VarString { get; set; }
public string? String { get; set; }
/// <summary>
/// Gets or Sets Object
@@ -161,11 +161,11 @@ namespace Org.OpenAPITools.Model
if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1)
{
Utf8JsonReader utf8JsonReaderVarBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderVarBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderVarString = utf8JsonReader;
ClientUtils.TryDeserialize<string?>(ref utf8JsonReaderVarString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderString = utf8JsonReader;
ClientUtils.TryDeserialize<string?>(ref utf8JsonReaderString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderObject = utf8JsonReader;
ClientUtils.TryDeserialize<Object?>(ref utf8JsonReaderObject, jsonSerializerOptions, out varObject);

View File

@@ -32,19 +32,19 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="OneOfString" /> class.
/// </summary>
/// <param name="varString"></param>
internal OneOfString(string varString)
/// <param name="string"></param>
internal OneOfString(string @string)
{
VarString = varString;
String = @string;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Gets or Sets VarString
/// Gets or Sets String
/// </summary>
public string VarString { get; set; }
public string String { get; set; }
/// <summary>
/// Gets or Sets additional properties

View File

@@ -32,20 +32,20 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class.
/// </summary>
/// <param name="varBool"></param>
internal PolymorphicProperty(bool varBool)
/// <param name="bool"></param>
internal PolymorphicProperty(bool @bool)
{
VarBool = varBool;
Bool = @bool;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class.
/// </summary>
/// <param name="varString"></param>
internal PolymorphicProperty(string varString)
/// <param name="string"></param>
internal PolymorphicProperty(string @string)
{
VarString = varString;
String = @string;
OnCreated();
}
@@ -72,14 +72,14 @@ namespace Org.OpenAPITools.Model
partial void OnCreated();
/// <summary>
/// Gets or Sets VarBool
/// Gets or Sets Bool
/// </summary>
public bool? VarBool { get; set; }
public bool? Bool { get; set; }
/// <summary>
/// Gets or Sets VarString
/// Gets or Sets String
/// </summary>
public string VarString { get; set; }
public string String { get; set; }
/// <summary>
/// Gets or Sets Object
@@ -159,11 +159,11 @@ namespace Org.OpenAPITools.Model
if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1)
{
Utf8JsonReader utf8JsonReaderVarBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderVarBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderVarString = utf8JsonReader;
ClientUtils.TryDeserialize<string>(ref utf8JsonReaderVarString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderString = utf8JsonReader;
ClientUtils.TryDeserialize<string>(ref utf8JsonReaderString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderObject = utf8JsonReader;
ClientUtils.TryDeserialize<Object>(ref utf8JsonReaderObject, jsonSerializerOptions, out varObject);

View File

@@ -35,19 +35,19 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="OneOfString" /> class.
/// </summary>
/// <param name="varString"></param>
internal OneOfString(string varString)
/// <param name="string"></param>
internal OneOfString(string @string)
{
VarString = varString;
String = @string;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Gets or Sets VarString
/// Gets or Sets String
/// </summary>
public string? VarString { get; set; }
public string? String { get; set; }
/// <summary>
/// Gets or Sets additional properties

View File

@@ -35,20 +35,20 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class.
/// </summary>
/// <param name="varBool"></param>
internal PolymorphicProperty(bool varBool)
/// <param name="bool"></param>
internal PolymorphicProperty(bool @bool)
{
VarBool = varBool;
Bool = @bool;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class.
/// </summary>
/// <param name="varString"></param>
internal PolymorphicProperty(string varString)
/// <param name="string"></param>
internal PolymorphicProperty(string @string)
{
VarString = varString;
String = @string;
OnCreated();
}
@@ -75,14 +75,14 @@ namespace Org.OpenAPITools.Model
partial void OnCreated();
/// <summary>
/// Gets or Sets VarBool
/// Gets or Sets Bool
/// </summary>
public bool? VarBool { get; set; }
public bool? Bool { get; set; }
/// <summary>
/// Gets or Sets VarString
/// Gets or Sets String
/// </summary>
public string? VarString { get; set; }
public string? String { get; set; }
/// <summary>
/// Gets or Sets Object
@@ -162,11 +162,11 @@ namespace Org.OpenAPITools.Model
if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1)
{
Utf8JsonReader utf8JsonReaderVarBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderVarBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderVarString = utf8JsonReader;
ClientUtils.TryDeserialize<string?>(ref utf8JsonReaderVarString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderString = utf8JsonReader;
ClientUtils.TryDeserialize<string?>(ref utf8JsonReaderString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderObject = utf8JsonReader;
ClientUtils.TryDeserialize<Object?>(ref utf8JsonReaderObject, jsonSerializerOptions, out varObject);

View File

@@ -32,19 +32,19 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="OneOfString" /> class.
/// </summary>
/// <param name="varString"></param>
internal OneOfString(string varString)
/// <param name="string"></param>
internal OneOfString(string @string)
{
VarString = varString;
String = @string;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Gets or Sets VarString
/// Gets or Sets String
/// </summary>
public string VarString { get; set; }
public string String { get; set; }
/// <summary>
/// Gets or Sets additional properties

View File

@@ -32,20 +32,20 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class.
/// </summary>
/// <param name="varBool"></param>
internal PolymorphicProperty(bool varBool)
/// <param name="bool"></param>
internal PolymorphicProperty(bool @bool)
{
VarBool = varBool;
Bool = @bool;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class.
/// </summary>
/// <param name="varString"></param>
internal PolymorphicProperty(string varString)
/// <param name="string"></param>
internal PolymorphicProperty(string @string)
{
VarString = varString;
String = @string;
OnCreated();
}
@@ -72,14 +72,14 @@ namespace Org.OpenAPITools.Model
partial void OnCreated();
/// <summary>
/// Gets or Sets VarBool
/// Gets or Sets Bool
/// </summary>
public bool? VarBool { get; set; }
public bool? Bool { get; set; }
/// <summary>
/// Gets or Sets VarString
/// Gets or Sets String
/// </summary>
public string VarString { get; set; }
public string String { get; set; }
/// <summary>
/// Gets or Sets Object
@@ -159,11 +159,11 @@ namespace Org.OpenAPITools.Model
if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1)
{
Utf8JsonReader utf8JsonReaderVarBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderVarBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderVarString = utf8JsonReader;
ClientUtils.TryDeserialize<string>(ref utf8JsonReaderVarString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderString = utf8JsonReader;
ClientUtils.TryDeserialize<string>(ref utf8JsonReaderString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderObject = utf8JsonReader;
ClientUtils.TryDeserialize<Object>(ref utf8JsonReaderObject, jsonSerializerOptions, out varObject);

View File

@@ -42,10 +42,7 @@ function Invoke-PSApiClient {
$Configuration = Get-PSConfiguration
$RequestUri = $Configuration["BaseUrl"] + $Uri
$DefaultHeaders = $Configuration["DefaultHeaders"]
# should make sure that SkipCertificateCheck is not set for PowerShell 5
$SkipCertificateCheck = $Configuration["SkipCertificateCheck"]
$Proxy = $Configuration["Proxy"]
# cookie parameters
foreach ($Parameter in $CookieParameters.GetEnumerator()) {
@@ -65,17 +62,19 @@ function Invoke-PSApiClient {
$HeaderParameters['Accept'] = $Accept
}
# Content-Type and multipart handling
$ContentType = SelectHeaders -Headers $ContentTypes
[string]$MultiPartBoundary = $null
$ContentType= SelectHeaders -Headers $ContentTypes
if ($ContentType) {
$HeaderParameters['Content-Type'] = $ContentType
if ($ContentType -eq 'multipart/form-data') {
$MultiPart = $true
[string]$MultiPartBoundary = [System.Guid]::NewGuid()
$MultiPartBoundary = "---------------------------$MultiPartBoundary"
$HeaderParameters['Content-Type'] = "$ContentType; boundary=$MultiPartBoundary"
}
}
# add default headers if any
foreach ($header in $DefaultHeaders.GetEnumerator()) {
foreach ($header in $Configuration["DefaultHeaders"].GetEnumerator()) {
$HeaderParameters[$header.Name] = $header.Value
}
@@ -96,7 +95,30 @@ function Invoke-PSApiClient {
# include form parameters in the request body
if ($FormParameters -and $FormParameters.Count -gt 0) {
$RequestBody = $FormParameters
if (![string]::IsNullOrEmpty($MultiPartBoundary)) {
$RequestBody = ""
$LF = "`r`n"
$FormParameters.Keys | ForEach-Object {
$value = $FormParameters[$_]
$isFile = $value.GetType().FullName -eq "System.IO.FileInfo"
$RequestBody += "--$MultiPartBoundary$LF"
$RequestBody += "Content-Disposition: form-data; name=`"$_`""
if ($isFile) {
$fileName = $value.Name
$RequestBody += "; filename=`"$fileName`"$LF"
$RequestBody += "Content-Type: application/octet-stream$LF$LF"
$RequestBody += Get-Content -Path $value.FullName
} else {
$RequestBody += "$LF$LF"
$RequestBody += ([string]$value)
}
$RequestBody += "$LF--$MultiPartBoundary"
}
$RequestBody += "--"
} else {
$RequestBody = $FormParameters
}
}
if ($Body -or $IsBodyNullable) {
@@ -123,55 +145,54 @@ function Invoke-PSApiClient {
}
}
# use splatting to pass parameters
$Params = @{}
$Params.Uri = $UriBuilder.Uri
$Params.Method = $Method
$Params.Headers = $HeaderParameters
$Params.ErrorAction = 'Stop'
if ($SkipCertificateCheck -eq $true) {
$Params.SkipCertificateCheck = $true
}
if ($null -ne $Proxy) {
$effectiveProxy = $Proxy.GetProxy($UriBuilder.Uri)
# do not set proxy if it is null or same as target Uri
if ($null -ne $effectiveProxy -and $effectiveProxy.AbsoluteUri -ne $UriBuilder.Uri) {
$Params.Proxy = $effectiveProxy.AbsoluteUri
$Params.ProxyUseDefaultCredentials = $true
}
}
# use Invoke-RestApi if Content-Type is 'multipart/form-data', Invoke-WebRequest otherwise
if ($MultiPart) {
if ($PSVersionTable.PSVersion.Major -eq 5) {
# preset null return values as not supported by Invoke-RestMethod on PS5
$ResponseHeaders = $null
$ResponseStatusCode = $null
if ($null -eq $Configuration["Proxy"]) {
# skip certification check, no proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-SkipCertificateCheck
} else {
# preset return variables
$Params.ResponseHeadersVariable = "ResponseHeaders"
$Params.StatusCodeVariable = "ResponseStatusCode"
# skip certification check, use proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-SkipCertificateCheck `
-Proxy $Configuration["Proxy"].GetProxy($UriBuilder.Uri) `
-ProxyUseDefaultCredentials
}
$Params.Form = $FormParameters
$Response = Invoke-RestMethod @Params
} else {
if ($null -eq $Configuration["Proxy"]) {
# perform certification check, no proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing
} else {
# perform certification check, use proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-Proxy $Configuration["Proxy"].GetProxy($UriBuilder.Uri) `
-ProxyUseDefaultCredentials
}
}
return @{
Response = $Response
StatusCode = $ResponseStatusCode
Headers = $ResponseHeaders
}
} else {
$Params.Body = $RequestBody
$Params.UseBasicParsing = $true
$Response = Invoke-WebRequest @Params
return @{
Response = DeserializeResponse -Response $Response.Content -ReturnType $ReturnType -ContentTypes $Response.Headers["Content-Type"]
StatusCode = $Response.StatusCode
Headers = $Response.Headers
}
return @{
Response = DeserializeResponse -Response $Response.Content -ReturnType $ReturnType -ContentTypes $Response.Headers["Content-Type"]
StatusCode = $Response.StatusCode
Headers = $Response.Headers
}
}