@@ -80,9 +80,9 @@ public string Serialize(object obj)
80
80
}
81
81
}
82
82
83
- public T Deserialize < T > ( HttpResponseMessage response )
83
+ public async Task < T > Deserialize < T > ( HttpResponseMessage response )
84
84
{
85
- var result = ( T ) Deserialize ( response , typeof ( T ) ) ;
85
+ var result = ( T ) await Deserialize ( response , typeof ( T ) ) ;
86
86
return result ;
87
87
}
88
88
@@ -92,19 +92,19 @@ public T Deserialize<T>(HttpResponseMessage response)
92
92
/// <param name="response">The HTTP response.</param>
93
93
/// <param name="type">Object type.</param>
94
94
/// <returns>Object representation of the JSON string.</returns>
95
- internal object Deserialize ( HttpResponseMessage response , Type type )
95
+ internal async Task < object > Deserialize ( HttpResponseMessage response , Type type )
96
96
{
97
97
IList < string > headers = response . Headers . Select ( x => x . Key + "=" + x . Value ) . ToList ( ) ;
98
98
99
99
if ( type == typeof ( byte [ ] ) ) // return byte array
100
100
{
101
- return response . Content . ReadAsByteArrayAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
101
+ return await response . Content . ReadAsByteArrayAsync ( ) ;
102
102
}
103
103
104
104
// TODO: ? if (type.IsAssignableFrom(typeof(Stream)))
105
105
if ( type == typeof ( Stream ) )
106
106
{
107
- var bytes = response . Content . ReadAsByteArrayAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
107
+ var bytes = await response . Content . ReadAsByteArrayAsync ( ) ;
108
108
if ( headers != null )
109
109
{
110
110
var filePath = String . IsNullOrEmpty ( _configuration . TempFolderPath )
@@ -128,18 +128,18 @@ internal object Deserialize(HttpResponseMessage response, Type type)
128
128
129
129
if ( type . Name . StartsWith ( "System.Nullable`1[[System.DateTime" ) ) // return a datetime object
130
130
{
131
- return DateTime . Parse ( response . Content . ReadAsStringAsync ( ) . GetAwaiter ( ) . GetResult ( ) , null , System . Globalization . DateTimeStyles . RoundtripKind ) ;
131
+ return DateTime . Parse ( await response . Content . ReadAsStringAsync ( ) , null , System . Globalization . DateTimeStyles . RoundtripKind ) ;
132
132
}
133
133
134
134
if ( type == typeof ( String ) || type . Name . StartsWith ( "System.Nullable" ) ) // return primitive type
135
135
{
136
- return Convert . ChangeType ( response . Content . ReadAsStringAsync ( ) . GetAwaiter ( ) . GetResult ( ) , type ) ;
136
+ return Convert . ChangeType ( await response . Content . ReadAsStringAsync ( ) , type ) ;
137
137
}
138
138
139
139
// at this point, it must be a model (json)
140
140
try
141
141
{
142
- return JsonConvert . DeserializeObject ( response . Content . ReadAsStringAsync ( ) . GetAwaiter ( ) . GetResult ( ) , type , _serializerSettings ) ;
142
+ return JsonConvert . DeserializeObject ( await response . Content . ReadAsStringAsync ( ) , type , _serializerSettings ) ;
143
143
}
144
144
catch ( Exception e )
145
145
{
@@ -504,7 +504,7 @@ private async Task<ApiResponse<T>> ExecAsync<T>(HttpRequestMessage req,
504
504
return await ToApiResponse < T > ( response , default ( T ) , req . RequestUri ) ;
505
505
}
506
506
507
- object responseData = deserializer . Deserialize < T > ( response ) ;
507
+ object responseData = await deserializer . Deserialize < T > ( response ) ;
508
508
509
509
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
510
510
if ( typeof ( Org . OpenAPITools . Model . AbstractOpenAPISchema ) . IsAssignableFrom ( typeof ( T ) ) )
0 commit comments