Skip to content

Commit 2c463d9

Browse files
committed
update C# samples
1 parent 5cffc45 commit 2c463d9

File tree

51 files changed

+699
-327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+699
-327
lines changed

samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
using System;
1414
using System.Collections.Generic;
15+
using System.Collections.ObjectModel;
1516
using System.Net;
17+
using System.IO;
1618
using System.Threading.Tasks;
1719
using Microsoft.Extensions.Logging;
1820
using System.Net.Http;
@@ -247,10 +249,10 @@ public async Task<IListApiResponse> ListAsync(string personId, System.Threading.
247249
"application/json"
248250
};
249251

250-
string? acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars);
252+
IEnumerable<MediaTypeWithQualityHeaderValue> acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars);
251253

252-
if (acceptLocalVar != null)
253-
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
254+
foreach (var acceptLocalVar in acceptHeaderValuesLocalVar)
255+
httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar);
254256

255257
httpRequestMessageLocalVar.Method = HttpMethod.Get;
256258

samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public partial interface IApiResponse
5252
/// </summary>
5353
System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
5454

55+
/// <summary>
56+
/// The headers contained in the api response related to the content
57+
/// </summary>
58+
System.Net.Http.Headers.HttpContentHeaders ContentHeaders { get; }
59+
5560
/// <summary>
5661
/// The path used when making the request.
5762
/// </summary>
@@ -109,6 +114,11 @@ public partial class ApiResponse : IApiResponse
109114
/// </summary>
110115
public System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
111116

117+
/// <summary>
118+
/// The headers contained in the api response related to the content
119+
/// </summary>
120+
public System.Net.Http.Headers.HttpContentHeaders ContentHeaders { get; }
121+
112122
/// <summary>
113123
/// The DateTime when the request was retrieved.
114124
/// </summary>
@@ -147,6 +157,7 @@ public ApiResponse(global::System.Net.Http.HttpRequestMessage httpRequestMessage
147157
{
148158
StatusCode = httpResponseMessage.StatusCode;
149159
Headers = httpResponseMessage.Headers;
160+
ContentHeaders = httpResponseMessage.Content.Headers;
150161
IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode;
151162
ReasonPhrase = httpResponseMessage.ReasonPhrase;
152163
RawContent = rawContent;
@@ -170,6 +181,7 @@ public ApiResponse(global::System.Net.Http.HttpRequestMessage httpRequestMessage
170181
{
171182
StatusCode = httpResponseMessage.StatusCode;
172183
Headers = httpResponseMessage.Headers;
184+
ContentHeaders = httpResponseMessage.Content.Headers;
173185
IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode;
174186
ReasonPhrase = httpResponseMessage.ReasonPhrase;
175187
ContentStream = contentStream;
@@ -181,6 +193,7 @@ public ApiResponse(global::System.Net.Http.HttpRequestMessage httpRequestMessage
181193
OnCreated(httpRequestMessage, httpResponseMessage);
182194
}
183195

196+
184197
partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
185198
}
186199

samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using KellermanSoftware.CompareNetObjects;
2121
using Org.OpenAPITools.Model;
2222
using System.Runtime.CompilerServices;
23+
using System.Net.Http.Headers;
2324

2425
[assembly: InternalsVisibleTo("Org.OpenAPITools.Test")]
2526

@@ -235,6 +236,26 @@ public static byte[] ReadAsBytes(Stream inputStream)
235236
return string.Join(",", accepts);
236237
}
237238

239+
240+
241+
/// <summary>
242+
/// Select the Accept header's value from the given accepts array:
243+
/// if JSON exists in the given array, use it;
244+
/// otherwise use all of them.
245+
/// </summary>
246+
/// <param name="accepts">The accepts array to select from.</param>
247+
/// <returns>The Accept header values to use.</returns>
248+
public static IEnumerable<MediaTypeWithQualityHeaderValue> SelectHeaderAcceptArray(string[] accepts)
249+
{
250+
if (accepts.Length == 0)
251+
return [];
252+
253+
if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase))
254+
return [MediaTypeWithQualityHeaderValue.Parse("application/json")];
255+
256+
return accepts.Select(MediaTypeWithQualityHeaderValue.Parse);
257+
}
258+
238259
/// <summary>
239260
/// Provides a case-insensitive check that a provided content type is a known JSON-like content type.
240261
/// </summary>

samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
using System;
1414
using System.Collections.Generic;
15+
using System.Collections.ObjectModel;
1516
using System.Net;
17+
using System.IO;
1618
using System.Threading.Tasks;
1719
using Microsoft.Extensions.Logging;
1820
using System.Net.Http;
@@ -221,10 +223,10 @@ public async Task<IRootGetApiResponse> RootGetAsync(System.Threading.Cancellatio
221223
"application/json"
222224
};
223225

224-
string? acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars);
226+
IEnumerable<MediaTypeWithQualityHeaderValue> acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars);
225227

226-
if (acceptLocalVar != null)
227-
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
228+
foreach (var acceptLocalVar in acceptHeaderValuesLocalVar)
229+
httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar);
228230

229231
httpRequestMessageLocalVar.Method = HttpMethod.Get;
230232

samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public partial interface IApiResponse
5252
/// </summary>
5353
System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
5454

55+
/// <summary>
56+
/// The headers contained in the api response related to the content
57+
/// </summary>
58+
System.Net.Http.Headers.HttpContentHeaders ContentHeaders { get; }
59+
5560
/// <summary>
5661
/// The path used when making the request.
5762
/// </summary>
@@ -109,6 +114,11 @@ public partial class ApiResponse : IApiResponse
109114
/// </summary>
110115
public System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
111116

117+
/// <summary>
118+
/// The headers contained in the api response related to the content
119+
/// </summary>
120+
public System.Net.Http.Headers.HttpContentHeaders ContentHeaders { get; }
121+
112122
/// <summary>
113123
/// The DateTime when the request was retrieved.
114124
/// </summary>
@@ -147,6 +157,7 @@ public ApiResponse(global::System.Net.Http.HttpRequestMessage httpRequestMessage
147157
{
148158
StatusCode = httpResponseMessage.StatusCode;
149159
Headers = httpResponseMessage.Headers;
160+
ContentHeaders = httpResponseMessage.Content.Headers;
150161
IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode;
151162
ReasonPhrase = httpResponseMessage.ReasonPhrase;
152163
RawContent = rawContent;
@@ -170,6 +181,7 @@ public ApiResponse(global::System.Net.Http.HttpRequestMessage httpRequestMessage
170181
{
171182
StatusCode = httpResponseMessage.StatusCode;
172183
Headers = httpResponseMessage.Headers;
184+
ContentHeaders = httpResponseMessage.Content.Headers;
173185
IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode;
174186
ReasonPhrase = httpResponseMessage.ReasonPhrase;
175187
ContentStream = contentStream;
@@ -181,6 +193,7 @@ public ApiResponse(global::System.Net.Http.HttpRequestMessage httpRequestMessage
181193
OnCreated(httpRequestMessage, httpResponseMessage);
182194
}
183195

196+
184197
partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
185198
}
186199

samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using KellermanSoftware.CompareNetObjects;
2121
using Org.OpenAPITools.Model;
2222
using System.Runtime.CompilerServices;
23+
using System.Net.Http.Headers;
2324

2425
[assembly: InternalsVisibleTo("Org.OpenAPITools.Test")]
2526

@@ -235,6 +236,26 @@ public static byte[] ReadAsBytes(Stream inputStream)
235236
return string.Join(",", accepts);
236237
}
237238

239+
240+
241+
/// <summary>
242+
/// Select the Accept header's value from the given accepts array:
243+
/// if JSON exists in the given array, use it;
244+
/// otherwise use all of them.
245+
/// </summary>
246+
/// <param name="accepts">The accepts array to select from.</param>
247+
/// <returns>The Accept header values to use.</returns>
248+
public static IEnumerable<MediaTypeWithQualityHeaderValue> SelectHeaderAcceptArray(string[] accepts)
249+
{
250+
if (accepts.Length == 0)
251+
return [];
252+
253+
if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase))
254+
return [MediaTypeWithQualityHeaderValue.Parse("application/json")];
255+
256+
return accepts.Select(MediaTypeWithQualityHeaderValue.Parse);
257+
}
258+
238259
/// <summary>
239260
/// Provides a case-insensitive check that a provided content type is a known JSON-like content type.
240261
/// </summary>

samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
using System;
1414
using System.Collections.Generic;
15+
using System.Collections.ObjectModel;
1516
using System.Net;
17+
using System.IO;
1618
using System.Threading.Tasks;
1719
using Microsoft.Extensions.Logging;
1820
using System.Net.Http;
@@ -221,10 +223,10 @@ public async Task<IRootGetApiResponse> RootGetAsync(System.Threading.Cancellatio
221223
"application/json"
222224
};
223225

