Skip to content

Commit c8af701

Browse files
author
Bryan Aldrich
committed
samples update
1 parent 9879fa5 commit c8af701

File tree

183 files changed

+8367
-1420
lines changed

Some content is hidden

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

183 files changed

+8367
-1420
lines changed

samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/CustomTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Newtonsoft.Json.Linq;
1+
using Newtonsoft.Json.Linq;
22
using Org.OpenAPITools.Api;
33
using Org.OpenAPITools.Model;
44
using System;

samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/EchoServerResponseParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");

samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Client/ApiClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
using System.Threading;
2424
using System.Text.RegularExpressions;
2525
using System.Threading.Tasks;
26+
#if !NET6_0_OR_GREATER
27+
using System.Web;
28+
#endif
2629
using Newtonsoft.Json;
2730
using Newtonsoft.Json.Serialization;
2831
using RestSharp;

samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Client/ClientUtils.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,14 @@ public static string ParameterToString(object obj, IReadableConfiguration config
101101
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
102102
// For example: 2009-06-15T13:45:30.0000000
103103
return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
104+
#if NET6_0_OR_GREATER
104105
if (obj is DateOnly dateOnly)
105106
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
106107
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
107108
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
108109
// For example: 2009-06-15
109110
return dateOnly.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
111+
#endif
110112
if (obj is bool boolean)
111113
return boolean ? "true" : "false";
112114
if (obj is ICollection collection) {

samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Client/ApiClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
using System.Threading;
2323
using System.Text.RegularExpressions;
2424
using System.Threading.Tasks;
25+
#if !NET6_0_OR_GREATER
2526
using System.Web;
27+
#endif
2628
using Newtonsoft.Json;
2729
using Newtonsoft.Json.Serialization;
2830
using RestSharp;

samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Client/ClientUtils.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ public static string ParameterToString(object obj, IReadableConfiguration config
116116
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
117117
// For example: 2009-06-15T13:45:30.0000000
118118
return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
119+
#if NET6_0_OR_GREATER
120+
if (obj is DateOnly dateOnly)
121+
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
122+
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
123+
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
124+
// For example: 2009-06-15
125+
return dateOnly.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
126+
#endif
119127
if (obj is bool boolean)
120128
return boolean ? "true" : "false";
121129
if (obj is ICollection collection) {

samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKEYSApi.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,25 @@ public async Task<IGetApiKeysIdApiResponse> GetApiKeysIdAsync(int id, System.Thr
234234
uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Bid%7D", Uri.EscapeDataString(id.ToString()));
235235

236236
httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
237-
237+
#if NET6_0_OR_GREATER
238238
httpRequestMessageLocalVar.Method = HttpMethod.Get;
239+
#else
240+
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
241+
#endif
239242

240243
DateTime requestedAtLocalVar = DateTime.UtcNow;
241244

242245
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
243246
{
244-
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
247+
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
248+
#if NET6_0_OR_GREATER
249+
cancellationToken
250+
#endif
251+
).ConfigureAwait(false);
245252

246253
ILogger<GetApiKeysIdApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetApiKeysIdApiResponse>();
247254

248-
GetApiKeysIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions);
255+
GetApiKeysIdApiResponse apiResponseLocalVar = new GetApiKeysIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions);
249256

250257
AfterGetApiKeysIdDefaultImplementation(apiResponseLocalVar, id);
251258

samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKeys0Api.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,25 @@ public async Task<IGetApiKeysIdApiResponse> GetApiKeysIdAsync(int id, System.Thr
222222
uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Bid%7D", Uri.EscapeDataString(id.ToString()));
223223

224224
httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
225-
225+
#if NET6_0_OR_GREATER
226226
httpRequestMessageLocalVar.Method = HttpMethod.Get;
227+
#else
228+
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
229+
#endif
227230

228231
DateTime requestedAtLocalVar = DateTime.UtcNow;
229232

230233
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
231234
{
232-
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
235+
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
236+
#if NET6_0_OR_GREATER
237+
cancellationToken
238+
#endif
239+
).ConfigureAwait(false);
233240

234241
ILogger<APIKEYSApi.GetApiKeysIdApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<APIKEYSApi.GetApiKeysIdApiResponse>();
235242

236-
APIKEYSApi.GetApiKeysIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions);
243+
APIKEYSApi.GetApiKeysIdApiResponse apiResponseLocalVar = new GetApiKeysIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions);
237244

238245
AfterGetApiKeysIdDefaultImplementation(apiResponseLocalVar, id);
239246

samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/ApiKeys1Api.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,25 @@ public async Task<IGetApiKeysIdApiResponse> GetApiKeysIdAsync(int id, System.Thr
222222
uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Bid%7D", Uri.EscapeDataString(id.ToString()));
223223

224224
httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
225-
225+
#if NET6_0_OR_GREATER
226226
httpRequestMessageLocalVar.Method = HttpMethod.Get;
227+
#else
228+
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
229+
#endif
227230

228231
DateTime requestedAtLocalVar = DateTime.UtcNow;
229232

230233
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
231234
{
232-
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
235+
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
236+
#if NET6_0_OR_GREATER
237+
cancellationToken
238+
#endif
239+
).ConfigureAwait(false);
233240

234241
ILogger<APIKEYSApi.GetApiKeysIdApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<APIKEYSApi.GetApiKeysIdApiResponse>();
235242

236-
APIKEYSApi.GetApiKeysIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions);
243+
APIKEYSApi.GetApiKeysIdApiResponse apiResponseLocalVar = new GetApiKeysIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions);
237244

238245
AfterGetApiKeysIdDefaultImplementation(apiResponseLocalVar, id);
239246

samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/ClientUtils.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,15 @@ public static string ApiKeyHeaderToString(ApiKeyHeader value)
7373
/// <param name="options"></param>
7474
/// <param name="result"></param>
7575
/// <returns></returns>
76-
public static bool TryDeserialize<T>(string json, JsonSerializerOptions options, [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T? result)
76+
public static bool TryDeserialize<T>(string json, JsonSerializerOptions options,
77+
#if NET6_0_OR_GREATER
78+
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
79+
#endif
80+
out T
81+
#if NET6_0_OR_GREATER
82+
?
83+
#endif
84+
result)
7785
{
7886
try
7987
{
@@ -95,7 +103,15 @@ public static bool TryDeserialize<T>(string json, JsonSerializerOptions options,
95103
/// <param name="options"></param>
96104
/// <param name="result"></param>
97105
/// <returns></returns>
98-
public static bool TryDeserialize<T>(ref Utf8JsonReader reader, JsonSerializerOptions options, [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T? result)
106+
public static bool TryDeserialize<T>(ref Utf8JsonReader reader, JsonSerializerOptions options,
107+
#if NET6_0_OR_GREATER
108+
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
109+
#endif
110+
out T
111+
#if NET6_0_OR_GREATER
112+
?
113+
#endif
114+
result)
99115
{
100116
try
101117
{
@@ -142,8 +158,10 @@ public static string SanitizeFilename(string filename)
142158
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
143159
// For example: 2009-06-15T13:45:30.0000000
144160
return dateTimeOffset.ToString(format);
161+
#if NET6_0_OR_GREATER
145162
if (obj is DateOnly dateOnly)
146163
return dateOnly.ToString(format);
164+
#endif
147165
if (obj is bool boolean)
148166
return boolean
149167
? "true"

0 commit comments

Comments
 (0)