224-
string? acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars);
226+
IEnumerable<MediaTypeWithQualityHeaderValue> acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars);
225227

226-
if (acceptLocalVar != null)
227-
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
228+
foreach (var acceptLocalVar in acceptHeaderValuesLocalVar)
229+
httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar);
228230

229231
httpRequestMessageLocalVar.Method = HttpMethod.Get;
230232

samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public partial interface IApiResponse
5252
/// </summary>
5353
System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
5454

55+
/// <summary>
56+
/// The headers contained in the api response related to the content
57+
/// </summary>
58+
System.Net.Http.Headers.HttpContentHeaders ContentHeaders { get; }
59+
5560
/// <summary>
5661
/// The path used when making the request.
5762
/// </summary>
@@ -109,6 +114,11 @@ public partial class ApiResponse : IApiResponse
109114
/// </summary>
110115
public System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
111116

117+
/// <summary>
118+
/// The headers contained in the api response related to the content
119+
/// </summary>
120+
public System.Net.Http.Headers.HttpContentHeaders ContentHeaders { get; }
121+
112122
/// <summary>
113123
/// The DateTime when the request was retrieved.
114124
/// </summary>
@@ -147,6 +157,7 @@ public ApiResponse(global::System.Net.Http.HttpRequestMessage httpRequestMessage
147157
{
148158
StatusCode = httpResponseMessage.StatusCode;
149159
Headers = httpResponseMessage.Headers;
160+
ContentHeaders = httpResponseMessage.Content.Headers;
150161
IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode;
151162
ReasonPhrase = httpResponseMessage.ReasonPhrase;
152163
RawContent = rawContent;
@@ -170,6 +181,7 @@ public ApiResponse(global::System.Net.Http.HttpRequestMessage httpRequestMessage
170181
{
171182
StatusCode = httpResponseMessage.StatusCode;
172183
Headers = httpResponseMessage.Headers;
184+
ContentHeaders = httpResponseMessage.Content.Headers;
173185
IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode;
174186
ReasonPhrase = httpResponseMessage.ReasonPhrase;
175187
ContentStream = contentStream;
@@ -181,6 +193,7 @@ public ApiResponse(global::System.Net.Http.HttpRequestMessage httpRequestMessage
181193
OnCreated(httpRequestMessage, httpResponseMessage);
182194
}
183195

196+
184197
partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
185198
}
186199

samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System.Text.RegularExpressions;
2020
using Org.OpenAPITools.Model;
2121
using System.Runtime.CompilerServices;
22+
using System.Net.Http.Headers;
2223

2324
[assembly: InternalsVisibleTo("Org.OpenAPITools.Test")]
2425

@@ -220,6 +221,26 @@ public static byte[] ReadAsBytes(Stream inputStream)
220221
return string.Join(",", accepts);
221222
}
222223

224+
225+
226+
/// <summary>
227+
/// Select the Accept header's value from the given accepts array:
228+
/// if JSON exists in the given array, use it;
229+
/// otherwise use all of them.
230+
/// </summary>
231+
/// <param name="accepts">The accepts array to select from.</param>
232+
/// <returns>The Accept header values to use.</returns>
233+
public static IEnumerable<MediaTypeWithQualityHeaderValue> SelectHeaderAcceptArray(string[] accepts)
234+
{
235+
if (accepts.Length == 0)
236+
return [];
237+
238+
if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase))
239+
return [MediaTypeWithQualityHeaderValue.Parse("application/json")];
240+
241+
return accepts.Select(MediaTypeWithQualityHeaderValue.Parse);
242+
}
243+
223244
/// <summary>
224245
/// Provides a case-insensitive check that a provided content type is a known JSON-like content type.
225246
/// </summary>

samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
using System;
1212
using System.Collections.Generic;
13+
using System.Collections.ObjectModel;
1314
using System.Net;
15+
using System.IO;
1416
using System.Threading.Tasks;
1517
using Microsoft.Extensions.Logging;
1618
using System.Net.Http;
@@ -292,10 +294,10 @@ public async Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsAsyn
292294
"application/json"
293295
};
294296

295-
string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars);
297+
IEnumerable<MediaTypeWithQualityHeaderValue> acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars);
296298

297-
if (acceptLocalVar != null)
298-
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
299+
foreach (var acceptLocalVar in acceptHeaderValuesLocalVar)
300+
httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar);
299301

300302
httpRequestMessageLocalVar.Method = HttpMethod.Patch;
301303

0 commit comments

Comments
 (0)