From 3b6c6f7dca726f31d106d46fe13c73147e018486 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 9 Jan 2021 22:45:57 -0500 Subject: [PATCH 01/20] implemented httpclient for jwt --- .../libraries/httpclient/ApiClient.mustache | 0 .../httpclient/ApiException.mustache | 60 +- .../libraries/httpclient/ApiResponse.mustache | 117 +--- .../libraries/httpclient/ClientUtils.mustache | 245 +++++++ .../httpclient/Configuration.mustache | 0 .../httpclient/GlobalConfiguration.mustache | 0 .../httpclient/RetryConfiguration.mustache | 0 .../libraries/httpclient/api.mustache | 641 ++++-------------- .../libraries/httpclient/api_test.mustache | 70 ++ .../libraries/httpclient/model_test.mustache | 80 +++ .../httpclient/netcore_project.mustache | 8 +- .../builds/inversify/.openapi-generator/FILES | 9 - .../builds/inversify/apis/PetApi.ts | 3 - .../builds/inversify/apis/StoreApi.ts | 3 - .../builds/inversify/apis/UserApi.ts | 3 - .../builds/inversify/apis/baseapi.ts | 5 +- .../typescript/builds/inversify/auth/auth.ts | 15 +- .../typescript/builds/inversify/index.ts | 2 - .../typescript/builds/inversify/package.json | 1 - .../typescript/builds/inversify/tsconfig.json | 1 - .../builds/inversify/types/ObservableAPI.ts | 41 +- .../builds/inversify/types/PromiseAPI.ts | 29 +- 22 files changed, 598 insertions(+), 735 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ClientUtils.mustache create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/Configuration.mustache create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/GlobalConfiguration.mustache create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/RetryConfiguration.mustache create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api_test.mustache create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/model_test.mustache diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiException.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiException.mustache index ddca08e5ca17..03ad75ce5a09 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiException.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiException.mustache @@ -7,64 +7,36 @@ namespace {{packageName}}.Client /// /// API Exception /// - {{>visibility}} class ApiException : Exception + {{>visibility}} class ApiException : Exception { /// - /// Gets or sets the error code (HTTP status code) + /// The reason the api request failed /// - /// The error code (HTTP status code). - public int ErrorCode { get; set; } + public string? ReasonPhrase { get; } /// - /// Gets or sets the error content (body json object) + /// The HttpStatusCode /// - /// The error content (Http response body). - public object ErrorContent { get; private set; } + public System.Net.HttpStatusCode StatusCode { get; } /// - /// Gets or sets the HTTP headers + /// The raw data returned by the api /// - /// HTTP headers - public Multimap Headers { get; private set; } - + public string RawData { get; } + /// - /// The unsuccessful server request. + /// Construct the ApiException from parts of the reponse /// - public ApiResponse ApiResponse; - - public ApiException(ApiResponse apiResponse) + /// + /// + /// + public ApiException(string? reasonPhrase, System.Net.HttpStatusCode statusCode, string rawData) : base(reasonPhrase ?? rawData) { - ApiResponse = apiResponse; - } + ReasonPhrase = reasonPhrase; - /// - /// Initializes a new instance of the class. - /// - public ApiException() { } - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Error message. - public ApiException(int errorCode, string message) : base(message) - { - this.ErrorCode = errorCode; - } + StatusCode = statusCode; - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Error message. - /// Error content. - /// HTTP Headers. - public ApiException(int errorCode, string message, object errorContent = null, Multimap headers = null) : base(message) - { - this.ErrorCode = errorCode; - this.ErrorContent = errorContent; - this.Headers = headers; + RawData = rawData; } } - } diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache index c117ee3d99cb..5bb4b0261573 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Net; +using Newtonsoft.Json; namespace {{packageName}}.Client { @@ -12,32 +13,16 @@ namespace {{packageName}}.Client public interface IApiResponse { /// - /// The data type of + /// The data type of /// Type ResponseType { get; } - /// - /// The content of this response - /// - Object Content { get; } - /// /// Gets or sets the status code (HTTP status code) /// /// The status code. HttpStatusCode StatusCode { get; } - /// - /// Gets or sets the HTTP headers - /// - /// HTTP headers - Multimap Headers { get; } - - /// - /// Gets or sets any error text defined by the calling client. - /// - String ErrorText { get; set; } - /// /// Gets or sets any cookies passed along on the response. /// @@ -46,7 +31,7 @@ namespace {{packageName}}.Client /// /// The raw content of this response /// - string RawContent { get; } + string RawData { get; } } /// @@ -57,27 +42,15 @@ namespace {{packageName}}.Client #region Properties /// - /// Gets or sets the status code (HTTP status code) - /// - /// The status code. - public HttpStatusCode StatusCode { get; } - - /// - /// Gets or sets the HTTP headers + /// The deserialized data /// - /// HTTP headers - public Multimap Headers { get; } + public T? Data { get; set; } /// - /// Gets or sets the data (parsed HTTP body) - /// - /// The data. - public T Data { get; } - - /// - /// Gets or sets any error text defined by the calling client. + /// Gets or sets the status code (HTTP status code) /// - public String ErrorText { get; set; } + /// The status code. + public HttpStatusCode StatusCode { get; } /// /// Gets or sets any cookies passed along on the response. @@ -93,77 +66,39 @@ namespace {{packageName}}.Client } /// - /// The data type of + /// The raw data /// - public object Content - { - get { return Data; } - } + public string RawData { get; } /// - /// The raw content + /// The IsSuccessStatusCode from the api response /// - public string RawContent { get; } + public bool IsSuccessStatusCode { get; } /// - /// The servers response to our request. + /// The reason phrase contained in the api response /// - public System.Net.Http.HttpResponseMessage Response { get; } - - #endregion Properties - - #region Constructors - - public ApiResponse(System.Net.Http.HttpResponseMessage response, string rawContent) - { - Response = response; - RawContent = rawContent; - } + public string? ReasonPhrase { get; } /// - /// Initializes a new instance of the class. + /// The headers contained in the api response /// - /// HTTP status code. - /// HTTP headers. - /// Data (parsed HTTP body) - /// Raw content. - public ApiResponse(HttpStatusCode statusCode, Multimap headers, T data, string rawContent) - { - StatusCode = statusCode; - Headers = headers; - Data = data; - RawContent = rawContent; - } + public System.Net.Http.Headers.HttpResponseHeaders Headers { get; } - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// HTTP headers. - /// Data (parsed HTTP body) - public ApiResponse(HttpStatusCode statusCode, Multimap headers, T data) : this(statusCode, headers, data, null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Data (parsed HTTP body) - /// Raw content. - public ApiResponse(HttpStatusCode statusCode, T data, string rawContent) : this(statusCode, null, data, rawContent) - { - } + #endregion Properties /// - /// Initializes a new instance of the class. + /// Construct the reponse using an HttpResponseMessage /// - /// HTTP status code. - /// Data (parsed HTTP body) - public ApiResponse(HttpStatusCode statusCode, T data) : this(statusCode, data, null) + /// + /// + public ApiResponse(System.Net.Http.HttpResponseMessage response, string rawData) { + StatusCode = response.StatusCode; + Headers = response.Headers; + IsSuccessStatusCode = response.IsSuccessStatusCode; + ReasonPhrase = response.ReasonPhrase; + RawData = rawData; } - - #endregion Constructors } } diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ClientUtils.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ClientUtils.mustache new file mode 100644 index 000000000000..684f79e66524 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ClientUtils.mustache @@ -0,0 +1,245 @@ +{{>partial_header}} + +using System; +using System.Collections; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +{{#useCompareNetObjects}} +using KellermanSoftware.CompareNetObjects; +{{/useCompareNetObjects}} + +namespace {{packageName}}.Client +{ + /// + /// Utility functions providing some benefit to API client consumers. + /// + public static class ClientUtils + { + {{#useCompareNetObjects}} + /// + /// An instance of CompareLogic. + /// + public static CompareLogic compareLogic; + + /// + /// Static contstructor to initialise compareLogic. + /// + static ClientUtils() + { + compareLogic = new CompareLogic(); + } + {{/useCompareNetObjects}} + + /// + /// Custom JSON serializer + /// + public static readonly Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings = new Newtonsoft.Json.JsonSerializerSettings + { + // OpenAPI generated types generally hide default constructors. + ConstructorHandling = Newtonsoft.Json.ConstructorHandling.AllowNonPublicDefaultConstructor, + MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Error, + ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver + { + NamingStrategy = new Newtonsoft.Json.Serialization.CamelCaseNamingStrategy + { + OverrideSpecifiedNames = false + } + } + }; + + /// + /// Sanitize filename by removing the path + /// + /// Filename + /// Filename + public static string SanitizeFilename(string filename) + { + Match match = Regex.Match(filename, @".*[/\\](.*)$"); + return match.Success ? match.Groups[1].Value : filename; + } + + /// + /// Convert params to key/value pairs. + /// Use collectionFormat to properly format lists and collections. + /// + /// The swagger-supported collection format, one of: csv, tsv, ssv, pipes, multi + /// Key name. + /// Value object. + /// A multimap of keys with 1..n associated values. + public static Multimap ParameterToMultiMap(string collectionFormat, string name, object value) + { + var parameters = new Multimap(); + + if (value is ICollection collection && collectionFormat == "multi") + { + foreach (var item in collection) + { + parameters.Add(name, ParameterToString(item)); + } + } + else + { + parameters.Add(name, ParameterToString(value)); + } + + return parameters; + } + + /// + /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. + /// If parameter is a list, join the list with ",". + /// Otherwise just return the string. + /// + /// The parameter (header, path, query, form). + /// An optional configuration instance, providing formatting options used in processing. + /// Formatted string. + public static string ParameterToString(object obj, IReadableConfiguration configuration = null) + { + throw new NotImplementedException(); + + /* + if (obj is DateTime dateTime) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTime.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat); + if (obj is DateTimeOffset dateTimeOffset) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat); + if (obj is bool boolean) + return boolean ? "true" : "false"; + if (obj is ICollection collection) + return string.Join(",", collection.Cast()); + + return Convert.ToString(obj, CultureInfo.InvariantCulture); + */ + } + + /// + /// URL encode a string + /// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50 + /// + /// String to be URL encoded + /// Byte array + public static string UrlEncode(string input) + { + const int maxLength = 32766; + + if (input == null) + { + throw new ArgumentNullException("input"); + } + + if (input.Length <= maxLength) + { + return Uri.EscapeDataString(input); + } + + StringBuilder sb = new StringBuilder(input.Length * 2); + int index = 0; + + while (index < input.Length) + { + int length = Math.Min(input.Length - index, maxLength); + string subString = input.Substring(index, length); + + sb.Append(Uri.EscapeDataString(subString)); + index += subString.Length; + } + + return sb.ToString(); + } + + /// + /// Encode string in base64 format. + /// + /// String to be encoded. + /// Encoded string. + public static string Base64Encode(string text) + { + return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text)); + } + + /// + /// Convert stream to byte array + /// + /// Input stream to be converted + /// Byte array + public static byte[] ReadAsBytes(Stream inputStream) + { + using (var ms = new MemoryStream()) + { + inputStream.CopyTo(ms); + return ms.ToArray(); + } + } + + /// + /// Select the Content-Type header's value from the given content-type array: + /// if JSON type exists in the given array, use it; + /// otherwise use the first one defined in 'consumes' + /// + /// The Content-Type array to select from. + /// The Content-Type header to use. + public static String SelectHeaderContentType(String[] contentTypes) + { + if (contentTypes.Length == 0) + return null; + + foreach (var contentType in contentTypes) + { + if (IsJsonMime(contentType)) + return contentType; + } + + return contentTypes[0]; // use the first content type specified in 'consumes' + } + + /// + /// Select the Accept header's value from the given accepts array: + /// if JSON exists in the given array, use it; + /// otherwise use all of them (joining into a string) + /// + /// The accepts array to select from. + /// The Accept header to use. + public static String SelectHeaderAccept(String[] accepts) + { + if (accepts.Length == 0) + return null; + + if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase)) + return "application/json"; + + return String.Join(",", accepts); + } + + /// + /// Provides a case-insensitive check that a provided content type is a known JSON-like content type. + /// + public static readonly Regex JsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"); + + /// + /// Check if the given MIME is a JSON MIME. + /// JSON MIME examples: + /// application/json + /// application/json; charset=UTF8 + /// APPLICATION/JSON + /// application/vnd.company+json + /// + /// MIME + /// Returns True if MIME type is json. + public static bool IsJsonMime(String mime) + { + if (String.IsNullOrWhiteSpace(mime)) return false; + + return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"); + } + } +} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/Configuration.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/Configuration.mustache new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/GlobalConfiguration.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/GlobalConfiguration.mustache new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/RetryConfiguration.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/RetryConfiguration.mustache new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache index 890f75c64a35..ce8e721df46a 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache @@ -13,27 +13,12 @@ using {{packageName}}.Client; namespace {{packageName}}.{{apiPackage}} { {{#operations}} - /// /// Represents a collection of functions to interact with the API endpoints /// - {{>visibility}} interface {{interfacePrefix}}{{classname}}Sync : IApiAccessor + {{>visibility}} interface {{interfacePrefix}}{{classname}} { - #region Synchronous Operations {{#operation}} - /// - /// {{summary}} - /// - {{#notes}} - /// - /// {{notes}} - /// - {{/notes}} - /// Thrown when fails to make API call - {{#allParams}}/// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} - {{/allParams}}/// {{#returnType}}{{returnType}}{{/returnType}} - {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}); - /// /// {{summary}} /// @@ -41,21 +26,13 @@ namespace {{packageName}}.{{apiPackage}} /// {{notes}} /// /// Thrown when fails to make API call - {{#allParams}}/// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} - {{/allParams}}/// ApiResponse of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Object(void){{/returnType}} - ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> {{operationId}}Response({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}); - {{/operation}} - #endregion Synchronous Operations - } - - {{#supportsAsync}} - /// - /// Represents a collection of functions to interact with the API endpoints - /// - {{>visibility}} interface {{interfacePrefix}}{{classname}}Async : IApiAccessor - { - #region Asynchronous Operations - {{#operation}} + {{#allParams}} + /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} + {{/allParams}} + /// Cancellation Token to cancel the request. + /// Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}} + System.Threading.Tasks.Task> {{operationId}}WithHttpInfoAsync({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}} = null{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken = null); + /// /// {{summary}} /// @@ -67,33 +44,24 @@ namespace {{packageName}}.{{apiPackage}} /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} {{/allParams}} /// Cancellation Token to cancel the request. - /// Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}} - {{#returnType}}System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}} = null{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}} + System.Threading.Tasks.Task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> {{operationId}}Async({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}} = null{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken = null); + + {{#returnType}} /// /// {{summary}} /// /// /// {{notes}} /// - /// Thrown when fails to make API call {{#allParams}} /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} {{/allParams}} /// Cancellation Token to cancel the request. - /// Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}} - System.Threading.Tasks.Task> {{operationId}}ResponseAsync({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}} = null{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken = null); + /// Task of ApiResponse{{#returnType}} ({{returnType}}?){{/returnType}} + System.Threading.Tasks.Task<{{#returnType}}{{{returnType}}}{{/returnType}}?> {{operationId}}OrDefaultAsync({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}} = null{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken = null); + {{/returnType}} {{/operation}} - #endregion Asynchronous Operations - } - {{/supportsAsync}} - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - {{>visibility}} interface {{interfacePrefix}}{{classname}} : {{interfacePrefix}}{{classname}}Sync{{#supportsAsync}}, {{interfacePrefix}}{{classname}}Async{{/supportsAsync}} - { - } /// @@ -101,319 +69,52 @@ namespace {{packageName}}.{{apiPackage}} /// {{>visibility}} partial class {{classname}} : {{interfacePrefix}}{{classname}} { - private {{packageName}}.Client.ExceptionFactory _exceptionFactory = (name, response) => null; private readonly System.Net.Http.HttpClient _httpClient; - private readonly Newtonsoft.Json.JsonConverter[] _jsonConverters; /// /// Initializes a new instance of the class. /// /// - public {{classname}}() : this((string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - public {{classname}}(System.Net.Http.HttpClient httpClient, Newtonsoft.Json.JsonConverter[] jsonConverters) : this((string)null) + public {{classname}}(System.Net.Http.HttpClient httpClient) { _httpClient = httpClient; - - _jsonConverters = jsonConverters; - } - - /// - /// Initializes a new instance of the class. - /// - /// - public {{classname}}(String basePath) - { - this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations( - {{packageName}}.Client.GlobalConfiguration.Instance, - new {{packageName}}.Client.Configuration { BasePath = basePath } - ); - this.Client = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath); - {{#supportsAsync}} - this.AsynchronousClient = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath); - {{/supportsAsync}} - this.ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory; } /// - /// Initializes a new instance of the class - /// using Configuration object + /// Returns the token to be used in the api query /// - /// An instance of Configuration - /// - public {{classname}}({{packageName}}.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations( - {{packageName}}.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath); - {{#supportsAsync}} - this.AsynchronousClient = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath); - {{/supportsAsync}} - ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access.{{#supportsAsync}} - /// The client interface for asynchronous API access.{{/supportsAsync}} - /// The configuration object. - public {{classname}}({{packageName}}.Client.ISynchronousClient client, {{#supportsAsync}}{{packageName}}.Client.IAsynchronousClient asyncClient, {{/supportsAsync}}{{packageName}}.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - {{#supportsAsync}} - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - {{/supportsAsync}} - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - {{#supportsAsync}} - this.AsynchronousClient = asyncClient; - {{/supportsAsync}} - this.Configuration = configuration; - this.ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory; - } - - {{#supportsAsync}} - /// - /// The client for accessing this underlying API asynchronously. - /// - public {{packageName}}.Client.IAsynchronousClient AsynchronousClient { get; set; } - {{/supportsAsync}} - - /// - /// The client for accessing this underlying API synchronously. - /// - public {{packageName}}.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public {{packageName}}.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public {{packageName}}.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } + public Func>? GetTokenAsync { get; set; } {{#operation}} + /// - /// {{summary}} {{notes}} + /// Validate the input before sending the request /// - /// Thrown when fails to make API call - {{#allParams}}/// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} - {{/allParams}}/// {{#returnType}}{{returnType}}{{/returnType}} - public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) - { - {{#returnType}}{{packageName}}.Client.ApiResponse<{{{returnType}}}> localVarResponse = {{operationId}}Response({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); - return localVarResponse.Data;{{/returnType}}{{^returnType}}{{operationId}}Response({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{/returnType}} - } + {{#allParams}} + /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} + {{/allParams}} + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask Validate{{operationId}}RequestAsync({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + {{#returnType}} /// /// {{summary}} {{notes}} /// /// Thrown when fails to make API call - {{#allParams}}/// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} - {{/allParams}}/// ApiResponse of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Object(void){{/returnType}} - public {{packageName}}.Client.ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> {{operationId}}Response({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) + {{#allParams}} + /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} + {{/allParams}} + /// Cancellation Token to cancel the request. + /// Task of {{returnType}} + public async System.Threading.Tasks.Task<{{{returnType}}}> {{operationId}}Async({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}} = null{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken = null) { - {{#allParams}} - {{#required}} - {{^vendorExtensions.x-csharp-value-type}} - // verify the required parameter '{{paramName}}' is set - if ({{paramName}} == null) - throw new {{packageName}}.Client.ApiException(400, "Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}"); - - {{/vendorExtensions.x-csharp-value-type}} - {{/required}} - {{/allParams}} - {{packageName}}.Client.RequestOptions localVarRequestOptions = new {{packageName}}.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - {{#consumes}} - "{{{mediaType}}}"{{^-last}},{{/-last}} - {{/consumes}} - }; - - // to determine the Accept header - String[] _accepts = new String[] { - {{#produces}} - "{{{mediaType}}}"{{^-last}},{{/-last}} - {{/produces}} - }; - - var localVarContentType = {{packageName}}.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = {{packageName}}.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - {{#pathParams}} - {{#required}} - localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter - {{/required}} - {{^required}} - if ({{paramName}} != null) - { - localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter - } - {{/required}} - {{/pathParams}} - {{#queryParams}} - {{#required}} - localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); - {{/required}} - {{^required}} - if ({{paramName}} != null) - { - localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); - } - {{/required}} - {{/queryParams}} - {{#headerParams}} - {{#required}} - localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter - {{/required}} - {{^required}} - if ({{paramName}} != null) - { - localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter - } - {{/required}} - {{/headerParams}} - {{#formParams}} - {{#required}} - {{#isFile}} - localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}}); - {{/isFile}} - {{^isFile}} - localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter - {{/isFile}} - {{/required}} - {{^required}} - if ({{paramName}} != null) - { - {{#isFile}} - localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}}); - {{/isFile}} - {{^isFile}} - localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter - {{/isFile}} - } - {{/required}} - {{/formParams}} - {{#bodyParam}} - localVarRequestOptions.Data = {{paramName}}; - {{/bodyParam}} - - {{#authMethods}} - // authentication ({{name}}) required - {{#isApiKey}} - {{#isKeyInCookie}} - // cookie parameter support - if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))) - { - localVarRequestOptions.Cookies.Add(new Cookie("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))); - } - {{/isKeyInCookie}} - {{#isKeyInHeader}} - if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))) - { - localVarRequestOptions.HeaderParameters.Add("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")); - } - {{/isKeyInHeader}} - {{#isKeyInQuery}} - if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))) - { - localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))); - } - {{/isKeyInQuery}} - {{/isApiKey}} - {{#isBasicBasic}} - // http basic authentication required - if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + {{packageName}}.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password)); - } - {{/isBasicBasic}} - {{#isBasicBearer}} - // bearer authentication required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - {{/isBasicBearer}} - {{#isOAuth}} - // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - {{/isOAuth}} - {{#isHttpSignature}} - if (this.Configuration.HttpSigningConfiguration != null) - { - var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "{{{httpMethod}}}", "{{{path}}}", localVarRequestOptions); - foreach (var headerItem in HttpSigningHeaders) - { - if (localVarRequestOptions.HeaderParameters.ContainsKey(headerItem.Key)) - { - localVarRequestOptions.HeaderParameters[headerItem.Key] = new List() { headerItem.Value }; - } - else - { - localVarRequestOptions.HeaderParameters.Add(headerItem.Key, headerItem.Value); - } - } - } - {{/isHttpSignature}} - {{/authMethods}} - - // make the HTTP request - var localVarResponse = this.Client.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>("{{{path}}}", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("{{operationId}}", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + {{packageName}}.Client.ApiResponse<{{{returnType}}}> result = await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } + {{/returnType}} - {{#supportsAsync}} + {{#returnType}} /// /// {{summary}} {{notes}} /// @@ -422,18 +123,16 @@ namespace {{packageName}}.{{apiPackage}} /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} {{/allParams}} /// Cancellation Token to cancel the request. - /// Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}} - {{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}} = null{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken = null) - { - {{#returnType}}{{packageName}}.Client.ApiResponse<{{{returnType}}}> localVarResponse = await {{operationId}}ResponseAsync({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken).ConfigureAwait(false); - return localVarResponse.Data;{{/returnType}}{{^returnType}}await {{operationId}}ResponseAsync({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken).ConfigureAwait(false);{{/returnType}} - } - - private System.Threading.Tasks.ValueTask Validate{{operationId}}RequestAsync({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken) + /// Task of {{returnType}} + public async System.Threading.Tasks.Task<{{{returnType}}}?> {{operationId}}OrDefaultAsync({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}} = null{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken = null) { - // todo - return new System.Threading.Tasks.ValueTask(); - } + {{packageName}}.Client.ApiResponse<{{{returnType}}}> result = await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } + {{/returnType}} /// /// {{summary}} {{notes}} @@ -444,179 +143,92 @@ namespace {{packageName}}.{{apiPackage}} {{/allParams}} /// Cancellation Token to cancel the request. /// Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}} - public async System.Threading.Tasks.Task<{{packageName}}.Client.ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}ResponseAsync({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}} = null{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task<{{packageName}}.Client.ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}WithHttpInfoAsync({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}} = null{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken = null) { {{#allParams}} {{#required}} {{^vendorExtensions.x-csharp-value-type}} - // verify the required parameter '{{paramName}}' is set if ({{paramName}} == null) - throw new {{packageName}}.Client.ApiException<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>(400, "Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}"); + throw new ArgumentNullException(nameof({{paramName}})); {{/vendorExtensions.x-csharp-value-type}} {{/required}} {{/allParams}} - await Validate{{operationId}}RequestAsync({{#allParams}}{{#required}}{{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + await Validate{{operationId}}RequestAsync({{#allParams}}{{#required}}{{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken).ConfigureAwait(false); - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "{{path}}"; - {{#pathParams}} - {{#required}} -{{=<< >>=}} - path = path.Replace("{<>}", Uri.EscapeDataString(<>)); -<<={{ }}=>> - {{/required}} - {{^required}} - if ({{paramName}} != null) - path = $"{path}{path.Replace("||baseName||", Uri.EscapeDataString(||paramName||))}&"; - - {{/required}} - {{/pathParams}} - - path = $"{path}?"; - - {{#queryParams}} - {{#required}} - path = $"{path}{{baseName}}={Uri.EscapeDataString({{paramName}}.ToString())&"; - - {{/required}} - {{^required}} - if ({{paramName}} != null) - path = $"{path}{{baseName}}={Uri.EscapeDataString({{paramName}}.ToString())}&"; - - {{/required}} - {{/queryParams}} - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - - {{#headerParams}} - {{#required}} - request.Headers.Add({{baseName}}, {{paramName}}); - {{/required}} - {{^required}} - if ({{paramName}} != null) - request.Headers.Add({{baseName}}, {{paramName}}); - {{/required}} - {{/headerParams}} - - {{#consumes}} - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("{{{mediaType}}}")); - {{/consumes}} - - string[] contentTypes = new string[] { - {{#consumes}} - "{{{mediaType}}}"{{^-last}}, {{/-last}} - {{/consumes}} - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - {{#produces}} - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("{{{mediaType}}}")); - {{/produces}} - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>(apiResponse); - - return apiResponse; - } - - {{packageName}}.Client.RequestOptions localVarRequestOptions = new {{packageName}}.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - {{#consumes}} - "{{{mediaType}}}"{{^-last}}, {{/-last}} - {{/consumes}} - }; - - // to determine the Accept header - string[] _accepts = new string[] { - {{#produces}} - "{{{mediaType}}}"{{^-last}},{{/-last}} - {{/produces}} - }; - - var localVarContentType = {{packageName}}.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = {{packageName}}.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + string path = "{{path}}"; {{#pathParams}} {{#required}} - localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter +{{=<< >>=}} + path = path.Replace("{<>}", Uri.EscapeDataString(<>)); +<<={{ }}=>> {{/required}} + {{^required}} if ({{paramName}} != null) - { - localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter - } - {{/required}} - {{/pathParams}} +{{=<< >>=}} + path = $"{path}{path.Replace("<>", Uri.EscapeDataString(<>))}&"; +<<={{ }}=>> + {{/required}}{{/pathParams}} + + path = $"{path}?"; + {{#queryParams}} {{#required}} - localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); + path = $"{path}{{baseName}}={Uri.EscapeDataString({{paramName}}.ToString()!)&"; + {{/required}} {{^required}} if ({{paramName}} != null) - { - localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); - } + path = $"{path}{{baseName}}={Uri.EscapeDataString({{paramName}}.ToString()!)}&"; + {{/required}} {{/queryParams}} + + if (path.EndsWith("&")) + path = path[..^1]; + + if (path.EndsWith("?")) + path = path[..^1]; + + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + {{#headerParams}} {{#required}} - localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter + request.Headers.Add({{baseName}}, {{paramName}}); {{/required}} {{^required}} - if ({{paramName}} != null) - { - localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter - } + if ({{paramName}} != null) + request.Headers.Add({{baseName}}, {{paramName}}); {{/required}} {{/headerParams}} + {{#formParams}} {{#required}} {{#isFile}} - localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}}); + // todo localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}}); {{/isFile}} {{^isFile}} - localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter + // todo localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter {{/isFile}} {{/required}} {{^required}} if ({{paramName}} != null) { {{#isFile}} - localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}}); + // todo localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}}); {{/isFile}} {{^isFile}} - localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter + // todo localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter {{/isFile}} } - {{/required}} + {{/required}} {{/formParams}} + {{#bodyParam}} - localVarRequestOptions.Data = {{paramName}}; + // todo localVarRequestOptions.Data = {{paramName}}; {{/bodyParam}} {{#authMethods}} @@ -624,48 +236,42 @@ namespace {{packageName}}.{{apiPackage}} {{#isApiKey}} {{#isKeyInCookie}} // cookie parameter support - if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))) - { - localVarRequestOptions.Cookies.Add(new Cookie("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))); - } + // todo if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))) + // todo localVarRequestOptions.Cookies.Add(new Cookie("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))); {{/isKeyInCookie}} - {{#isKeyInHeader}} - if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))) - { - localVarRequestOptions.HeaderParameters.Add("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")); - } + {{#isKeyInHeader}}//isKeyInHeader + string? token = GetTokenAsync != null + ? await GetTokenAsync().ConfigureAwait(false) + : null; + + if (token != null) + request.Headers.Add("authorization", $"Bearer {token}"); {{/isKeyInHeader}} {{#isKeyInQuery}} - if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))) - { - localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))); - } + //todo if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))) + //todo localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))); {{/isKeyInQuery}} {{/isApiKey}} {{#isBasic}} {{#isBasicBasic}} // http basic authentication required - if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + {{packageName}}.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password)); - } + //todo if (!string.IsNullOrEmpty(this.Configuration.Username) || !string.IsNullOrEmpty(this.Configuration.Password)) + //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + {{packageName}}.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password)); {{/isBasicBasic}} - {{#isBasicBearer}} + {{#isBasicBearer}}//isBasicBearer // bearer authentication required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } + //todo if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + //todo request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); {{/isBasicBearer}} {{/isBasic}} {{#isOAuth}} // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } + //todo if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); {{/isOAuth}} {{#isHttpSignature}} + //todo + /* if (this.Configuration.HttpSigningConfiguration != null) { var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "{{{httpMethod}}}", "{{{path}}}", localVarRequestOptions); @@ -681,23 +287,38 @@ namespace {{packageName}}.{{apiPackage}} } } } + */ {{/isHttpSignature}} {{/authMethods}} - // make the HTTP request + {{#consumes}} + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("{{{mediaType}}}")); + {{/consumes}} - var localVarResponse = await this.AsynchronousClient.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}Async<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>("{{{path}}}", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string[] contentTypes = new string[] { + {{#consumes}} + "{{{mediaType}}}"{{^-last}}, {{/-last}} + {{/consumes}} + }; - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("{{operationId}}", localVarResponse); - if (_exception != null) throw _exception; - } + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - return localVarResponse; - } + {{#produces}} + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("{{{mediaType}}}")); + {{/produces}} + + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - {{/supportsAsync}} + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); + + ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> apiResponse = new(responseMessage, responseContent); + + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + + return apiResponse; + } {{/operation}} } {{/operations}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api_test.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api_test.mustache new file mode 100644 index 000000000000..65a16c67e0c6 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api_test.mustache @@ -0,0 +1,70 @@ +{{>partial_header}} +using System; +using System.IO; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using Xunit; + +using {{packageName}}.Client; +using {{packageName}}.{{apiPackage}}; +{{#hasImport}} +// uncomment below to import models +//using {{packageName}}.{{modelPackage}}; +{{/hasImport}} + +namespace {{packageName}}.Test.Api +{ + /// + /// Class for testing {{classname}} + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the API endpoint. + /// + public class {{classname}}Tests : IDisposable + { + private {{classname}} instance; + + public {{classname}}Tests() + { + //instance = new {{classname}}(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of {{classname}} + /// + [Fact] + public void {{operationId}}InstanceTest() + { + // TODO uncomment below to test 'IsType' {{classname}} + //Assert.IsType<{{classname}}>(instance); + } + {{#operations}} + {{#operation}} + + /// + /// Test {{operationId}} + /// + [Fact] + public void {{operationId}}Test() + { + // TODO uncomment below to test the method and replace null with proper value + {{#allParams}} + //{{{dataType}}} {{paramName}} = null; + {{/allParams}} + //{{#returnType}}var response = {{/returnType}}instance.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); + {{#returnType}} + //Assert.IsType<{{{returnType}}}>(response); + {{/returnType}} + } + {{/operation}} + {{/operations}} + } +} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/model_test.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/model_test.mustache new file mode 100644 index 000000000000..43510ade64ee --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/model_test.mustache @@ -0,0 +1,80 @@ +{{>partial_header}} + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using {{packageName}}.{{apiPackage}}; +using {{packageName}}.{{modelPackage}}; +using {{packageName}}.Client; +using Newtonsoft.Json; + +{{#models}} +{{#model}} +namespace {{packageName}}.Test.Model +{ + /// + /// Class for testing {{classname}} + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class {{classname}}Tests : IDisposable + { + // TODO uncomment below to declare an instance variable for {{classname}} + //private {{classname}} instance; + + public {{classname}}Tests() + { + // TODO uncomment below to create an instance of {{classname}} + //instance = new {{classname}}(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of {{classname}} + /// + [Fact] + public void {{classname}}InstanceTest() + { + // TODO uncomment below to test "IsType" {{classname}} + //Assert.IsType<{{classname}}>(instance); + } + + {{#discriminator}} + {{#children}} + /// + /// Test deserialize a {{classname}} from type {{parent}} + /// + [Fact] + public void {{classname}}DeserializeFrom{{parent}}Test() + { + // TODO uncomment below to test deserialize a {{classname}} from type {{parent}} + //Assert.IsType<{{parent}}>(JsonConvert.DeserializeObject<{{parent}}>(new {{classname}}().ToJson())); + } + {{/children}} + {{/discriminator}} + + {{#vars}} + /// + /// Test the property '{{name}}' + /// + [Fact] + public void {{name}}Test() + { + // TODO unit test for the property '{{name}}' + } + {{/vars}} + + } + +} +{{/model}} +{{/models}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/netcore_project.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/netcore_project.mustache index 456feeeed393..650dcb9247c7 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/netcore_project.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/netcore_project.mustache @@ -26,13 +26,13 @@ {{#useCompareNetObjects}} {{/useCompareNetObjects}} - + - - + {{#validatable}} - + {{/validatable}} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES b/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES index 4f2382c7e38d..29f9ff544d92 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES @@ -1,10 +1,7 @@ .gitignore README.md -apis/PetApi.service.ts apis/PetApi.ts -apis/StoreApi.service.ts apis/StoreApi.ts -apis/UserApi.service.ts apis/UserApi.ts apis/baseapi.ts apis/exception.ts @@ -26,12 +23,6 @@ models/all.ts package.json rxjsStub.ts servers.ts -services/ObjectParamAPI.ts -services/ObservableAPI.ts -services/PromiseAPI.ts -services/configuration.ts -services/http.ts -services/index.ts tsconfig.json types/ObjectParamAPI.ts types/ObservableAPI.ts diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts index c97b44cf0893..7041341a7089 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts @@ -6,7 +6,6 @@ import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; -import { injectable } from "inversify"; import { ApiResponse } from '../models/ApiResponse'; import { Pet } from '../models/Pet'; @@ -14,7 +13,6 @@ import { Pet } from '../models/Pet'; /** * no description */ -@injectable() export class PetApiRequestFactory extends BaseAPIRequestFactory { /** @@ -399,7 +397,6 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { -@injectable() export class PetApiResponseProcessor { /** diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts index ceef209c37db..09400e99c083 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts @@ -6,14 +6,12 @@ import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; -import { injectable } from "inversify"; import { Order } from '../models/Order'; /** * no description */ -@injectable() export class StoreApiRequestFactory extends BaseAPIRequestFactory { /** @@ -168,7 +166,6 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { -@injectable() export class StoreApiResponseProcessor { /** diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts index 353bae433c58..1d43ec7a72b4 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts @@ -6,14 +6,12 @@ import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; -import { injectable } from "inversify"; import { User } from '../models/User'; /** * no description */ -@injectable() export class UserApiRequestFactory extends BaseAPIRequestFactory { /** @@ -377,7 +375,6 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { -@injectable() export class UserApiResponseProcessor { /** diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts index cf8fec079eb3..fe7ee3d15118 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts @@ -1,6 +1,4 @@ import { Configuration } from '../configuration' -import { injectable, inject } from "inversify"; -import { AbstractConfiguration } from "../services/configuration"; /** * @@ -19,10 +17,9 @@ export const COLLECTION_FORMATS = { * @export * @class BaseAPI */ -@injectable() export class BaseAPIRequestFactory { - constructor(@inject(AbstractConfiguration) protected configuration: Configuration) { + constructor(protected configuration: Configuration) { } }; diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts index 13e3b17fa825..9d59a0a25580 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts @@ -2,8 +2,6 @@ //@ts-ignore import * as btoa from "btoa"; import { RequestContext } from "../http/http"; -import { injectable, inject, named } from "inversify"; -import { AbstractTokenProvider } from "../services/configuration"; /** * Interface authentication schemes. @@ -22,10 +20,6 @@ export interface SecurityAuthentication { applySecurityAuthentication(context: RequestContext): void | Promise; } -export const AuthApiKey = Symbol("auth.api_key"); -export const AuthUsername = Symbol("auth.username"); -export const AuthPassword = Symbol("auth.password"); - export interface TokenProvider { getToken(): Promise | string; } @@ -33,14 +27,13 @@ export interface TokenProvider { /** * Applies apiKey authentication to the request context. */ -@injectable() export class ApiKeyAuthentication implements SecurityAuthentication { /** * Configures this api key authentication with the necessary properties * * @param apiKey: The api key to be used for every request */ - public constructor(@inject(AuthApiKey) @named("api_key") private apiKey: string) {} + public constructor(private apiKey: string) {} public getName(): string { return "api_key"; @@ -54,7 +47,6 @@ export class ApiKeyAuthentication implements SecurityAuthentication { /** * Applies oauth2 authentication to the request context. */ -@injectable() export class PetstoreAuthAuthentication implements SecurityAuthentication { // TODO: How to handle oauth2 authentication! public constructor() {} @@ -74,11 +66,6 @@ export type AuthMethods = { "petstore_auth"?: SecurityAuthentication } -export const authMethodServices = { - "api_key": ApiKeyAuthentication, - "petstore_auth": PetstoreAuthAuthentication -} - export type ApiKeyConfiguration = string; export type HttpBasicConfiguration = { "username": string, "password": string }; export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts index 4d48e5222adf..de89bb05e702 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts @@ -9,5 +9,3 @@ export * from "./servers"; export { PromiseMiddleware as Middleware } from './middleware'; export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI'; -export * from "./services/index"; -export { AbstractPromisePetApi as AbstractPetApi, AbstractPromiseStoreApi as AbstractStoreApi, AbstractPromiseUserApi as AbstractUserApi } from './services/PromiseAPI'; diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/package.json b/samples/openapi3/client/petstore/typescript/builds/inversify/package.json index 71908ad48cae..f26767636102 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/package.json +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/package.json @@ -22,7 +22,6 @@ "@types/node": "*", "form-data": "^2.5.0", "btoa": "^1.2.1", - "inversify": "^5.0.1", "es6-promise": "^4.2.4", "url-parse": "^1.4.3" }, diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json b/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json index b53dce7b41b3..a542d795677c 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json @@ -18,7 +18,6 @@ "outDir": "./dist", "noLib": false, "lib": [ "es6" ], - "experimentalDecorators": true, }, "exclude": [ "dist", diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts index 31ced8bbdca3..6154d267ed3a 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts @@ -3,8 +3,6 @@ import * as models from '../models/all'; import { Configuration} from '../configuration' import { Observable, of, from } from '../rxjsStub'; import {mergeMap, map} from '../rxjsStub'; -import { injectable, inject, optional } from "inversify"; -import { AbstractConfiguration } from "../services/configuration"; import { ApiResponse } from '../models/ApiResponse'; import { Category } from '../models/Category'; @@ -14,18 +12,15 @@ import { Tag } from '../models/Tag'; import { User } from '../models/User'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; -import { AbstractPetApiRequestFactory, AbstractPetApiResponseProcessor } from "../apis/PetApi.service"; - -@injectable() export class ObservablePetApi { - private requestFactory: AbstractPetApiRequestFactory; - private responseProcessor: AbstractPetApiResponseProcessor; + private requestFactory: PetApiRequestFactory; + private responseProcessor: PetApiResponseProcessor; private configuration: Configuration; public constructor( - @inject(AbstractConfiguration) configuration: Configuration, - @inject(AbstractPetApiRequestFactory) @optional() requestFactory?: AbstractPetApiRequestFactory, - @inject(AbstractPetApiResponseProcessor) @optional() responseProcessor?: AbstractPetApiResponseProcessor + configuration: Configuration, + requestFactory?: PetApiRequestFactory, + responseProcessor?: PetApiResponseProcessor ) { this.configuration = configuration; this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); @@ -231,18 +226,15 @@ export class ObservablePetApi { import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; -import { AbstractStoreApiRequestFactory, AbstractStoreApiResponseProcessor } from "../apis/StoreApi.service"; - -@injectable() export class ObservableStoreApi { - private requestFactory: AbstractStoreApiRequestFactory; - private responseProcessor: AbstractStoreApiResponseProcessor; + private requestFactory: StoreApiRequestFactory; + private responseProcessor: StoreApiResponseProcessor; private configuration: Configuration; public constructor( - @inject(AbstractConfiguration) configuration: Configuration, - @inject(AbstractStoreApiRequestFactory) @optional() requestFactory?: AbstractStoreApiRequestFactory, - @inject(AbstractStoreApiResponseProcessor) @optional() responseProcessor?: AbstractStoreApiResponseProcessor + configuration: Configuration, + requestFactory?: StoreApiRequestFactory, + responseProcessor?: StoreApiResponseProcessor ) { this.configuration = configuration; this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); @@ -350,18 +342,15 @@ export class ObservableStoreApi { import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; -import { AbstractUserApiRequestFactory, AbstractUserApiResponseProcessor } from "../apis/UserApi.service"; - -@injectable() export class ObservableUserApi { - private requestFactory: AbstractUserApiRequestFactory; - private responseProcessor: AbstractUserApiResponseProcessor; + private requestFactory: UserApiRequestFactory; + private responseProcessor: UserApiResponseProcessor; private configuration: Configuration; public constructor( - @inject(AbstractConfiguration) configuration: Configuration, - @inject(AbstractUserApiRequestFactory) @optional() requestFactory?: AbstractUserApiRequestFactory, - @inject(AbstractUserApiResponseProcessor) @optional() responseProcessor?: AbstractUserApiResponseProcessor + configuration: Configuration, + requestFactory?: UserApiRequestFactory, + responseProcessor?: UserApiResponseProcessor ) { this.configuration = configuration; this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts index 6077fdac2d59..533095a405d6 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts @@ -1,8 +1,6 @@ import { ResponseContext, RequestContext, HttpFile } from '../http/http'; import * as models from '../models/all'; import { Configuration} from '../configuration' -import { injectable, inject, optional } from "inversify"; -import { AbstractConfiguration } from "../services/configuration"; import { ApiResponse } from '../models/ApiResponse'; import { Category } from '../models/Category'; @@ -14,16 +12,13 @@ import { ObservablePetApi } from './ObservableAPI'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; -import { AbstractPetApiRequestFactory, AbstractPetApiResponseProcessor } from "../apis/PetApi.service"; - -@injectable() export class PromisePetApi { private api: ObservablePetApi public constructor( - @inject(AbstractConfiguration) configuration: Configuration, - @inject(AbstractPetApiRequestFactory) @optional() requestFactory?: AbstractPetApiRequestFactory, - @inject(AbstractPetApiResponseProcessor) @optional() responseProcessor?: AbstractPetApiResponseProcessor + configuration: Configuration, + requestFactory?: PetApiRequestFactory, + responseProcessor?: PetApiResponseProcessor ) { this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); } @@ -117,16 +112,13 @@ import { ObservableStoreApi } from './ObservableAPI'; import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; -import { AbstractStoreApiRequestFactory, AbstractStoreApiResponseProcessor } from "../apis/StoreApi.service"; - -@injectable() export class PromiseStoreApi { private api: ObservableStoreApi public constructor( - @inject(AbstractConfiguration) configuration: Configuration, - @inject(AbstractStoreApiRequestFactory) @optional() requestFactory?: AbstractStoreApiRequestFactory, - @inject(AbstractStoreApiResponseProcessor) @optional() responseProcessor?: AbstractStoreApiResponseProcessor + configuration: Configuration, + requestFactory?: StoreApiRequestFactory, + responseProcessor?: StoreApiResponseProcessor ) { this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); } @@ -178,16 +170,13 @@ import { ObservableUserApi } from './ObservableAPI'; import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; -import { AbstractUserApiRequestFactory, AbstractUserApiResponseProcessor } from "../apis/UserApi.service"; - -@injectable() export class PromiseUserApi { private api: ObservableUserApi public constructor( - @inject(AbstractConfiguration) configuration: Configuration, - @inject(AbstractUserApiRequestFactory) @optional() requestFactory?: AbstractUserApiRequestFactory, - @inject(AbstractUserApiResponseProcessor) @optional() responseProcessor?: AbstractUserApiResponseProcessor + configuration: Configuration, + requestFactory?: UserApiRequestFactory, + responseProcessor?: UserApiResponseProcessor ) { this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); } From 60c0ed527e6058f7327227e467329e864d5a8e30 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sun, 17 Jan 2021 21:26:23 -0500 Subject: [PATCH 02/20] refactored models --- .../libraries/httpclient/ApiResponse.mustache | 2 +- .../libraries/httpclient/api_test.mustache | 10 +- .../resources/csharp-netcore/model.mustache | 4 +- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 307 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 289 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 3645 ++++------------- .../Api/FakeClassnameTags123Api.cs | 320 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 2154 +++------- .../src/Org.OpenAPITools/Api/StoreApi.cs | 857 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 1621 ++------ .../src/Org.OpenAPITools/Client/ApiClient.cs | 834 ---- .../Org.OpenAPITools/Client/ApiException.cs | 60 +- .../Org.OpenAPITools/Client/ApiResponse.cs | 119 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 21 + .../Org.OpenAPITools/Client/Configuration.cs | 587 --- .../Client/GlobalConfiguration.cs | 67 - .../Client/RetryConfiguration.cs | 21 - .../Model/AdditionalPropertiesClass.cs | 80 +- .../src/Org.OpenAPITools/Model/Animal.cs | 48 +- .../src/Org.OpenAPITools/Model/ApiResponse.cs | 49 +- .../src/Org.OpenAPITools/Model/Apple.cs | 44 +- .../src/Org.OpenAPITools/Model/AppleReq.cs | 38 +- .../Model/ArrayOfArrayOfNumberOnly.cs | 38 +- .../Model/ArrayOfNumberOnly.cs | 38 +- .../src/Org.OpenAPITools/Model/ArrayTest.cs | 50 +- .../src/Org.OpenAPITools/Model/Banana.cs | 37 +- .../src/Org.OpenAPITools/Model/BananaReq.cs | 37 +- .../src/Org.OpenAPITools/Model/BasquePig.cs | 40 +- .../Org.OpenAPITools/Model/Capitalization.cs | 68 +- .../src/Org.OpenAPITools/Model/Cat.cs | 42 +- .../src/Org.OpenAPITools/Model/CatAllOf.cs | 37 +- .../src/Org.OpenAPITools/Model/Category.cs | 45 +- .../src/Org.OpenAPITools/Model/ChildCat.cs | 52 +- .../Org.OpenAPITools/Model/ChildCatAllOf.cs | 46 +- .../src/Org.OpenAPITools/Model/ClassModel.cs | 38 +- .../Model/ComplexQuadrilateral.cs | 47 +- .../src/Org.OpenAPITools/Model/DanishPig.cs | 40 +- .../src/Org.OpenAPITools/Model/Dog.cs | 43 +- .../src/Org.OpenAPITools/Model/DogAllOf.cs | 38 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 52 +- .../src/Org.OpenAPITools/Model/EnumArrays.cs | 48 +- .../src/Org.OpenAPITools/Model/EnumClass.cs | 3 - .../src/Org.OpenAPITools/Model/EnumTest.cs | 88 +- .../Model/EquilateralTriangle.cs | 47 +- .../src/Org.OpenAPITools/Model/File.cs | 38 +- .../Model/FileSchemaTestClass.cs | 44 +- .../src/Org.OpenAPITools/Model/Foo.cs | 38 +- .../src/Org.OpenAPITools/Model/FormatTest.cs | 128 +- .../src/Org.OpenAPITools/Model/Fruit.cs | 3 - .../src/Org.OpenAPITools/Model/FruitReq.cs | 3 - .../src/Org.OpenAPITools/Model/GmFruit.cs | 4 +- .../Model/GrandparentAnimal.cs | 42 +- .../Org.OpenAPITools/Model/HasOnlyReadOnly.cs | 38 +- .../Model/HealthCheckResult.cs | 38 +- .../Model/InlineResponseDefault.cs | 38 +- .../Model/IsoscelesTriangle.cs | 40 +- .../src/Org.OpenAPITools/Model/List.cs | 38 +- .../src/Org.OpenAPITools/Model/Mammal.cs | 3 - .../src/Org.OpenAPITools/Model/MapTest.cs | 58 +- ...dPropertiesAndAdditionalPropertiesClass.cs | 50 +- .../Model/Model200Response.cs | 43 +- .../src/Org.OpenAPITools/Model/ModelClient.cs | 38 +- .../src/Org.OpenAPITools/Model/Name.cs | 51 +- .../Org.OpenAPITools/Model/NullableClass.cs | 102 +- .../Org.OpenAPITools/Model/NullableShape.cs | 3 - .../src/Org.OpenAPITools/Model/NumberOnly.cs | 37 +- .../src/Org.OpenAPITools/Model/Order.cs | 66 +- .../Org.OpenAPITools/Model/OuterComposite.cs | 48 +- .../src/Org.OpenAPITools/Model/OuterEnum.cs | 3 - .../Model/OuterEnumDefaultValue.cs | 3 - .../Model/OuterEnumInteger.cs | 3 - .../Model/OuterEnumIntegerDefaultValue.cs | 3 - .../src/Org.OpenAPITools/Model/ParentPet.cs | 37 +- .../src/Org.OpenAPITools/Model/Pet.cs | 72 +- .../src/Org.OpenAPITools/Model/Pig.cs | 3 - .../Org.OpenAPITools/Model/Quadrilateral.cs | 3 - .../Model/QuadrilateralInterface.cs | 40 +- .../Org.OpenAPITools/Model/ReadOnlyFirst.cs | 42 +- .../src/Org.OpenAPITools/Model/Return.cs | 37 +- .../Org.OpenAPITools/Model/ScaleneTriangle.cs | 47 +- .../src/Org.OpenAPITools/Model/Shape.cs | 3 - .../Org.OpenAPITools/Model/ShapeInterface.cs | 40 +- .../src/Org.OpenAPITools/Model/ShapeOrNull.cs | 3 - .../Model/SimpleQuadrilateral.cs | 47 +- .../Model/SpecialModelName.cs | 37 +- .../src/Org.OpenAPITools/Model/Tag.cs | 43 +- .../src/Org.OpenAPITools/Model/Triangle.cs | 3 - .../Model/TriangleInterface.cs | 40 +- .../src/Org.OpenAPITools/Model/User.cs | 102 +- .../src/Org.OpenAPITools/Model/Whale.cs | 50 +- .../src/Org.OpenAPITools/Model/Zebra.cs | 50 +- .../Org.OpenAPITools/Org.OpenAPITools.csproj | 8 +- .../src/Org.OpenAPITools/Model/GmFruit.cs | 1 + .../src/Org.OpenAPITools/Model/GmFruit.cs | 1 + .../src/Org.OpenAPITools/Model/GmFruit.cs | 1 + .../builds/inversify/.openapi-generator/FILES | 9 + .../builds/inversify/apis/PetApi.ts | 3 + .../builds/inversify/apis/StoreApi.ts | 3 + .../builds/inversify/apis/UserApi.ts | 3 + .../builds/inversify/apis/baseapi.ts | 5 +- .../typescript/builds/inversify/auth/auth.ts | 15 +- .../typescript/builds/inversify/index.ts | 2 + .../typescript/builds/inversify/package.json | 1 + .../typescript/builds/inversify/tsconfig.json | 1 + .../builds/inversify/types/ObservableAPI.ts | 41 +- .../builds/inversify/types/PromiseAPI.ts | 29 +- .../org/openapitools/server/apis/PetApi.kt | 352 +- .../org/openapitools/server/apis/StoreApi.kt | 170 +- .../org/openapitools/server/apis/UserApi.kt | 196 +- 109 files changed, 3430 insertions(+), 11264 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache index 5bb4b0261573..29675f21fa2d 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache @@ -37,7 +37,7 @@ namespace {{packageName}}.Client /// /// API Response /// - public class ApiResponse : IApiResponse + {{>visibility}} partial class ApiResponse : IApiResponse { #region Properties diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api_test.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api_test.mustache index 65a16c67e0c6..87187868dfad 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api_test.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api_test.mustache @@ -25,11 +25,13 @@ namespace {{packageName}}.Test.Api /// public class {{classname}}Tests : IDisposable { - private {{classname}} instance; + private readonly {{classname}} _instance; + + private readonly System.Net.Http.HttpClient _httpClient = new System.Net.Http.HttpClient(); public {{classname}}Tests() { - //instance = new {{classname}}(); + //_instance = new {{classname}}(_httpClient); } public void Dispose() @@ -44,7 +46,7 @@ namespace {{packageName}}.Test.Api public void {{operationId}}InstanceTest() { // TODO uncomment below to test 'IsType' {{classname}} - //Assert.IsType<{{classname}}>(instance); + //Assert.IsType<{{classname}}>(_instance); } {{#operations}} {{#operation}} @@ -59,7 +61,7 @@ namespace {{packageName}}.Test.Api {{#allParams}} //{{{dataType}}} {{paramName}} = null; {{/allParams}} - //{{#returnType}}var response = {{/returnType}}instance.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); + //{{#returnType}}var response = {{/returnType}}_instance.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); {{#returnType}} //Assert.IsType<{{{returnType}}}>(response); {{/returnType}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/model.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/model.mustache index 339a6d2f76b7..bcc56c75044f 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/model.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/model.mustache @@ -33,11 +33,11 @@ using OpenAPIClientUtils = {{packageName}}.Client.ClientUtils; using System.Reflection; {{/-first}} {{/oneOf}} -{{#aneOf}} +{{#anyOf}} {{#-first}} using System.Reflection; {{/-first}} -{{/aneOf}} +{{/anyOf}} namespace {{packageName}}.{{modelPackage}} { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index ddf2cbb44a88..0d6ff9ad905b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -19,24 +19,11 @@ namespace Org.OpenAPITools.Api { - /// /// Represents a collection of functions to interact with the API endpoints /// - public interface IAnotherFakeApiSync : IApiAccessor + public interface IAnotherFakeApi { - #region Synchronous Operations - /// - /// To test special tags - /// - /// - /// To test special tags and operation ID starting with number - /// - /// Thrown when fails to make API call - /// client model - /// ModelClient - ModelClient Call123TestSpecialTags(ModelClient modelClient); - /// /// To test special tags /// @@ -45,17 +32,10 @@ public interface IAnotherFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// client model - /// ApiResponse of ModelClient - ApiResponse Call123TestSpecialTagsResponse(ModelClient modelClient); - #endregion Synchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IAnotherFakeApiAsync : IApiAccessor - { - #region Asynchronous Operations + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ModelClient) + System.Threading.Tasks.Task> Call123TestSpecialTagsWithHttpInfoAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); + /// /// To test special tags /// @@ -65,29 +45,19 @@ public interface IAnotherFakeApiAsync : IApiAccessor /// Thrown when fails to make API call /// client model /// Cancellation Token to cancel the request. - /// Task of ModelClient + /// Task of ApiResponse (ModelClient) System.Threading.Tasks.Task Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); - + /// /// To test special tags /// /// /// To test special tags and operation ID starting with number /// - /// Thrown when fails to make API call /// client model /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ModelClient) - System.Threading.Tasks.Task> Call123TestSpecialTagsResponseAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IAnotherFakeApi : IAnotherFakeApiSync, IAnotherFakeApiAsync - { - + /// Task of ApiResponse (ModelClient?) + System.Threading.Tasks.Task Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); } /// @@ -95,177 +65,42 @@ public interface IAnotherFakeApi : IAnotherFakeApiSync, IAnotherFakeApiAsync /// public partial class AnotherFakeApi : IAnotherFakeApi { - private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null; private readonly System.Net.Http.HttpClient _httpClient; - private readonly Newtonsoft.Json.JsonConverter[] _jsonConverters; - - /// - /// Initializes a new instance of the class. - /// - /// - public AnotherFakeApi() : this((string)null) - { - } /// /// Initializes a new instance of the class. /// /// - public AnotherFakeApi(System.Net.Http.HttpClient httpClient, Newtonsoft.Json.JsonConverter[] jsonConverters) : this((string)null) + public AnotherFakeApi(System.Net.Http.HttpClient httpClient) { _httpClient = httpClient; - - _jsonConverters = jsonConverters; - } - - /// - /// Initializes a new instance of the class. - /// - /// - public AnotherFakeApi(String basePath) - { - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public AnotherFakeApi(Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; } /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. + /// Returns the token to be used in the api query /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public AnotherFakeApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } + public Func>? GetTokenAsync { get; set; } - /// - /// The client for accessing this underlying API asynchronously. - /// - public Org.OpenAPITools.Client.IAsynchronousClient AsynchronousClient { get; set; } /// - /// The client for accessing this underlying API synchronously. + /// Validate the input before sending the request /// - public Org.OpenAPITools.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public Org.OpenAPITools.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public Org.OpenAPITools.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } - - /// - /// To test special tags To test special tags and operation ID starting with number - /// - /// Thrown when fails to make API call /// client model - /// ModelClient - public ModelClient Call123TestSpecialTags(ModelClient modelClient) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = Call123TestSpecialTagsResponse(modelClient); - return localVarResponse.Data; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateCall123TestSpecialTagsRequestAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// To test special tags To test special tags and operation ID starting with number /// /// Thrown when fails to make API call /// client model - /// ApiResponse of ModelClient - public Org.OpenAPITools.Client.ApiResponse Call123TestSpecialTagsResponse(ModelClient modelClient) + /// Cancellation Token to cancel the request. + /// Task of ModelClient + public async System.Threading.Tasks.Task Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'modelClient' is set - if (modelClient == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'modelClient' when calling AnotherFakeApi->Call123TestSpecialTags"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = modelClient; - - - // make the HTTP request - var localVarResponse = this.Client.Patch("/another-fake/dummy", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("Call123TestSpecialTags", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse result = await Call123TestSpecialTagsWithHttpInfoAsync(modelClient, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -275,17 +110,14 @@ public Org.OpenAPITools.Client.ApiResponse Call123TestSpecialTagsRe /// client model /// Cancellation Token to cancel the request. /// Task of ModelClient - public async System.Threading.Tasks.Task Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await Call123TestSpecialTagsResponseAsync(modelClient, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateCall123TestSpecialTagsRequestAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await Call123TestSpecialTagsWithHttpInfoAsync(modelClient, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// To test special tags To test special tags and operation ID starting with number @@ -294,90 +126,55 @@ private System.Threading.Tasks.ValueTask ValidateCall123TestSpecialTagsRequestAs /// client model /// Cancellation Token to cancel the request. /// Task of ApiResponse (ModelClient) - public async System.Threading.Tasks.Task> Call123TestSpecialTagsResponseAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> Call123TestSpecialTagsWithHttpInfoAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'modelClient' is set if (modelClient == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'modelClient' when calling AnotherFakeApi->Call123TestSpecialTags"); - - await ValidateCall123TestSpecialTagsRequestAsync(modelClient, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/another-fake/dummy"; - - path = $"{path}?"; - + throw new ArgumentNullException(nameof(modelClient)); - if (path.EndsWith("&")) - path = path[..^1]; + await ValidateCall123TestSpecialTagsRequestAsync(modelClient, cancellationToken).ConfigureAwait(false); - if (path.EndsWith("?")) - path = path[..^1]; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + string path = "/another-fake/dummy"; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + path = $"{path}?"; + - string[] contentTypes = new string[] { - "application/json" - }; + if (path.EndsWith("&")) + path = path[..^1]; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + if (path.EndsWith("?")) + path = path[..^1]; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - ApiResponse apiResponse = new(responseMessage, responseContent); + // todo localVarRequestOptions.Data = modelClient; - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - return apiResponse; - } + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - "application/json" - }; - - // to determine the Accept header - string[] _accepts = new string[] { + string[] contentTypes = new string[] { "application/json" }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - localVarRequestOptions.Data = modelClient; + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - // make the HTTP request + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - var localVarResponse = await this.AsynchronousClient.PatchAsync("/another-fake/dummy", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("Call123TestSpecialTags", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs index 8e202853bfec..5ee6e54c869a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -19,20 +19,11 @@ namespace Org.OpenAPITools.Api { - /// /// Represents a collection of functions to interact with the API endpoints /// - public interface IDefaultApiSync : IApiAccessor + public interface IDefaultApi { - #region Synchronous Operations - /// - /// - /// - /// Thrown when fails to make API call - /// InlineResponseDefault - InlineResponseDefault FooGet(); - /// /// /// @@ -40,17 +31,10 @@ public interface IDefaultApiSync : IApiAccessor /// /// /// Thrown when fails to make API call - /// ApiResponse of InlineResponseDefault - ApiResponse FooGetResponse(); - #endregion Synchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IDefaultApiAsync : IApiAccessor - { - #region Asynchronous Operations + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (InlineResponseDefault) + System.Threading.Tasks.Task> FooGetWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null); + /// /// /// @@ -59,28 +43,18 @@ public interface IDefaultApiAsync : IApiAccessor /// /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of InlineResponseDefault + /// Task of ApiResponse (InlineResponseDefault) System.Threading.Tasks.Task FooGetAsync(System.Threading.CancellationToken? cancellationToken = null); - + /// /// /// /// /// /// - /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (InlineResponseDefault) - System.Threading.Tasks.Task> FooGetResponseAsync(System.Threading.CancellationToken? cancellationToken = null); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IDefaultApi : IDefaultApiSync, IDefaultApiAsync - { - + /// Task of ApiResponse (InlineResponseDefault?) + System.Threading.Tasks.Task FooGetOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null); } /// @@ -88,169 +62,40 @@ public interface IDefaultApi : IDefaultApiSync, IDefaultApiAsync /// public partial class DefaultApi : IDefaultApi { - private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null; private readonly System.Net.Http.HttpClient _httpClient; - private readonly Newtonsoft.Json.JsonConverter[] _jsonConverters; /// /// Initializes a new instance of the class. /// /// - public DefaultApi() : this((string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - public DefaultApi(System.Net.Http.HttpClient httpClient, Newtonsoft.Json.JsonConverter[] jsonConverters) : this((string)null) + public DefaultApi(System.Net.Http.HttpClient httpClient) { _httpClient = httpClient; - - _jsonConverters = jsonConverters; - } - - /// - /// Initializes a new instance of the class. - /// - /// - public DefaultApi(String basePath) - { - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public DefaultApi(Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public DefaultApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; } /// - /// The client for accessing this underlying API asynchronously. + /// Returns the token to be used in the api query /// - public Org.OpenAPITools.Client.IAsynchronousClient AsynchronousClient { get; set; } + public Func>? GetTokenAsync { get; set; } - /// - /// The client for accessing this underlying API synchronously. - /// - public Org.OpenAPITools.Client.ISynchronousClient Client { get; set; } /// - /// Gets the base path of the API client. + /// Validate the input before sending the request /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public Org.OpenAPITools.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public Org.OpenAPITools.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFooGetRequestAsync(System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// /// /// Thrown when fails to make API call - /// InlineResponseDefault - public InlineResponseDefault FooGet() + /// Cancellation Token to cancel the request. + /// Task of InlineResponseDefault + public async System.Threading.Tasks.Task FooGetAsync(System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.ApiResponse localVarResponse = FooGetResponse(); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of InlineResponseDefault - public Org.OpenAPITools.Client.ApiResponse FooGetResponse() - { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - var localVarResponse = this.Client.Get("/foo", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FooGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse result = await FooGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -259,17 +104,14 @@ public Org.OpenAPITools.Client.ApiResponse FooGetResponse /// Thrown when fails to make API call /// Cancellation Token to cancel the request. /// Task of InlineResponseDefault - public async System.Threading.Tasks.Task FooGetAsync(System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task FooGetOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await FooGetResponseAsync(cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateFooGetRequestAsync(System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await FooGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// @@ -277,83 +119,50 @@ private System.Threading.Tasks.ValueTask ValidateFooGetRequestAsync(System.Threa /// Thrown when fails to make API call /// Cancellation Token to cancel the request. /// Task of ApiResponse (InlineResponseDefault) - public async System.Threading.Tasks.Task> FooGetResponseAsync(System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> FooGetWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { - await ValidateFooGetRequestAsync(cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/foo"; - - path = $"{path}?"; - + await ValidateFooGetRequestAsync(cancellationToken).ConfigureAwait(false); - if (path.EndsWith("&")) - path = path[..^1]; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - if (path.EndsWith("?")) - path = path[..^1]; + string path = "/foo"; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + path = $"{path}?"; + + if (path.EndsWith("&")) + path = path[..^1]; - string[] contentTypes = new string[] { - }; + if (path.EndsWith("?")) + path = path[..^1]; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - ApiResponse apiResponse = new(responseMessage, responseContent); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - }; - - // to determine the Accept header - string[] _accepts = new string[] { - "application/json" + string[] contentTypes = new string[] { }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - // make the HTTP request + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - var localVarResponse = await this.AsynchronousClient.GetAsync("/foo", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FooGet", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs index f8668dd70a25..f4aee0c37628 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs @@ -19,20 +19,22 @@ namespace Org.OpenAPITools.Api { - /// /// Represents a collection of functions to interact with the API endpoints /// - public interface IFakeApiSync : IApiAccessor + public interface IFakeApi { - #region Synchronous Operations /// /// Health check endpoint /// + /// + /// + /// /// Thrown when fails to make API call - /// HealthCheckResult - HealthCheckResult FakeHealthGet(); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (HealthCheckResult) + System.Threading.Tasks.Task> FakeHealthGetWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null); + /// /// Health check endpoint /// @@ -40,8 +42,19 @@ public interface IFakeApiSync : IApiAccessor /// /// /// Thrown when fails to make API call - /// ApiResponse of HealthCheckResult - ApiResponse FakeHealthGetResponse(); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (HealthCheckResult) + System.Threading.Tasks.Task FakeHealthGetAsync(System.Threading.CancellationToken? cancellationToken = null); + + /// + /// Health check endpoint + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (HealthCheckResult?) + System.Threading.Tasks.Task FakeHealthGetOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null); /// /// /// @@ -50,9 +63,10 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// Input boolean as post body (optional) - /// bool - bool FakeOuterBooleanSerialize(bool? body = default(bool?)); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (bool) + System.Threading.Tasks.Task> FakeOuterBooleanSerializeWithHttpInfoAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// /// @@ -61,8 +75,20 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// Input boolean as post body (optional) - /// ApiResponse of bool - ApiResponse FakeOuterBooleanSerializeResponse(bool? body = default(bool?)); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (bool) + System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// + /// + /// + /// Test serialization of outer boolean types + /// + /// Input boolean as post body (optional) + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (bool?) + System.Threading.Tasks.Task FakeOuterBooleanSerializeOrDefaultAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null); /// /// /// @@ -71,9 +97,10 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// Input composite as post body (optional) - /// OuterComposite - OuterComposite FakeOuterCompositeSerialize(OuterComposite outerComposite = default(OuterComposite)); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (OuterComposite) + System.Threading.Tasks.Task> FakeOuterCompositeSerializeWithHttpInfoAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// /// @@ -82,8 +109,20 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// Input composite as post body (optional) - /// ApiResponse of OuterComposite - ApiResponse FakeOuterCompositeSerializeResponse(OuterComposite outerComposite = default(OuterComposite)); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (OuterComposite) + System.Threading.Tasks.Task FakeOuterCompositeSerializeAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// + /// + /// + /// Test serialization of object with outer number type + /// + /// Input composite as post body (optional) + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (OuterComposite?) + System.Threading.Tasks.Task FakeOuterCompositeSerializeOrDefaultAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null); /// /// /// @@ -92,9 +131,10 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// Input number as post body (optional) - /// decimal - decimal FakeOuterNumberSerialize(decimal? body = default(decimal?)); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (decimal) + System.Threading.Tasks.Task> FakeOuterNumberSerializeWithHttpInfoAsync(decimal???? body = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// /// @@ -103,8 +143,20 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// Input number as post body (optional) - /// ApiResponse of decimal - ApiResponse FakeOuterNumberSerializeResponse(decimal? body = default(decimal?)); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (decimal) + System.Threading.Tasks.Task FakeOuterNumberSerializeAsync(decimal???? body = null, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// + /// + /// + /// Test serialization of outer number types + /// + /// Input number as post body (optional) + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (decimal?) + System.Threading.Tasks.Task FakeOuterNumberSerializeOrDefaultAsync(decimal???? body = null, System.Threading.CancellationToken? cancellationToken = null); /// /// /// @@ -113,9 +165,10 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// Input string as post body (optional) - /// string - string FakeOuterStringSerialize(string body = default(string)); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (string) + System.Threading.Tasks.Task> FakeOuterStringSerializeWithHttpInfoAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// /// @@ -124,15 +177,31 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// Input string as post body (optional) - /// ApiResponse of string - ApiResponse FakeOuterStringSerializeResponse(string body = default(string)); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (string) + System.Threading.Tasks.Task FakeOuterStringSerializeAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// + /// + /// + /// Test serialization of outer string types + /// + /// Input string as post body (optional) + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (string?) + System.Threading.Tasks.Task FakeOuterStringSerializeOrDefaultAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null); /// /// Array of Enums /// + /// + /// + /// /// Thrown when fails to make API call - /// List<OuterEnum> - List GetArrayOfEnums(); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (List<OuterEnum>) + System.Threading.Tasks.Task>> GetArrayOfEnumsWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null); + /// /// Array of Enums /// @@ -140,8 +209,19 @@ public interface IFakeApiSync : IApiAccessor /// /// /// Thrown when fails to make API call - /// ApiResponse of List<OuterEnum> - ApiResponse> GetArrayOfEnumsResponse(); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (List<OuterEnum>) + System.Threading.Tasks.Task> GetArrayOfEnumsAsync(System.Threading.CancellationToken? cancellationToken = null); + + /// + /// Array of Enums + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (List<OuterEnum>?) + System.Threading.Tasks.Task?> GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null); /// /// /// @@ -150,9 +230,10 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// - /// - void TestBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> TestBodyWithFileSchemaWithHttpInfoAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken? cancellationToken = null); + /// /// /// @@ -161,17 +242,23 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// - /// ApiResponse of Object(void) - ApiResponse TestBodyWithFileSchemaResponse(FileSchemaTestClass fileSchemaTestClass); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task TestBodyWithFileSchemaAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken? cancellationToken = null); + /// /// /// + /// + /// + /// /// Thrown when fails to make API call /// /// - /// - void TestBodyWithQueryParams(string query, User user); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> TestBodyWithQueryParamsWithHttpInfoAsync(string query, User user, System.Threading.CancellationToken? cancellationToken = null); + /// /// /// @@ -181,8 +268,10 @@ public interface IFakeApiSync : IApiAccessor /// Thrown when fails to make API call /// /// - /// ApiResponse of Object(void) - ApiResponse TestBodyWithQueryParamsResponse(string query, User user); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task TestBodyWithQueryParamsAsync(string query, User user, System.Threading.CancellationToken? cancellationToken = null); + /// /// To test \"client\" model /// @@ -191,9 +280,10 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// client model - /// ModelClient - ModelClient TestClientModel(ModelClient modelClient); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ModelClient) + System.Threading.Tasks.Task> TestClientModelWithHttpInfoAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); + /// /// To test \"client\" model /// @@ -202,8 +292,20 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// client model - /// ApiResponse of ModelClient - ApiResponse TestClientModelResponse(ModelClient modelClient); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ModelClient) + System.Threading.Tasks.Task TestClientModelAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// To test \"client\" model + /// + /// + /// To test \"client\" model + /// + /// client model + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ModelClient?) + System.Threading.Tasks.Task TestClientModelOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 /// @@ -225,9 +327,10 @@ public interface IFakeApiSync : IApiAccessor /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") /// None (optional) /// None (optional) - /// - void TestEndpointParameters(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int? integer = default(int?), int? int32 = default(int?), long? int64 = default(long?), float? _float = default(float?), string _string = default(string), System.IO.Stream binary = default(System.IO.Stream), DateTime? date = default(DateTime?), DateTime? dateTime = default(DateTime?), string password = default(string), string callback = default(string)); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> TestEndpointParametersWithHttpInfoAsync(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int???? integer = null, int???? int32 = null, long???? int64 = null, float???? _float = null, string??? _string = null, System.IO.Stream??? binary = null, DateTime???? date = null, DateTime???? dateTime = null, string??? password = null, string??? callback = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 /// @@ -249,8 +352,10 @@ public interface IFakeApiSync : IApiAccessor /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") /// None (optional) /// None (optional) - /// ApiResponse of Object(void) - ApiResponse TestEndpointParametersResponse(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int? integer = default(int?), int? int32 = default(int?), long? int64 = default(long?), float? _float = default(float?), string _string = default(string), System.IO.Stream binary = default(System.IO.Stream), DateTime? date = default(DateTime?), DateTime? dateTime = default(DateTime?), string password = default(string), string callback = default(string)); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task TestEndpointParametersAsync(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int???? integer = null, int???? int32 = null, long???? int64 = null, float???? _float = null, string??? _string = null, System.IO.Stream??? binary = null, DateTime???? date = null, DateTime???? dateTime = null, string??? password = null, string??? callback = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// To test enum parameters /// @@ -266,9 +371,10 @@ public interface IFakeApiSync : IApiAccessor /// Query parameter enum test (double) (optional) /// Form parameter enum test (string array) (optional, default to $) /// Form parameter enum test (string) (optional, default to -efg) - /// - void TestEnumParameters(List enumHeaderStringArray = default(List), string enumHeaderString = default(string), List enumQueryStringArray = default(List), string enumQueryString = default(string), int? enumQueryInteger = default(int?), double? enumQueryDouble = default(double?), List enumFormStringArray = default(List), string enumFormString = default(string)); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> TestEnumParametersWithHttpInfoAsync(List??? enumHeaderStringArray = null, string??? enumHeaderString = null, List??? enumQueryStringArray = null, string??? enumQueryString = null, int???? enumQueryInteger = null, double???? enumQueryDouble = null, List??? enumFormStringArray = null, string??? enumFormString = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// To test enum parameters /// @@ -284,8 +390,10 @@ public interface IFakeApiSync : IApiAccessor /// Query parameter enum test (double) (optional) /// Form parameter enum test (string array) (optional, default to $) /// Form parameter enum test (string) (optional, default to -efg) - /// ApiResponse of Object(void) - ApiResponse TestEnumParametersResponse(List enumHeaderStringArray = default(List), string enumHeaderString = default(string), List enumQueryStringArray = default(List), string enumQueryString = default(string), int? enumQueryInteger = default(int?), double? enumQueryDouble = default(double?), List enumFormStringArray = default(List), string enumFormString = default(string)); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task TestEnumParametersAsync(List??? enumHeaderStringArray = null, string??? enumHeaderString = null, List??? enumQueryStringArray = null, string??? enumQueryString = null, int???? enumQueryInteger = null, double???? enumQueryDouble = null, List??? enumFormStringArray = null, string??? enumFormString = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// Fake endpoint to test group parameters (optional) /// @@ -299,9 +407,10 @@ public interface IFakeApiSync : IApiAccessor /// String in group parameters (optional) /// Boolean in group parameters (optional) /// Integer in group parameters (optional) - /// - void TestGroupParameters(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int? stringGroup = default(int?), bool? booleanGroup = default(bool?), long? int64Group = default(long?)); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> TestGroupParametersWithHttpInfoAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup = null, bool???? booleanGroup = null, long???? int64Group = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// Fake endpoint to test group parameters (optional) /// @@ -315,16 +424,22 @@ public interface IFakeApiSync : IApiAccessor /// String in group parameters (optional) /// Boolean in group parameters (optional) /// Integer in group parameters (optional) - /// ApiResponse of Object(void) - ApiResponse TestGroupParametersResponse(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int? stringGroup = default(int?), bool? booleanGroup = default(bool?), long? int64Group = default(long?)); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task TestGroupParametersAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup = null, bool???? booleanGroup = null, long???? int64Group = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// test inline additionalProperties /// + /// + /// + /// /// Thrown when fails to make API call /// request body - /// - void TestInlineAdditionalProperties(Dictionary requestBody); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> TestInlineAdditionalPropertiesWithHttpInfoAsync(Dictionary requestBody, System.Threading.CancellationToken? cancellationToken = null); + /// /// test inline additionalProperties /// @@ -333,17 +448,23 @@ public interface IFakeApiSync : IApiAccessor /// /// Thrown when fails to make API call /// request body - /// ApiResponse of Object(void) - ApiResponse TestInlineAdditionalPropertiesResponse(Dictionary requestBody); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task TestInlineAdditionalPropertiesAsync(Dictionary requestBody, System.Threading.CancellationToken? cancellationToken = null); + /// /// test json serialization of form data /// + /// + /// + /// /// Thrown when fails to make API call /// field1 /// field2 - /// - void TestJsonFormData(string param, string param2); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> TestJsonFormDataWithHttpInfoAsync(string param, string param2, System.Threading.CancellationToken? cancellationToken = null); + /// /// test json serialization of form data /// @@ -353,8 +474,10 @@ public interface IFakeApiSync : IApiAccessor /// Thrown when fails to make API call /// field1 /// field2 - /// ApiResponse of Object(void) - ApiResponse TestJsonFormDataResponse(string param, string param2); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task TestJsonFormDataAsync(string param, string param2, System.Threading.CancellationToken? cancellationToken = null); + /// /// /// @@ -367,9 +490,10 @@ public interface IFakeApiSync : IApiAccessor /// /// /// - /// - void TestQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> TestQueryParameterCollectionFormatWithHttpInfoAsync(List pipe, List ioutil, List http, List url, List context, System.Threading.CancellationToken? cancellationToken = null); + /// /// /// @@ -382,773 +506,156 @@ public interface IFakeApiSync : IApiAccessor /// /// /// - /// ApiResponse of Object(void) - ApiResponse TestQueryParameterCollectionFormatResponse(List pipe, List ioutil, List http, List url, List context); - #endregion Synchronous Operations + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task TestQueryParameterCollectionFormatAsync(List pipe, List ioutil, List http, List url, List context, System.Threading.CancellationToken? cancellationToken = null); + } /// /// Represents a collection of functions to interact with the API endpoints /// - public interface IFakeApiAsync : IApiAccessor + public partial class FakeApi : IFakeApi { - #region Asynchronous Operations + private readonly System.Net.Http.HttpClient _httpClient; + /// - /// Health check endpoint + /// Initializes a new instance of the class. + /// + /// + public FakeApi(System.Net.Http.HttpClient httpClient) + { + _httpClient = httpClient; + } + + /// + /// Returns the token to be used in the api query + /// + public Func>? GetTokenAsync { get; set; } + + + /// + /// Validate the input before sending the request + /// + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFakeHealthGetRequestAsync(System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + + /// + /// Health check endpoint /// - /// - /// - /// /// Thrown when fails to make API call /// Cancellation Token to cancel the request. /// Task of HealthCheckResult - System.Threading.Tasks.Task FakeHealthGetAsync(System.Threading.CancellationToken? cancellationToken = null); + public async System.Threading.Tasks.Task FakeHealthGetAsync(System.Threading.CancellationToken? cancellationToken = null) + { + Org.OpenAPITools.Client.ApiResponse result = await FakeHealthGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); + } /// - /// Health check endpoint + /// Health check endpoint /// - /// - /// - /// /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (HealthCheckResult) - System.Threading.Tasks.Task> FakeHealthGetResponseAsync(System.Threading.CancellationToken? cancellationToken = null); + /// Task of HealthCheckResult + public async System.Threading.Tasks.Task FakeHealthGetOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null) + { + Org.OpenAPITools.Client.ApiResponse result = await FakeHealthGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } + /// - /// + /// Health check endpoint /// - /// - /// Test serialization of outer boolean types - /// /// Thrown when fails to make API call - /// Input boolean as post body (optional) /// Cancellation Token to cancel the request. - /// Task of bool - System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null); + /// Task of ApiResponse (HealthCheckResult) + public async System.Threading.Tasks.Task> FakeHealthGetWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) + { + + await ValidateFakeHealthGetRequestAsync(cancellationToken).ConfigureAwait(false); + + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + + string path = "/fake/health"; + + + path = $"{path}?"; + + + if (path.EndsWith("&")) + path = path[..^1]; + + if (path.EndsWith("?")) + path = path[..^1]; + + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + + + + + + + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); + + ApiResponse apiResponse = new(responseMessage, responseContent); + + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + + return apiResponse; + } /// - /// + /// Validate the input before sending the request /// - /// - /// Test serialization of outer boolean types - /// - /// Thrown when fails to make API call /// Input boolean as post body (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (bool) - System.Threading.Tasks.Task> FakeOuterBooleanSerializeResponseAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null); + protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterBooleanSerializeRequestAsync(bool???? body, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// - /// + /// Test serialization of outer boolean types /// - /// - /// Test serialization of object with outer number type - /// /// Thrown when fails to make API call - /// Input composite as post body (optional) + /// Input boolean as post body (optional) /// Cancellation Token to cancel the request. - /// Task of OuterComposite - System.Threading.Tasks.Task FakeOuterCompositeSerializeAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null); + /// Task of bool + public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null) + { + Org.OpenAPITools.Client.ApiResponse result = await FakeOuterBooleanSerializeWithHttpInfoAsync(body, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); + } /// - /// - /// - /// - /// Test serialization of object with outer number type - /// - /// Thrown when fails to make API call - /// Input composite as post body (optional) - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (OuterComposite) - System.Threading.Tasks.Task> FakeOuterCompositeSerializeResponseAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null); - /// - /// - /// - /// - /// Test serialization of outer number types - /// - /// Thrown when fails to make API call - /// Input number as post body (optional) - /// Cancellation Token to cancel the request. - /// Task of decimal - System.Threading.Tasks.Task FakeOuterNumberSerializeAsync(decimal???? body = null, System.Threading.CancellationToken? cancellationToken = null); - - /// - /// - /// - /// - /// Test serialization of outer number types - /// - /// Thrown when fails to make API call - /// Input number as post body (optional) - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (decimal) - System.Threading.Tasks.Task> FakeOuterNumberSerializeResponseAsync(decimal???? body = null, System.Threading.CancellationToken? cancellationToken = null); - /// - /// - /// - /// - /// Test serialization of outer string types - /// - /// Thrown when fails to make API call - /// Input string as post body (optional) - /// Cancellation Token to cancel the request. - /// Task of string - System.Threading.Tasks.Task FakeOuterStringSerializeAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null); - - /// - /// - /// - /// - /// Test serialization of outer string types - /// - /// Thrown when fails to make API call - /// Input string as post body (optional) - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - System.Threading.Tasks.Task> FakeOuterStringSerializeResponseAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null); - /// - /// Array of Enums - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<OuterEnum> - System.Threading.Tasks.Task> GetArrayOfEnumsAsync(System.Threading.CancellationToken? cancellationToken = null); - - /// - /// Array of Enums - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<OuterEnum>) - System.Threading.Tasks.Task>> GetArrayOfEnumsResponseAsync(System.Threading.CancellationToken? cancellationToken = null); - /// - /// - /// - /// - /// For this test, the body for this request much reference a schema named `File`. - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task TestBodyWithFileSchemaAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken? cancellationToken = null); - - /// - /// - /// - /// - /// For this test, the body for this request much reference a schema named `File`. - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> TestBodyWithFileSchemaResponseAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken? cancellationToken = null); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task TestBodyWithQueryParamsAsync(string query, User user, System.Threading.CancellationToken? cancellationToken = null); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> TestBodyWithQueryParamsResponseAsync(string query, User user, System.Threading.CancellationToken? cancellationToken = null); - /// - /// To test \"client\" model - /// - /// - /// To test \"client\" model - /// - /// Thrown when fails to make API call - /// client model - /// Cancellation Token to cancel the request. - /// Task of ModelClient - System.Threading.Tasks.Task TestClientModelAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); - - /// - /// To test \"client\" model - /// - /// - /// To test \"client\" model - /// - /// Thrown when fails to make API call - /// client model - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ModelClient) - System.Threading.Tasks.Task> TestClientModelResponseAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); - /// - /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - /// - /// - /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - /// - /// Thrown when fails to make API call - /// None - /// None - /// None - /// None - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") - /// None (optional) - /// None (optional) - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task TestEndpointParametersAsync(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int???? integer = null, int???? int32 = null, long???? int64 = null, float???? _float = null, string??? _string = null, System.IO.Stream??? binary = null, DateTime???? date = null, DateTime???? dateTime = null, string??? password = null, string??? callback = null, System.Threading.CancellationToken? cancellationToken = null); - - /// - /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - /// - /// - /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - /// - /// Thrown when fails to make API call - /// None - /// None - /// None - /// None - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") - /// None (optional) - /// None (optional) - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> TestEndpointParametersResponseAsync(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int???? integer = null, int???? int32 = null, long???? int64 = null, float???? _float = null, string??? _string = null, System.IO.Stream??? binary = null, DateTime???? date = null, DateTime???? dateTime = null, string??? password = null, string??? callback = null, System.Threading.CancellationToken? cancellationToken = null); - /// - /// To test enum parameters - /// - /// - /// To test enum parameters - /// - /// Thrown when fails to make API call - /// Header parameter enum test (string array) (optional) - /// Header parameter enum test (string) (optional, default to -efg) - /// Query parameter enum test (string array) (optional) - /// Query parameter enum test (string) (optional, default to -efg) - /// Query parameter enum test (double) (optional) - /// Query parameter enum test (double) (optional) - /// Form parameter enum test (string array) (optional, default to $) - /// Form parameter enum test (string) (optional, default to -efg) - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task TestEnumParametersAsync(List??? enumHeaderStringArray = null, string??? enumHeaderString = null, List??? enumQueryStringArray = null, string??? enumQueryString = null, int???? enumQueryInteger = null, double???? enumQueryDouble = null, List??? enumFormStringArray = null, string??? enumFormString = null, System.Threading.CancellationToken? cancellationToken = null); - - /// - /// To test enum parameters - /// - /// - /// To test enum parameters - /// - /// Thrown when fails to make API call - /// Header parameter enum test (string array) (optional) - /// Header parameter enum test (string) (optional, default to -efg) - /// Query parameter enum test (string array) (optional) - /// Query parameter enum test (string) (optional, default to -efg) - /// Query parameter enum test (double) (optional) - /// Query parameter enum test (double) (optional) - /// Form parameter enum test (string array) (optional, default to $) - /// Form parameter enum test (string) (optional, default to -efg) - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> TestEnumParametersResponseAsync(List??? enumHeaderStringArray = null, string??? enumHeaderString = null, List??? enumQueryStringArray = null, string??? enumQueryString = null, int???? enumQueryInteger = null, double???? enumQueryDouble = null, List??? enumFormStringArray = null, string??? enumFormString = null, System.Threading.CancellationToken? cancellationToken = null); - /// - /// Fake endpoint to test group parameters (optional) - /// - /// - /// Fake endpoint to test group parameters (optional) - /// - /// Thrown when fails to make API call - /// Required String in group parameters - /// Required Boolean in group parameters - /// Required Integer in group parameters - /// String in group parameters (optional) - /// Boolean in group parameters (optional) - /// Integer in group parameters (optional) - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task TestGroupParametersAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup = null, bool???? booleanGroup = null, long???? int64Group = null, System.Threading.CancellationToken? cancellationToken = null); - - /// - /// Fake endpoint to test group parameters (optional) - /// - /// - /// Fake endpoint to test group parameters (optional) - /// - /// Thrown when fails to make API call - /// Required String in group parameters - /// Required Boolean in group parameters - /// Required Integer in group parameters - /// String in group parameters (optional) - /// Boolean in group parameters (optional) - /// Integer in group parameters (optional) - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> TestGroupParametersResponseAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup = null, bool???? booleanGroup = null, long???? int64Group = null, System.Threading.CancellationToken? cancellationToken = null); - /// - /// test inline additionalProperties - /// - /// - /// - /// - /// Thrown when fails to make API call - /// request body - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task TestInlineAdditionalPropertiesAsync(Dictionary requestBody, System.Threading.CancellationToken? cancellationToken = null); - - /// - /// test inline additionalProperties - /// - /// - /// - /// - /// Thrown when fails to make API call - /// request body - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> TestInlineAdditionalPropertiesResponseAsync(Dictionary requestBody, System.Threading.CancellationToken? cancellationToken = null); - /// - /// test json serialization of form data - /// - /// - /// - /// - /// Thrown when fails to make API call - /// field1 - /// field2 - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task TestJsonFormDataAsync(string param, string param2, System.Threading.CancellationToken? cancellationToken = null); - - /// - /// test json serialization of form data - /// - /// - /// - /// - /// Thrown when fails to make API call - /// field1 - /// field2 - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> TestJsonFormDataResponseAsync(string param, string param2, System.Threading.CancellationToken? cancellationToken = null); - /// - /// - /// - /// - /// To test the collection format in query parameters - /// - /// Thrown when fails to make API call - /// - /// - /// - /// - /// - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task TestQueryParameterCollectionFormatAsync(List pipe, List ioutil, List http, List url, List context, System.Threading.CancellationToken? cancellationToken = null); - - /// - /// - /// - /// - /// To test the collection format in query parameters - /// - /// Thrown when fails to make API call - /// - /// - /// - /// - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> TestQueryParameterCollectionFormatResponseAsync(List pipe, List ioutil, List http, List url, List context, System.Threading.CancellationToken? cancellationToken = null); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IFakeApi : IFakeApiSync, IFakeApiAsync - { - - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public partial class FakeApi : IFakeApi - { - private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null; - private readonly System.Net.Http.HttpClient _httpClient; - private readonly Newtonsoft.Json.JsonConverter[] _jsonConverters; - - /// - /// Initializes a new instance of the class. - /// - /// - public FakeApi() : this((string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - public FakeApi(System.Net.Http.HttpClient httpClient, Newtonsoft.Json.JsonConverter[] jsonConverters) : this((string)null) - { - _httpClient = httpClient; - - _jsonConverters = jsonConverters; - } - - /// - /// Initializes a new instance of the class. - /// - /// - public FakeApi(String basePath) - { - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public FakeApi(Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public FakeApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// The client for accessing this underlying API asynchronously. - /// - public Org.OpenAPITools.Client.IAsynchronousClient AsynchronousClient { get; set; } - - /// - /// The client for accessing this underlying API synchronously. - /// - public Org.OpenAPITools.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public Org.OpenAPITools.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public Org.OpenAPITools.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } - - /// - /// Health check endpoint - /// - /// Thrown when fails to make API call - /// HealthCheckResult - public HealthCheckResult FakeHealthGet() - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = FakeHealthGetResponse(); - return localVarResponse.Data; - } - - /// - /// Health check endpoint - /// - /// Thrown when fails to make API call - /// ApiResponse of HealthCheckResult - public Org.OpenAPITools.Client.ApiResponse FakeHealthGetResponse() - { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - var localVarResponse = this.Client.Get("/fake/health", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FakeHealthGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Health check endpoint - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of HealthCheckResult - public async System.Threading.Tasks.Task FakeHealthGetAsync(System.Threading.CancellationToken? cancellationToken = null) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await FakeHealthGetResponseAsync(cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateFakeHealthGetRequestAsync(System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } - - /// - /// Health check endpoint - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (HealthCheckResult) - public async System.Threading.Tasks.Task> FakeHealthGetResponseAsync(System.Threading.CancellationToken? cancellationToken = null) - { - - await ValidateFakeHealthGetRequestAsync(cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake/health"; - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - - - - string[] contentTypes = new string[] { - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - }; - - // to determine the Accept header - string[] _accepts = new string[] { - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/health", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FakeHealthGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Test serialization of outer boolean types - /// - /// Thrown when fails to make API call - /// Input boolean as post body (optional) - /// bool - public bool FakeOuterBooleanSerialize(bool? body = default(bool?)) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = FakeOuterBooleanSerializeResponse(body); - return localVarResponse.Data; - } - - /// - /// Test serialization of outer boolean types - /// - /// Thrown when fails to make API call - /// Input boolean as post body (optional) - /// ApiResponse of bool - public Org.OpenAPITools.Client.ApiResponse FakeOuterBooleanSerializeResponse(bool? body = default(bool?)) - { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "*/*" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = body; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/fake/outer/boolean", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FakeOuterBooleanSerialize", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Test serialization of outer boolean types + /// Test serialization of outer boolean types /// /// Thrown when fails to make API call /// Input boolean as post body (optional) /// Cancellation Token to cancel the request. /// Task of bool - public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task FakeOuterBooleanSerializeOrDefaultAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await FakeOuterBooleanSerializeResponseAsync(body, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateFakeOuterBooleanSerializeRequestAsync(bool???? body, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await FakeOuterBooleanSerializeWithHttpInfoAsync(body, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// Test serialization of outer boolean types @@ -1157,138 +664,74 @@ private System.Threading.Tasks.ValueTask ValidateFakeOuterBooleanSerializeReques /// Input boolean as post body (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse (bool) - public async System.Threading.Tasks.Task> FakeOuterBooleanSerializeResponseAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> FakeOuterBooleanSerializeWithHttpInfoAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateFakeOuterBooleanSerializeRequestAsync(body, cancellationToken); + await ValidateFakeOuterBooleanSerializeRequestAsync(body, cancellationToken).ConfigureAwait(false); - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake/outer/boolean"; - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + string path = "/fake/outer/boolean"; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; + path = $"{path}?"; + - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + if (path.EndsWith("&")) + path = path[..^1]; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); + if (path.EndsWith("?")) + path = path[..^1]; - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - ApiResponse apiResponse = new(responseMessage, responseContent); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); + // todo localVarRequestOptions.Data = body; - return apiResponse; - } - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] _contentTypes = new string[] { + string[] contentTypes = new string[] { "application/json" }; - // to determine the Accept header - string[] _accepts = new string[] { - "*/*" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - localVarRequestOptions.Data = body; + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - // make the HTTP request + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - var localVarResponse = await this.AsynchronousClient.PostAsync("/fake/outer/boolean", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FakeOuterBooleanSerialize", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// Test serialization of object with outer number type + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// Input composite as post body (optional) - /// OuterComposite - public OuterComposite FakeOuterCompositeSerialize(OuterComposite outerComposite = default(OuterComposite)) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = FakeOuterCompositeSerializeResponse(outerComposite); - return localVarResponse.Data; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterCompositeSerializeRequestAsync(OuterComposite??? outerComposite, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// Test serialization of object with outer number type /// /// Thrown when fails to make API call /// Input composite as post body (optional) - /// ApiResponse of OuterComposite - public Org.OpenAPITools.Client.ApiResponse FakeOuterCompositeSerializeResponse(OuterComposite outerComposite = default(OuterComposite)) + /// Cancellation Token to cancel the request. + /// Task of OuterComposite + public async System.Threading.Tasks.Task FakeOuterCompositeSerializeAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "*/*" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = outerComposite; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/fake/outer/composite", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FakeOuterCompositeSerialize", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse result = await FakeOuterCompositeSerializeWithHttpInfoAsync(outerComposite, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -1298,17 +741,14 @@ private System.Threading.Tasks.ValueTask ValidateFakeOuterBooleanSerializeReques /// Input composite as post body (optional) /// Cancellation Token to cancel the request. /// Task of OuterComposite - public async System.Threading.Tasks.Task FakeOuterCompositeSerializeAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await FakeOuterCompositeSerializeResponseAsync(outerComposite, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateFakeOuterCompositeSerializeRequestAsync(OuterComposite??? outerComposite, System.Threading.CancellationToken? cancellationToken) + public async System.Threading.Tasks.Task FakeOuterCompositeSerializeOrDefaultAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null) { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await FakeOuterCompositeSerializeWithHttpInfoAsync(outerComposite, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// Test serialization of object with outer number type @@ -1317,139 +757,62 @@ private System.Threading.Tasks.ValueTask ValidateFakeOuterCompositeSerializeRequ /// Input composite as post body (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse (OuterComposite) - public async System.Threading.Tasks.Task> FakeOuterCompositeSerializeResponseAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> FakeOuterCompositeSerializeWithHttpInfoAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateFakeOuterCompositeSerializeRequestAsync(outerComposite, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake/outer/composite"; - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; + await ValidateFakeOuterCompositeSerializeRequestAsync(outerComposite, cancellationToken).ConfigureAwait(false); - if (path.EndsWith("?")) - path = path[..^1]; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + string path = "/fake/outer/composite"; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + path = $"{path}?"; + - string[] contentTypes = new string[] { - "application/json" - }; + if (path.EndsWith("&")) + path = path[..^1]; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + if (path.EndsWith("?")) + path = path[..^1]; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - ApiResponse apiResponse = new(responseMessage, responseContent); + // todo localVarRequestOptions.Data = outerComposite; - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] _contentTypes = new string[] { + string[] contentTypes = new string[] { "application/json" }; - // to determine the Accept header - string[] _accepts = new string[] { - "*/*" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); - localVarRequestOptions.Data = outerComposite; + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/fake/outer/composite", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FakeOuterCompositeSerialize", localVarResponse); - if (_exception != null) throw _exception; - } + ApiResponse apiResponse = new(responseMessage, responseContent); - return localVarResponse; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - /// - /// Test serialization of outer number types - /// - /// Thrown when fails to make API call - /// Input number as post body (optional) - /// decimal - public decimal FakeOuterNumberSerialize(decimal? body = default(decimal?)) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = FakeOuterNumberSerializeResponse(body); - return localVarResponse.Data; + return apiResponse; } /// - /// Test serialization of outer number types + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// Input number as post body (optional) - /// ApiResponse of decimal - public Org.OpenAPITools.Client.ApiResponse FakeOuterNumberSerializeResponse(decimal? body = default(decimal?)) - { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "*/*" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = body; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/fake/outer/number", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FakeOuterNumberSerialize", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterNumberSerializeRequestAsync(decimal???? body, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// Test serialization of outer number types @@ -1460,14 +823,8 @@ private System.Threading.Tasks.ValueTask ValidateFakeOuterCompositeSerializeRequ /// Task of decimal public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync(decimal???? body = null, System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await FakeOuterNumberSerializeResponseAsync(body, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateFakeOuterNumberSerializeRequestAsync(decimal???? body, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); + Org.OpenAPITools.Client.ApiResponse result = await FakeOuterNumberSerializeWithHttpInfoAsync(body, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -1476,1042 +833,489 @@ private System.Threading.Tasks.ValueTask ValidateFakeOuterNumberSerializeRequest /// Thrown when fails to make API call /// Input number as post body (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (decimal) - public async System.Threading.Tasks.Task> FakeOuterNumberSerializeResponseAsync(decimal???? body = null, System.Threading.CancellationToken? cancellationToken = null) - { - - await ValidateFakeOuterNumberSerializeRequestAsync(body, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake/outer/number"; - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - - string[] contentTypes = new string[] { - "application/json" - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - "application/json" - }; - - // to determine the Accept header - string[] _accepts = new string[] { - "*/*" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = body; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/fake/outer/number", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FakeOuterNumberSerialize", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Test serialization of outer string types - /// - /// Thrown when fails to make API call - /// Input string as post body (optional) - /// string - public string FakeOuterStringSerialize(string body = default(string)) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = FakeOuterStringSerializeResponse(body); - return localVarResponse.Data; - } - - /// - /// Test serialization of outer string types - /// - /// Thrown when fails to make API call - /// Input string as post body (optional) - /// ApiResponse of string - public Org.OpenAPITools.Client.ApiResponse FakeOuterStringSerializeResponse(string body = default(string)) - { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "*/*" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = body; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/fake/outer/string", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FakeOuterStringSerialize", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Test serialization of outer string types - /// - /// Thrown when fails to make API call - /// Input string as post body (optional) - /// Cancellation Token to cancel the request. - /// Task of string - public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await FakeOuterStringSerializeResponseAsync(body, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateFakeOuterStringSerializeRequestAsync(string??? body, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } - - /// - /// Test serialization of outer string types - /// - /// Thrown when fails to make API call - /// Input string as post body (optional) - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async System.Threading.Tasks.Task> FakeOuterStringSerializeResponseAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null) - { - - await ValidateFakeOuterStringSerializeRequestAsync(body, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake/outer/string"; - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - - string[] contentTypes = new string[] { - "application/json" - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - "application/json" - }; - - // to determine the Accept header - string[] _accepts = new string[] { - "*/*" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = body; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/fake/outer/string", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FakeOuterStringSerialize", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Array of Enums - /// - /// Thrown when fails to make API call - /// List<OuterEnum> - public List GetArrayOfEnums() - { - Org.OpenAPITools.Client.ApiResponse> localVarResponse = GetArrayOfEnumsResponse(); - return localVarResponse.Data; - } - - /// - /// Array of Enums - /// - /// Thrown when fails to make API call - /// ApiResponse of List<OuterEnum> - public Org.OpenAPITools.Client.ApiResponse> GetArrayOfEnumsResponse() - { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - var localVarResponse = this.Client.Get>("/fake/array-of-enums", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("GetArrayOfEnums", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Array of Enums - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<OuterEnum> - public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(System.Threading.CancellationToken? cancellationToken = null) - { - Org.OpenAPITools.Client.ApiResponse> localVarResponse = await GetArrayOfEnumsResponseAsync(cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateGetArrayOfEnumsRequestAsync(System.Threading.CancellationToken? cancellationToken) + /// Task of decimal + public async System.Threading.Tasks.Task FakeOuterNumberSerializeOrDefaultAsync(decimal???? body = null, System.Threading.CancellationToken? cancellationToken = null) { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await FakeOuterNumberSerializeWithHttpInfoAsync(body, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// - /// Array of Enums + /// Test serialization of outer number types /// /// Thrown when fails to make API call + /// Input number as post body (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<OuterEnum>) - public async System.Threading.Tasks.Task>> GetArrayOfEnumsResponseAsync(System.Threading.CancellationToken? cancellationToken = null) + /// Task of ApiResponse (decimal) + public async System.Threading.Tasks.Task> FakeOuterNumberSerializeWithHttpInfoAsync(decimal???? body = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateGetArrayOfEnumsRequestAsync(cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake/array-of-enums"; - - path = $"{path}?"; - + await ValidateFakeOuterNumberSerializeRequestAsync(body, cancellationToken).ConfigureAwait(false); - if (path.EndsWith("&")) - path = path[..^1]; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - if (path.EndsWith("?")) - path = path[..^1]; + string path = "/fake/outer/number"; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + path = $"{path}?"; + + if (path.EndsWith("&")) + path = path[..^1]; - string[] contentTypes = new string[] { - }; + if (path.EndsWith("?")) + path = path[..^1]; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse> apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException>(apiResponse); - - return apiResponse; - } + // todo localVarRequestOptions.Data = body; - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - string[] _contentTypes = new string[] { - }; + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - // to determine the Accept header - string[] _accepts = new string[] { + string[] contentTypes = new string[] { "application/json" }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - // make the HTTP request + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - var localVarResponse = await this.AsynchronousClient.GetAsync>("/fake/array-of-enums", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("GetArrayOfEnums", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// For this test, the body for this request much reference a schema named `File`. + /// Validate the input before sending the request /// - /// Thrown when fails to make API call - /// - /// - public void TestBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass) - { - TestBodyWithFileSchemaResponse(fileSchemaTestClass); - } + /// Input string as post body (optional) + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterStringSerializeRequestAsync(string??? body, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// - /// For this test, the body for this request much reference a schema named `File`. + /// Test serialization of outer string types /// /// Thrown when fails to make API call - /// - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse TestBodyWithFileSchemaResponse(FileSchemaTestClass fileSchemaTestClass) + /// Input string as post body (optional) + /// Cancellation Token to cancel the request. + /// Task of string + public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'fileSchemaTestClass' is set - if (fileSchemaTestClass == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'fileSchemaTestClass' when calling FakeApi->TestBodyWithFileSchema"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = fileSchemaTestClass; - - - // make the HTTP request - var localVarResponse = this.Client.Put("/fake/body-with-file-schema", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestBodyWithFileSchema", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse result = await FakeOuterStringSerializeWithHttpInfoAsync(body, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// - /// For this test, the body for this request much reference a schema named `File`. + /// Test serialization of outer string types /// /// Thrown when fails to make API call - /// + /// Input string as post body (optional) /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task TestBodyWithFileSchemaAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken? cancellationToken = null) - { - await TestBodyWithFileSchemaResponseAsync(fileSchemaTestClass, cancellationToken).ConfigureAwait(false); - } - - private System.Threading.Tasks.ValueTask ValidateTestBodyWithFileSchemaRequestAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken? cancellationToken) + /// Task of string + public async System.Threading.Tasks.Task FakeOuterStringSerializeOrDefaultAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null) { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await FakeOuterStringSerializeWithHttpInfoAsync(body, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// - /// For this test, the body for this request much reference a schema named `File`. + /// Test serialization of outer string types /// /// Thrown when fails to make API call - /// + /// Input string as post body (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse - public async System.Threading.Tasks.Task> TestBodyWithFileSchemaResponseAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken? cancellationToken = null) + /// Task of ApiResponse (string) + public async System.Threading.Tasks.Task> FakeOuterStringSerializeWithHttpInfoAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'fileSchemaTestClass' is set - if (fileSchemaTestClass == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'fileSchemaTestClass' when calling FakeApi->TestBodyWithFileSchema"); - - await ValidateTestBodyWithFileSchemaRequestAsync(fileSchemaTestClass, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - string path = "/fake/body-with-file-schema"; + await ValidateFakeOuterStringSerializeRequestAsync(body, cancellationToken).ConfigureAwait(false); - path = $"{path}?"; - + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - if (path.EndsWith("&")) - path = path[..^1]; + string path = "/fake/outer/string"; - if (path.EndsWith("?")) - path = path[..^1]; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + path = $"{path}?"; + + if (path.EndsWith("&")) + path = path[..^1]; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + if (path.EndsWith("?")) + path = path[..^1]; - string[] contentTypes = new string[] { - "application/json" - }; + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); + // todo localVarRequestOptions.Data = body; - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - ApiResponse apiResponse = new(responseMessage, responseContent); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { + string[] contentTypes = new string[] { "application/json" }; - // to determine the Accept header - string[] _accepts = new string[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); - localVarRequestOptions.Data = fileSchemaTestClass; + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request + ApiResponse apiResponse = new(responseMessage, responseContent); - var localVarResponse = await this.AsynchronousClient.PutAsync("/fake/body-with-file-schema", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestBodyWithFileSchema", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// + /// Validate the input before sending the request /// - /// Thrown when fails to make API call - /// - /// - /// - public void TestBodyWithQueryParams(string query, User user) - { - TestBodyWithQueryParamsResponse(query, user); - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateGetArrayOfEnumsRequestAsync(System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// - /// + /// Array of Enums /// /// Thrown when fails to make API call - /// - /// - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse TestBodyWithQueryParamsResponse(string query, User user) + /// Cancellation Token to cancel the request. + /// Task of List<OuterEnum> + public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'query' is set - if (query == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'query' when calling FakeApi->TestBodyWithQueryParams"); - - // verify the required parameter 'user' is set - if (user == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'user' when calling FakeApi->TestBodyWithQueryParams"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "query", query)); - localVarRequestOptions.Data = user; - - - // make the HTTP request - var localVarResponse = this.Client.Put("/fake/body-with-query-params", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestBodyWithQueryParams", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse> result = await GetArrayOfEnumsWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// - /// + /// Array of Enums /// /// Thrown when fails to make API call - /// - /// /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task TestBodyWithQueryParamsAsync(string query, User user, System.Threading.CancellationToken? cancellationToken = null) - { - await TestBodyWithQueryParamsResponseAsync(query, user, cancellationToken).ConfigureAwait(false); - } - - private System.Threading.Tasks.ValueTask ValidateTestBodyWithQueryParamsRequestAsync(string query, User user, System.Threading.CancellationToken? cancellationToken) + /// Task of List<OuterEnum> + public async System.Threading.Tasks.Task?> GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null) { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse> result = await GetArrayOfEnumsWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// - /// + /// Array of Enums /// /// Thrown when fails to make API call - /// - /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse - public async System.Threading.Tasks.Task> TestBodyWithQueryParamsResponseAsync(string query, User user, System.Threading.CancellationToken? cancellationToken = null) + /// Task of ApiResponse (List<OuterEnum>) + public async System.Threading.Tasks.Task>> GetArrayOfEnumsWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'query' is set - if (query == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'query' when calling FakeApi->TestBodyWithQueryParams"); - // verify the required parameter 'user' is set - if (user == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'user' when calling FakeApi->TestBodyWithQueryParams"); - await ValidateTestBodyWithQueryParamsRequestAsync(query, user, cancellationToken); + await ValidateGetArrayOfEnumsRequestAsync(cancellationToken).ConfigureAwait(false); - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); + string path = "/fake/array-of-enums"; - string path = "/fake/body-with-query-params"; + path = $"{path}?"; + - path = $"{path}?"; - - path = $"{path}query={Uri.EscapeDataString(query.ToString())&"; + if (path.EndsWith("&")) + path = path[..^1]; + if (path.EndsWith("?")) + path = path[..^1]; - if (path.EndsWith("&")) - path = path[..^1]; + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - if (path.EndsWith("?")) - path = path[..^1]; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + string[] contentTypes = new string[] { + }; + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); + ApiResponse> apiResponse = new(responseMessage, responseContent); - return apiResponse; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + return apiResponse; + } - string[] _contentTypes = new string[] { - "application/json" - }; + /// + /// Validate the input before sending the request + /// + /// + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithFileSchemaRequestAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); - // to determine the Accept header - string[] _accepts = new string[] { - }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + /// + /// For this test, the body for this request much reference a schema named `File`. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task> TestBodyWithFileSchemaWithHttpInfoAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken? cancellationToken = null) + { + if (fileSchemaTestClass == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "query", query)); - localVarRequestOptions.Data = user; + await ValidateTestBodyWithFileSchemaRequestAsync(fileSchemaTestClass, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - // make the HTTP request + string path = "/fake/body-with-file-schema"; - var localVarResponse = await this.AsynchronousClient.PutAsync("/fake/body-with-query-params", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestBodyWithQueryParams", localVarResponse); - if (_exception != null) throw _exception; - } + path = $"{path}?"; + - return localVarResponse; - } + if (path.EndsWith("&")) + path = path[..^1]; - /// - /// To test \"client\" model To test \"client\" model - /// - /// Thrown when fails to make API call - /// client model - /// ModelClient - public ModelClient TestClientModel(ModelClient modelClient) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = TestClientModelResponse(modelClient); - return localVarResponse.Data; - } + if (path.EndsWith("?")) + path = path[..^1]; - /// - /// To test \"client\" model To test \"client\" model - /// - /// Thrown when fails to make API call - /// client model - /// ApiResponse of ModelClient - public Org.OpenAPITools.Client.ApiResponse TestClientModelResponse(ModelClient modelClient) - { - // verify the required parameter 'modelClient' is set - if (modelClient == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'modelClient' when calling FakeApi->TestClientModel"); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - String[] _contentTypes = new String[] { - "application/json" - }; - // to determine the Accept header - String[] _accepts = new String[] { + // todo localVarRequestOptions.Data = fileSchemaTestClass; + + + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + + string[] contentTypes = new string[] { "application/json" }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.Data = modelClient; + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - var localVarResponse = this.Client.Patch("/fake", localVarRequestOptions, this.Configuration); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestClientModel", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// To test \"client\" model To test \"client\" model + /// Validate the input before sending the request /// - /// Thrown when fails to make API call - /// client model + /// + /// /// Cancellation Token to cancel the request. - /// Task of ModelClient - public async System.Threading.Tasks.Task TestClientModelAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await TestClientModelResponseAsync(modelClient, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } + protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithQueryParamsRequestAsync(string query, User user, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateTestClientModelRequestAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// - /// To test \"client\" model To test \"client\" model + /// /// /// Thrown when fails to make API call - /// client model + /// + /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ModelClient) - public async System.Threading.Tasks.Task> TestClientModelResponseAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) + /// Task of ApiResponse + public async System.Threading.Tasks.Task> TestBodyWithQueryParamsWithHttpInfoAsync(string query, User user, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'modelClient' is set - if (modelClient == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'modelClient' when calling FakeApi->TestClientModel"); - - await ValidateTestClientModelRequestAsync(modelClient, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake"; - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; + if (query == null) + throw new ArgumentNullException(nameof(query)); + if (user == null) + throw new ArgumentNullException(nameof(user)); - if (path.EndsWith("?")) - path = path[..^1]; + await ValidateTestBodyWithQueryParamsRequestAsync(query, user, cancellationToken).ConfigureAwait(false); - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + string path = "/fake/body-with-query-params"; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; + path = $"{path}?"; + + path = $"{path}query={Uri.EscapeDataString(query.ToString()!)&"; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + if (path.EndsWith("&")) + path = path[..^1]; - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); + if (path.EndsWith("?")) + path = path[..^1]; - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - ApiResponse apiResponse = new(responseMessage, responseContent); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - return apiResponse; - } + // todo localVarRequestOptions.Data = user; - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - string[] _contentTypes = new string[] { - "application/json" - }; + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - // to determine the Accept header - string[] _accepts = new string[] { + string[] contentTypes = new string[] { "application/json" }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.Data = modelClient; + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request + ApiResponse apiResponse = new(responseMessage, responseContent); - var localVarResponse = await this.AsynchronousClient.PatchAsync("/fake", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestClientModel", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + return apiResponse; } /// - /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// Validate the input before sending the request + /// + /// client model + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestClientModelRequestAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + + /// + /// To test \"client\" model To test \"client\" model /// /// Thrown when fails to make API call - /// None - /// None - /// None - /// None - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") - /// None (optional) - /// None (optional) - /// - public void TestEndpointParameters(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int? integer = default(int?), int? int32 = default(int?), long? int64 = default(long?), float? _float = default(float?), string _string = default(string), System.IO.Stream binary = default(System.IO.Stream), DateTime? date = default(DateTime?), DateTime? dateTime = default(DateTime?), string password = default(string), string callback = default(string)) + /// client model + /// Cancellation Token to cancel the request. + /// Task of ModelClient + public async System.Threading.Tasks.Task TestClientModelAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) { - TestEndpointParametersResponse(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, _string, binary, date, dateTime, password, callback); + Org.OpenAPITools.Client.ApiResponse result = await TestClientModelWithHttpInfoAsync(modelClient, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// - /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// To test \"client\" model To test \"client\" model /// /// Thrown when fails to make API call - /// None - /// None - /// None - /// None - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") - /// None (optional) - /// None (optional) - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse TestEndpointParametersResponse(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int? integer = default(int?), int? int32 = default(int?), long? int64 = default(long?), float? _float = default(float?), string _string = default(string), System.IO.Stream binary = default(System.IO.Stream), DateTime? date = default(DateTime?), DateTime? dateTime = default(DateTime?), string password = default(string), string callback = default(string)) + /// client model + /// Cancellation Token to cancel the request. + /// Task of ModelClient + public async System.Threading.Tasks.Task TestClientModelOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'patternWithoutDelimiter' is set - if (patternWithoutDelimiter == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'patternWithoutDelimiter' when calling FakeApi->TestEndpointParameters"); + Org.OpenAPITools.Client.ApiResponse result = await TestClientModelWithHttpInfoAsync(modelClient, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } - // verify the required parameter '_byte' is set - if (_byte == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter '_byte' when calling FakeApi->TestEndpointParameters"); + /// + /// To test \"client\" model To test \"client\" model + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ModelClient) + public async System.Threading.Tasks.Task> TestClientModelWithHttpInfoAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) + { + if (modelClient == null) + throw new ArgumentNullException(nameof(modelClient)); - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + await ValidateTestClientModelRequestAsync(modelClient, cancellationToken).ConfigureAwait(false); - String[] _contentTypes = new String[] { - "application/x-www-form-urlencoded" - }; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + + string path = "/fake"; + + + path = $"{path}?"; + - // to determine the Accept header - String[] _accepts = new String[] { + if (path.EndsWith("&")) + path = path[..^1]; + + if (path.EndsWith("?")) + path = path[..^1]; + + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + + + + // todo localVarRequestOptions.Data = modelClient; + + + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + + string[] contentTypes = new string[] { + "application/json" }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - if (integer != null) - { - localVarRequestOptions.FormParameters.Add("integer", Org.OpenAPITools.Client.ClientUtils.ParameterToString(integer)); // form parameter - } - if (int32 != null) - { - localVarRequestOptions.FormParameters.Add("int32", Org.OpenAPITools.Client.ClientUtils.ParameterToString(int32)); // form parameter - } - if (int64 != null) - { - localVarRequestOptions.FormParameters.Add("int64", Org.OpenAPITools.Client.ClientUtils.ParameterToString(int64)); // form parameter - } - localVarRequestOptions.FormParameters.Add("number", Org.OpenAPITools.Client.ClientUtils.ParameterToString(number)); // form parameter - if (_float != null) - { - localVarRequestOptions.FormParameters.Add("float", Org.OpenAPITools.Client.ClientUtils.ParameterToString(_float)); // form parameter - } - localVarRequestOptions.FormParameters.Add("double", Org.OpenAPITools.Client.ClientUtils.ParameterToString(_double)); // form parameter - if (_string != null) - { - localVarRequestOptions.FormParameters.Add("string", Org.OpenAPITools.Client.ClientUtils.ParameterToString(_string)); // form parameter - } - localVarRequestOptions.FormParameters.Add("pattern_without_delimiter", Org.OpenAPITools.Client.ClientUtils.ParameterToString(patternWithoutDelimiter)); // form parameter - localVarRequestOptions.FormParameters.Add("byte", Org.OpenAPITools.Client.ClientUtils.ParameterToString(_byte)); // form parameter - if (binary != null) - { - localVarRequestOptions.FileParameters.Add("binary", binary); - } - if (date != null) - { - localVarRequestOptions.FormParameters.Add("date", Org.OpenAPITools.Client.ClientUtils.ParameterToString(date)); // form parameter - } - if (dateTime != null) - { - localVarRequestOptions.FormParameters.Add("dateTime", Org.OpenAPITools.Client.ClientUtils.ParameterToString(dateTime)); // form parameter - } - if (password != null) - { - localVarRequestOptions.FormParameters.Add("password", Org.OpenAPITools.Client.ClientUtils.ParameterToString(password)); // form parameter - } - if (callback != null) - { - localVarRequestOptions.FormParameters.Add("callback", Org.OpenAPITools.Client.ClientUtils.ParameterToString(callback)); // form parameter - } + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - // authentication (http_basic_test) required - // http basic authentication required - if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + Org.OpenAPITools.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password)); - } + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - var localVarResponse = this.Client.Post("/fake", localVarRequestOptions, this.Configuration); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestEndpointParameters", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// None /// None /// None @@ -2527,17 +1331,10 @@ private System.Threading.Tasks.ValueTask ValidateTestClientModelRequestAsync(Mod /// None (optional) /// None (optional) /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task TestEndpointParametersAsync(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int???? integer = null, int???? int32 = null, long???? int64 = null, float???? _float = null, string??? _string = null, System.IO.Stream??? binary = null, DateTime???? date = null, DateTime???? dateTime = null, string??? password = null, string??? callback = null, System.Threading.CancellationToken? cancellationToken = null) - { - await TestEndpointParametersResponseAsync(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, _string, binary, date, dateTime, password, callback, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateTestEndpointParametersRequestAsync(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int???? integer, int???? int32, long???? int64, float???? _float, string??? _string, System.IO.Stream??? binary, DateTime???? date, DateTime???? dateTime, string??? password, string??? callback, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateTestEndpointParametersRequestAsync(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int???? integer, int???? int32, long???? int64, float???? _float, string??? _string, System.IO.Stream??? binary, DateTime???? date, DateTime???? dateTime, string??? password, string??? callback, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -2559,240 +1356,108 @@ private System.Threading.Tasks.ValueTask ValidateTestEndpointParametersRequestAs /// None (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> TestEndpointParametersResponseAsync(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int???? integer = null, int???? int32 = null, long???? int64 = null, float???? _float = null, string??? _string = null, System.IO.Stream??? binary = null, DateTime???? date = null, DateTime???? dateTime = null, string??? password = null, string??? callback = null, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> TestEndpointParametersWithHttpInfoAsync(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int???? integer = null, int???? int32 = null, long???? int64 = null, float???? _float = null, string??? _string = null, System.IO.Stream??? binary = null, DateTime???? date = null, DateTime???? dateTime = null, string??? password = null, string??? callback = null, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'patternWithoutDelimiter' is set if (patternWithoutDelimiter == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'patternWithoutDelimiter' when calling FakeApi->TestEndpointParameters"); - // verify the required parameter '_byte' is set + throw new ArgumentNullException(nameof(patternWithoutDelimiter)); if (_byte == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter '_byte' when calling FakeApi->TestEndpointParameters"); - - await ValidateTestEndpointParametersRequestAsync(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, _string, binary, date, dateTime, password, callback, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake"; - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); + throw new ArgumentNullException(nameof(_byte)); - string[] contentTypes = new string[] { - "application/x-www-form-urlencoded" - }; + await ValidateTestEndpointParametersRequestAsync(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, _string, binary, date, dateTime, password, callback, cancellationToken).ConfigureAwait(false); - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + string path = "/fake"; - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + path = $"{path}?"; + - ApiResponse apiResponse = new(responseMessage, responseContent); + if (path.EndsWith("&")) + path = path[..^1]; - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); + if (path.EndsWith("?")) + path = path[..^1]; - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - "application/x-www-form-urlencoded" - }; - - // to determine the Accept header - string[] _accepts = new string[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); if (integer != null) { - localVarRequestOptions.FormParameters.Add("integer", Org.OpenAPITools.Client.ClientUtils.ParameterToString(integer)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("integer", Org.OpenAPITools.Client.ClientUtils.ParameterToString(integer)); // form parameter } if (int32 != null) { - localVarRequestOptions.FormParameters.Add("int32", Org.OpenAPITools.Client.ClientUtils.ParameterToString(int32)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("int32", Org.OpenAPITools.Client.ClientUtils.ParameterToString(int32)); // form parameter } if (int64 != null) { - localVarRequestOptions.FormParameters.Add("int64", Org.OpenAPITools.Client.ClientUtils.ParameterToString(int64)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("int64", Org.OpenAPITools.Client.ClientUtils.ParameterToString(int64)); // form parameter } - localVarRequestOptions.FormParameters.Add("number", Org.OpenAPITools.Client.ClientUtils.ParameterToString(number)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("number", Org.OpenAPITools.Client.ClientUtils.ParameterToString(number)); // form parameter if (_float != null) { - localVarRequestOptions.FormParameters.Add("float", Org.OpenAPITools.Client.ClientUtils.ParameterToString(_float)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("float", Org.OpenAPITools.Client.ClientUtils.ParameterToString(_float)); // form parameter } - localVarRequestOptions.FormParameters.Add("double", Org.OpenAPITools.Client.ClientUtils.ParameterToString(_double)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("double", Org.OpenAPITools.Client.ClientUtils.ParameterToString(_double)); // form parameter if (_string != null) { - localVarRequestOptions.FormParameters.Add("string", Org.OpenAPITools.Client.ClientUtils.ParameterToString(_string)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("string", Org.OpenAPITools.Client.ClientUtils.ParameterToString(_string)); // form parameter } - localVarRequestOptions.FormParameters.Add("pattern_without_delimiter", Org.OpenAPITools.Client.ClientUtils.ParameterToString(patternWithoutDelimiter)); // form parameter - localVarRequestOptions.FormParameters.Add("byte", Org.OpenAPITools.Client.ClientUtils.ParameterToString(_byte)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("pattern_without_delimiter", Org.OpenAPITools.Client.ClientUtils.ParameterToString(patternWithoutDelimiter)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("byte", Org.OpenAPITools.Client.ClientUtils.ParameterToString(_byte)); // form parameter if (binary != null) { - localVarRequestOptions.FileParameters.Add("binary", binary); + // todo localVarRequestOptions.FileParameters.Add("binary", binary); } if (date != null) { - localVarRequestOptions.FormParameters.Add("date", Org.OpenAPITools.Client.ClientUtils.ParameterToString(date)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("date", Org.OpenAPITools.Client.ClientUtils.ParameterToString(date)); // form parameter } if (dateTime != null) { - localVarRequestOptions.FormParameters.Add("dateTime", Org.OpenAPITools.Client.ClientUtils.ParameterToString(dateTime)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("dateTime", Org.OpenAPITools.Client.ClientUtils.ParameterToString(dateTime)); // form parameter } if (password != null) { - localVarRequestOptions.FormParameters.Add("password", Org.OpenAPITools.Client.ClientUtils.ParameterToString(password)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("password", Org.OpenAPITools.Client.ClientUtils.ParameterToString(password)); // form parameter } if (callback != null) { - localVarRequestOptions.FormParameters.Add("callback", Org.OpenAPITools.Client.ClientUtils.ParameterToString(callback)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("callback", Org.OpenAPITools.Client.ClientUtils.ParameterToString(callback)); // form parameter } + // authentication (http_basic_test) required // http basic authentication required - if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + Org.OpenAPITools.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password)); - } - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/fake", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestEndpointParameters", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// To test enum parameters To test enum parameters - /// - /// Thrown when fails to make API call - /// Header parameter enum test (string array) (optional) - /// Header parameter enum test (string) (optional, default to -efg) - /// Query parameter enum test (string array) (optional) - /// Query parameter enum test (string) (optional, default to -efg) - /// Query parameter enum test (double) (optional) - /// Query parameter enum test (double) (optional) - /// Form parameter enum test (string array) (optional, default to $) - /// Form parameter enum test (string) (optional, default to -efg) - /// - public void TestEnumParameters(List enumHeaderStringArray = default(List), string enumHeaderString = default(string), List enumQueryStringArray = default(List), string enumQueryString = default(string), int? enumQueryInteger = default(int?), double? enumQueryDouble = default(double?), List enumFormStringArray = default(List), string enumFormString = default(string)) - { - TestEnumParametersResponse(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); - } - - /// - /// To test enum parameters To test enum parameters - /// - /// Thrown when fails to make API call - /// Header parameter enum test (string array) (optional) - /// Header parameter enum test (string) (optional, default to -efg) - /// Query parameter enum test (string array) (optional) - /// Query parameter enum test (string) (optional, default to -efg) - /// Query parameter enum test (double) (optional) - /// Query parameter enum test (double) (optional) - /// Form parameter enum test (string array) (optional, default to $) - /// Form parameter enum test (string) (optional, default to -efg) - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse TestEnumParametersResponse(List enumHeaderStringArray = default(List), string enumHeaderString = default(string), List enumQueryStringArray = default(List), string enumQueryString = default(string), int? enumQueryInteger = default(int?), double? enumQueryDouble = default(double?), List enumFormStringArray = default(List), string enumFormString = default(string)) - { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + //todo if (!string.IsNullOrEmpty(this.Configuration.Username) || !string.IsNullOrEmpty(this.Configuration.Password)) + //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + Org.OpenAPITools.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password)); + + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); - String[] _contentTypes = new String[] { + string[] contentTypes = new string[] { "application/x-www-form-urlencoded" }; - // to determine the Accept header - String[] _accepts = new String[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - if (enumQueryStringArray != null) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "enum_query_string_array", enumQueryStringArray)); - } - if (enumQueryString != null) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_string", enumQueryString)); - } - if (enumQueryInteger != null) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_integer", enumQueryInteger)); - } - if (enumQueryDouble != null) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_double", enumQueryDouble)); - } - if (enumHeaderStringArray != null) - { - localVarRequestOptions.HeaderParameters.Add("enum_header_string_array", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumHeaderStringArray)); // header parameter - } - if (enumHeaderString != null) - { - localVarRequestOptions.HeaderParameters.Add("enum_header_string", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumHeaderString)); // header parameter - } - if (enumFormStringArray != null) - { - localVarRequestOptions.FormParameters.Add("enum_form_string_array", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumFormStringArray)); // form parameter - } - if (enumFormString != null) - { - localVarRequestOptions.FormParameters.Add("enum_form_string", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumFormString)); // form parameter - } + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - var localVarResponse = this.Client.Get("/fake", localVarRequestOptions, this.Configuration); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestEnumParameters", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// To test enum parameters To test enum parameters + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// Header parameter enum test (string array) (optional) /// Header parameter enum test (string) (optional, default to -efg) /// Query parameter enum test (string array) (optional) @@ -2802,17 +1467,10 @@ private System.Threading.Tasks.ValueTask ValidateTestEndpointParametersRequestAs /// Form parameter enum test (string array) (optional, default to $) /// Form parameter enum test (string) (optional, default to -efg) /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task TestEnumParametersAsync(List??? enumHeaderStringArray = null, string??? enumHeaderString = null, List??? enumQueryStringArray = null, string??? enumQueryString = null, int???? enumQueryInteger = null, double???? enumQueryDouble = null, List??? enumFormStringArray = null, string??? enumFormString = null, System.Threading.CancellationToken? cancellationToken = null) - { - await TestEnumParametersResponseAsync(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateTestEnumParametersRequestAsync(List??? enumHeaderStringArray, string??? enumHeaderString, List??? enumQueryStringArray, string??? enumQueryString, int???? enumQueryInteger, double???? enumQueryDouble, List??? enumFormStringArray, string??? enumFormString, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateTestEnumParametersRequestAsync(List??? enumHeaderStringArray, string??? enumHeaderString, List??? enumQueryStringArray, string??? enumQueryString, int???? enumQueryInteger, double???? enumQueryDouble, List??? enumFormStringArray, string??? enumFormString, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// To test enum parameters To test enum parameters @@ -2823,221 +1481,85 @@ private System.Threading.Tasks.ValueTask ValidateTestEnumParametersRequestAsync( /// Query parameter enum test (string array) (optional) /// Query parameter enum test (string) (optional, default to -efg) /// Query parameter enum test (double) (optional) - /// Query parameter enum test (double) (optional) - /// Form parameter enum test (string array) (optional, default to $) - /// Form parameter enum test (string) (optional, default to -efg) - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - public async System.Threading.Tasks.Task> TestEnumParametersResponseAsync(List??? enumHeaderStringArray = null, string??? enumHeaderString = null, List??? enumQueryStringArray = null, string??? enumQueryString = null, int???? enumQueryInteger = null, double???? enumQueryDouble = null, List??? enumFormStringArray = null, string??? enumFormString = null, System.Threading.CancellationToken? cancellationToken = null) - { - - await ValidateTestEnumParametersRequestAsync(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake"; - - path = $"{path}?"; - - if (enumQueryStringArray != null) - path = $"{path}enum_query_string_array={Uri.EscapeDataString(enumQueryStringArray.ToString())}&"; - - if (enumQueryString != null) - path = $"{path}enum_query_string={Uri.EscapeDataString(enumQueryString.ToString())}&"; - - if (enumQueryInteger != null) - path = $"{path}enum_query_integer={Uri.EscapeDataString(enumQueryInteger.ToString())}&"; - - if (enumQueryDouble != null) - path = $"{path}enum_query_double={Uri.EscapeDataString(enumQueryDouble.ToString())}&"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - - if (enumHeaderStringArray != null) - request.Headers.Add(enum_header_string_array, enumHeaderStringArray); - if (enumHeaderString != null) - request.Headers.Add(enum_header_string, enumHeaderString); - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); - - string[] contentTypes = new string[] { - "application/x-www-form-urlencoded" - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - "application/x-www-form-urlencoded" - }; - - // to determine the Accept header - string[] _accepts = new string[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - if (enumQueryStringArray != null) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "enum_query_string_array", enumQueryStringArray)); - } - if (enumQueryString != null) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_string", enumQueryString)); - } - if (enumQueryInteger != null) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_integer", enumQueryInteger)); - } - if (enumQueryDouble != null) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_double", enumQueryDouble)); - } - if (enumHeaderStringArray != null) - { - localVarRequestOptions.HeaderParameters.Add("enum_header_string_array", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumHeaderStringArray)); // header parameter - } - if (enumHeaderString != null) - { - localVarRequestOptions.HeaderParameters.Add("enum_header_string", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumHeaderString)); // header parameter - } - if (enumFormStringArray != null) - { - localVarRequestOptions.FormParameters.Add("enum_form_string_array", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumFormStringArray)); // form parameter - } - if (enumFormString != null) - { - localVarRequestOptions.FormParameters.Add("enum_form_string", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumFormString)); // form parameter - } - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync("/fake", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestEnumParameters", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) - /// - /// Thrown when fails to make API call - /// Required String in group parameters - /// Required Boolean in group parameters - /// Required Integer in group parameters - /// String in group parameters (optional) - /// Boolean in group parameters (optional) - /// Integer in group parameters (optional) - /// - public void TestGroupParameters(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int? stringGroup = default(int?), bool? booleanGroup = default(bool?), long? int64Group = default(long?)) - { - TestGroupParametersResponse(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); - } - - /// - /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) - /// - /// Thrown when fails to make API call - /// Required String in group parameters - /// Required Boolean in group parameters - /// Required Integer in group parameters - /// String in group parameters (optional) - /// Boolean in group parameters (optional) - /// Integer in group parameters (optional) - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse TestGroupParametersResponse(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int? stringGroup = default(int?), bool? booleanGroup = default(bool?), long? int64Group = default(long?)) + /// Query parameter enum test (double) (optional) + /// Form parameter enum test (string array) (optional, default to $) + /// Form parameter enum test (string) (optional, default to -efg) + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task> TestEnumParametersWithHttpInfoAsync(List??? enumHeaderStringArray = null, string??? enumHeaderString = null, List??? enumQueryStringArray = null, string??? enumQueryString = null, int???? enumQueryInteger = null, double???? enumQueryDouble = null, List??? enumFormStringArray = null, string??? enumFormString = null, System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - String[] _contentTypes = new String[] { - }; + await ValidateTestEnumParametersRequestAsync(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, cancellationToken).ConfigureAwait(false); - // to determine the Accept header - String[] _accepts = new String[] { - }; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + string path = "/fake"; - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_string_group", requiredStringGroup)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_int64_group", requiredInt64Group)); - if (stringGroup != null) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "string_group", stringGroup)); - } - if (int64Group != null) + path = $"{path}?"; + + if (enumQueryStringArray != null) + path = $"{path}enum_query_string_array={Uri.EscapeDataString(enumQueryStringArray.ToString()!)}&"; + + if (enumQueryString != null) + path = $"{path}enum_query_string={Uri.EscapeDataString(enumQueryString.ToString()!)}&"; + + if (enumQueryInteger != null) + path = $"{path}enum_query_integer={Uri.EscapeDataString(enumQueryInteger.ToString()!)}&"; + + if (enumQueryDouble != null) + path = $"{path}enum_query_double={Uri.EscapeDataString(enumQueryDouble.ToString()!)}&"; + + + if (path.EndsWith("&")) + path = path[..^1]; + + if (path.EndsWith("?")) + path = path[..^1]; + + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + + if (enumHeaderStringArray != null) + request.Headers.Add(enum_header_string_array, enumHeaderStringArray); + if (enumHeaderString != null) + request.Headers.Add(enum_header_string, enumHeaderString); + + if (enumFormStringArray != null) { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "int64_group", int64Group)); + // todo localVarRequestOptions.FormParameters.Add("enum_form_string_array", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumFormStringArray)); // form parameter } - localVarRequestOptions.HeaderParameters.Add("required_boolean_group", Org.OpenAPITools.Client.ClientUtils.ParameterToString(requiredBooleanGroup)); // header parameter - if (booleanGroup != null) + if (enumFormString != null) { - localVarRequestOptions.HeaderParameters.Add("boolean_group", Org.OpenAPITools.Client.ClientUtils.ParameterToString(booleanGroup)); // header parameter + // todo localVarRequestOptions.FormParameters.Add("enum_form_string", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumFormString)); // form parameter } - // authentication (bearer_test) required - // bearer authentication required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - // make the HTTP request - var localVarResponse = this.Client.Delete("/fake", localVarRequestOptions, this.Configuration); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestGroupParameters", localVarResponse); - if (_exception != null) throw _exception; - } + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); - return localVarResponse; + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + + + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); + + ApiResponse apiResponse = new(responseMessage, responseContent); + + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + + return apiResponse; } /// - /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// Required String in group parameters /// Required Boolean in group parameters /// Required Integer in group parameters @@ -3045,17 +1567,10 @@ private System.Threading.Tasks.ValueTask ValidateTestEnumParametersRequestAsync( /// Boolean in group parameters (optional) /// Integer in group parameters (optional) /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task TestGroupParametersAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup = null, bool???? booleanGroup = null, long???? int64Group = null, System.Threading.CancellationToken? cancellationToken = null) - { - await TestGroupParametersResponseAsync(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateTestGroupParametersRequestAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup, bool???? booleanGroup, long???? int64Group, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateTestGroupParametersRequestAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup, bool???? booleanGroup, long???? int64Group, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) @@ -3069,187 +1584,78 @@ private System.Threading.Tasks.ValueTask ValidateTestGroupParametersRequestAsync /// Integer in group parameters (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> TestGroupParametersResponseAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup = null, bool???? booleanGroup = null, long???? int64Group = null, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> TestGroupParametersWithHttpInfoAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup = null, bool???? booleanGroup = null, long???? int64Group = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateTestGroupParametersRequestAsync(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, cancellationToken); + await ValidateTestGroupParametersRequestAsync(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, cancellationToken).ConfigureAwait(false); - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake"; - - path = $"{path}?"; - - path = $"{path}required_string_group={Uri.EscapeDataString(requiredStringGroup.ToString())&"; - - path = $"{path}required_int64_group={Uri.EscapeDataString(requiredInt64Group.ToString())&"; - - if (stringGroup != null) - path = $"{path}string_group={Uri.EscapeDataString(stringGroup.ToString())}&"; - - if (int64Group != null) - path = $"{path}int64_group={Uri.EscapeDataString(int64Group.ToString())}&"; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + string path = "/fake"; - if (path.EndsWith("&")) - path = path[..^1]; - if (path.EndsWith("?")) - path = path[..^1]; + path = $"{path}?"; + + path = $"{path}required_string_group={Uri.EscapeDataString(requiredStringGroup.ToString()!)&"; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + path = $"{path}required_int64_group={Uri.EscapeDataString(requiredInt64Group.ToString()!)&"; - request.Headers.Add(required_boolean_group, requiredBooleanGroup); - if (booleanGroup != null) - request.Headers.Add(boolean_group, booleanGroup); - - - string[] contentTypes = new string[] { - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); + if (stringGroup != null) + path = $"{path}string_group={Uri.EscapeDataString(stringGroup.ToString()!)}&"; - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); + if (int64Group != null) + path = $"{path}int64_group={Uri.EscapeDataString(int64Group.ToString()!)}&"; - return apiResponse; - } - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + if (path.EndsWith("&")) + path = path[..^1]; - string[] _contentTypes = new string[] { - }; + if (path.EndsWith("?")) + path = path[..^1]; - // to determine the Accept header - string[] _accepts = new string[] { - }; + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + request.Headers.Add(required_boolean_group, requiredBooleanGroup); + if (booleanGroup != null) + request.Headers.Add(boolean_group, booleanGroup); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_string_group", requiredStringGroup)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_int64_group", requiredInt64Group)); - if (stringGroup != null) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "string_group", stringGroup)); - } - if (int64Group != null) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "int64_group", int64Group)); - } - localVarRequestOptions.HeaderParameters.Add("required_boolean_group", Org.OpenAPITools.Client.ClientUtils.ParameterToString(requiredBooleanGroup)); // header parameter - if (booleanGroup != null) - { - localVarRequestOptions.HeaderParameters.Add("boolean_group", Org.OpenAPITools.Client.ClientUtils.ParameterToString(booleanGroup)); // header parameter - } // authentication (bearer_test) required + //isBasicBearer // bearer authentication required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.DeleteAsync("/fake", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestGroupParameters", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// test inline additionalProperties - /// - /// Thrown when fails to make API call - /// request body - /// - public void TestInlineAdditionalProperties(Dictionary requestBody) - { - TestInlineAdditionalPropertiesResponse(requestBody); - } - - /// - /// test inline additionalProperties - /// - /// Thrown when fails to make API call - /// request body - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse TestInlineAdditionalPropertiesResponse(Dictionary requestBody) - { - // verify the required parameter 'requestBody' is set - if (requestBody == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'requestBody' when calling FakeApi->TestInlineAdditionalProperties"); + //todo if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + //todo request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json" - }; - // to determine the Accept header - String[] _accepts = new String[] { + string[] contentTypes = new string[] { }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.Data = requestBody; + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - var localVarResponse = this.Client.Post("/fake/inline-additionalProperties", localVarRequestOptions, this.Configuration); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestInlineAdditionalProperties", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// test inline additionalProperties + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// request body /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task TestInlineAdditionalPropertiesAsync(Dictionary requestBody, System.Threading.CancellationToken? cancellationToken = null) - { - await TestInlineAdditionalPropertiesResponseAsync(requestBody, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateTestInlineAdditionalPropertiesRequestAsync(Dictionary requestBody, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateTestInlineAdditionalPropertiesRequestAsync(Dictionary requestBody, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// test inline additionalProperties @@ -3258,168 +1664,66 @@ private System.Threading.Tasks.ValueTask ValidateTestInlineAdditionalPropertiesR /// request body /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> TestInlineAdditionalPropertiesResponseAsync(Dictionary requestBody, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> TestInlineAdditionalPropertiesWithHttpInfoAsync(Dictionary requestBody, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'requestBody' is set if (requestBody == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'requestBody' when calling FakeApi->TestInlineAdditionalProperties"); - - await ValidateTestInlineAdditionalPropertiesRequestAsync(requestBody, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake/inline-additionalProperties"; + throw new ArgumentNullException(nameof(requestBody)); - path = $"{path}?"; - + await ValidateTestInlineAdditionalPropertiesRequestAsync(requestBody, cancellationToken).ConfigureAwait(false); - if (path.EndsWith("&")) - path = path[..^1]; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - if (path.EndsWith("?")) - path = path[..^1]; + string path = "/fake/inline-additionalProperties"; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + path = $"{path}?"; + - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + if (path.EndsWith("&")) + path = path[..^1]; - string[] contentTypes = new string[] { - "application/json" - }; + if (path.EndsWith("?")) + path = path[..^1]; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + // todo localVarRequestOptions.Data = requestBody; - ApiResponse apiResponse = new(responseMessage, responseContent); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { + string[] contentTypes = new string[] { "application/json" }; - // to determine the Accept header - string[] _accepts = new string[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = requestBody; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/fake/inline-additionalProperties", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestInlineAdditionalProperties", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// test json serialization of form data - /// - /// Thrown when fails to make API call - /// field1 - /// field2 - /// - public void TestJsonFormData(string param, string param2) - { - TestJsonFormDataResponse(param, param2); - } - - /// - /// test json serialization of form data - /// - /// Thrown when fails to make API call - /// field1 - /// field2 - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse TestJsonFormDataResponse(string param, string param2) - { - // verify the required parameter 'param' is set - if (param == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'param' when calling FakeApi->TestJsonFormData"); - - // verify the required parameter 'param2' is set - if (param2 == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'param2' when calling FakeApi->TestJsonFormData"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/x-www-form-urlencoded" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.FormParameters.Add("param", Org.OpenAPITools.Client.ClientUtils.ParameterToString(param)); // form parameter - localVarRequestOptions.FormParameters.Add("param2", Org.OpenAPITools.Client.ClientUtils.ParameterToString(param2)); // form parameter + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - var localVarResponse = this.Client.Get("/fake/jsonFormData", localVarRequestOptions, this.Configuration); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestJsonFormData", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// test json serialization of form data + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// field1 /// field2 /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task TestJsonFormDataAsync(string param, string param2, System.Threading.CancellationToken? cancellationToken = null) - { - await TestJsonFormDataResponseAsync(param, param2, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateTestJsonFormDataRequestAsync(string param, string param2, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateTestJsonFormDataRequestAsync(string param, string param2, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// test json serialization of form data @@ -3429,195 +1733,72 @@ private System.Threading.Tasks.ValueTask ValidateTestJsonFormDataRequestAsync(st /// field2 /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> TestJsonFormDataResponseAsync(string param, string param2, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> TestJsonFormDataWithHttpInfoAsync(string param, string param2, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'param' is set if (param == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'param' when calling FakeApi->TestJsonFormData"); - // verify the required parameter 'param2' is set + throw new ArgumentNullException(nameof(param)); if (param2 == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'param2' when calling FakeApi->TestJsonFormData"); - - await ValidateTestJsonFormDataRequestAsync(param, param2, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); + throw new ArgumentNullException(nameof(param2)); + await ValidateTestJsonFormDataRequestAsync(param, param2, cancellationToken).ConfigureAwait(false); - string path = "/fake/jsonFormData"; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - path = $"{path}?"; - + string path = "/fake/jsonFormData"; - if (path.EndsWith("&")) - path = path[..^1]; - if (path.EndsWith("?")) - path = path[..^1]; + path = $"{path}?"; + - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + if (path.EndsWith("&")) + path = path[..^1]; + if (path.EndsWith("?")) + path = path[..^1]; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - string[] contentTypes = new string[] { - "application/x-www-form-urlencoded" - }; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + // todo localVarRequestOptions.FormParameters.Add("param", Org.OpenAPITools.Client.ClientUtils.ParameterToString(param)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("param2", Org.OpenAPITools.Client.ClientUtils.ParameterToString(param2)); // form parameter - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { + string[] contentTypes = new string[] { "application/x-www-form-urlencoded" }; - // to determine the Accept header - string[] _accepts = new string[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.FormParameters.Add("param", Org.OpenAPITools.Client.ClientUtils.ParameterToString(param)); // form parameter - localVarRequestOptions.FormParameters.Add("param2", Org.OpenAPITools.Client.ClientUtils.ParameterToString(param2)); // form parameter - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/jsonFormData", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestJsonFormData", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// To test the collection format in query parameters - /// - /// Thrown when fails to make API call - /// - /// - /// - /// - /// - /// - public void TestQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context) - { - TestQueryParameterCollectionFormatResponse(pipe, ioutil, http, url, context); - } - - /// - /// To test the collection format in query parameters - /// - /// Thrown when fails to make API call - /// - /// - /// - /// - /// - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse TestQueryParameterCollectionFormatResponse(List pipe, List ioutil, List http, List url, List context) - { - // verify the required parameter 'pipe' is set - if (pipe == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'pipe' when calling FakeApi->TestQueryParameterCollectionFormat"); - - // verify the required parameter 'ioutil' is set - if (ioutil == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'ioutil' when calling FakeApi->TestQueryParameterCollectionFormat"); - - // verify the required parameter 'http' is set - if (http == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'http' when calling FakeApi->TestQueryParameterCollectionFormat"); - - // verify the required parameter 'url' is set - if (url == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'url' when calling FakeApi->TestQueryParameterCollectionFormat"); - - // verify the required parameter 'context' is set - if (context == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'context' when calling FakeApi->TestQueryParameterCollectionFormat"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "pipe", pipe)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "ioutil", ioutil)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("ssv", "http", http)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "url", url)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "context", context)); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - var localVarResponse = this.Client.Put("/fake/test-query-paramters", localVarRequestOptions, this.Configuration); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestQueryParameterCollectionFormat", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// To test the collection format in query parameters + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// /// /// /// /// /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task TestQueryParameterCollectionFormatAsync(List pipe, List ioutil, List http, List url, List context, System.Threading.CancellationToken? cancellationToken = null) - { - await TestQueryParameterCollectionFormatResponseAsync(pipe, ioutil, http, url, context, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateTestQueryParameterCollectionFormatRequestAsync(List pipe, List ioutil, List http, List url, List context, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateTestQueryParameterCollectionFormatRequestAsync(List pipe, List ioutil, List http, List url, List context, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// To test the collection format in query parameters @@ -3630,111 +1811,69 @@ private System.Threading.Tasks.ValueTask ValidateTestQueryParameterCollectionFor /// /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> TestQueryParameterCollectionFormatResponseAsync(List pipe, List ioutil, List http, List url, List context, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> TestQueryParameterCollectionFormatWithHttpInfoAsync(List pipe, List ioutil, List http, List url, List context, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'pipe' is set if (pipe == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'pipe' when calling FakeApi->TestQueryParameterCollectionFormat"); - // verify the required parameter 'ioutil' is set + throw new ArgumentNullException(nameof(pipe)); if (ioutil == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'ioutil' when calling FakeApi->TestQueryParameterCollectionFormat"); - // verify the required parameter 'http' is set + throw new ArgumentNullException(nameof(ioutil)); if (http == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'http' when calling FakeApi->TestQueryParameterCollectionFormat"); - // verify the required parameter 'url' is set + throw new ArgumentNullException(nameof(http)); if (url == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'url' when calling FakeApi->TestQueryParameterCollectionFormat"); - // verify the required parameter 'context' is set + throw new ArgumentNullException(nameof(url)); if (context == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'context' when calling FakeApi->TestQueryParameterCollectionFormat"); - - await ValidateTestQueryParameterCollectionFormatRequestAsync(pipe, ioutil, http, url, context, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake/test-query-paramters"; - - path = $"{path}?"; - - path = $"{path}pipe={Uri.EscapeDataString(pipe.ToString())&"; + throw new ArgumentNullException(nameof(context)); - path = $"{path}ioutil={Uri.EscapeDataString(ioutil.ToString())&"; + await ValidateTestQueryParameterCollectionFormatRequestAsync(pipe, ioutil, http, url, context, cancellationToken).ConfigureAwait(false); - path = $"{path}http={Uri.EscapeDataString(http.ToString())&"; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - path = $"{path}url={Uri.EscapeDataString(url.ToString())&"; + string path = "/fake/test-query-paramters"; - path = $"{path}context={Uri.EscapeDataString(context.ToString())&"; + path = $"{path}?"; + + path = $"{path}pipe={Uri.EscapeDataString(pipe.ToString()!)&"; - if (path.EndsWith("&")) - path = path[..^1]; + path = $"{path}ioutil={Uri.EscapeDataString(ioutil.ToString()!)&"; - if (path.EndsWith("?")) - path = path[..^1]; + path = $"{path}http={Uri.EscapeDataString(http.ToString()!)&"; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + path = $"{path}url={Uri.EscapeDataString(url.ToString()!)&"; + path = $"{path}context={Uri.EscapeDataString(context.ToString()!)&"; - string[] contentTypes = new string[] { - }; + if (path.EndsWith("&")) + path = path[..^1]; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + if (path.EndsWith("?")) + path = path[..^1]; + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - ApiResponse apiResponse = new(responseMessage, responseContent); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - }; - // to determine the Accept header - string[] _accepts = new string[] { + string[] contentTypes = new string[] { }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "pipe", pipe)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "ioutil", ioutil)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("ssv", "http", http)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "url", url)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "context", context)); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request + ApiResponse apiResponse = new(responseMessage, responseContent); - var localVarResponse = await this.AsynchronousClient.PutAsync("/fake/test-query-paramters", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestQueryParameterCollectionFormat", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + return apiResponse; } - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 14e069235093..4ce310c787d1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -19,13 +19,11 @@ namespace Org.OpenAPITools.Api { - /// /// Represents a collection of functions to interact with the API endpoints /// - public interface IFakeClassnameTags123ApiSync : IApiAccessor + public interface IFakeClassnameTags123Api { - #region Synchronous Operations /// /// To test class name in snake case /// @@ -34,28 +32,10 @@ public interface IFakeClassnameTags123ApiSync : IApiAccessor /// /// Thrown when fails to make API call /// client model - /// ModelClient - ModelClient TestClassname(ModelClient modelClient); - - /// - /// To test class name in snake case - /// - /// - /// To test class name in snake case - /// - /// Thrown when fails to make API call - /// client model - /// ApiResponse of ModelClient - ApiResponse TestClassnameResponse(ModelClient modelClient); - #endregion Synchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IFakeClassnameTags123ApiAsync : IApiAccessor - { - #region Asynchronous Operations + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ModelClient) + System.Threading.Tasks.Task> TestClassnameWithHttpInfoAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); + /// /// To test class name in snake case /// @@ -65,29 +45,19 @@ public interface IFakeClassnameTags123ApiAsync : IApiAccessor /// Thrown when fails to make API call /// client model /// Cancellation Token to cancel the request. - /// Task of ModelClient + /// Task of ApiResponse (ModelClient) System.Threading.Tasks.Task TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); - + /// /// To test class name in snake case /// /// /// To test class name in snake case /// - /// Thrown when fails to make API call /// client model /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ModelClient) - System.Threading.Tasks.Task> TestClassnameResponseAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IFakeClassnameTags123Api : IFakeClassnameTags123ApiSync, IFakeClassnameTags123ApiAsync - { - + /// Task of ApiResponse (ModelClient?) + System.Threading.Tasks.Task TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null); } /// @@ -95,182 +65,42 @@ public interface IFakeClassnameTags123Api : IFakeClassnameTags123ApiSync, IFakeC /// public partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { - private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null; private readonly System.Net.Http.HttpClient _httpClient; - private readonly Newtonsoft.Json.JsonConverter[] _jsonConverters; - - /// - /// Initializes a new instance of the class. - /// - /// - public FakeClassnameTags123Api() : this((string)null) - { - } /// /// Initializes a new instance of the class. /// /// - public FakeClassnameTags123Api(System.Net.Http.HttpClient httpClient, Newtonsoft.Json.JsonConverter[] jsonConverters) : this((string)null) + public FakeClassnameTags123Api(System.Net.Http.HttpClient httpClient) { _httpClient = httpClient; - - _jsonConverters = jsonConverters; - } - - /// - /// Initializes a new instance of the class. - /// - /// - public FakeClassnameTags123Api(String basePath) - { - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public FakeClassnameTags123Api(Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public FakeClassnameTags123Api(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// The client for accessing this underlying API asynchronously. - /// - public Org.OpenAPITools.Client.IAsynchronousClient AsynchronousClient { get; set; } - - /// - /// The client for accessing this underlying API synchronously. - /// - public Org.OpenAPITools.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; } /// - /// Gets or sets the configuration object + /// Returns the token to be used in the api query /// - /// An instance of the Configuration - public Org.OpenAPITools.Client.IReadableConfiguration Configuration { get; set; } + public Func>? GetTokenAsync { get; set; } - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public Org.OpenAPITools.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } /// - /// To test class name in snake case To test class name in snake case + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// client model - /// ModelClient - public ModelClient TestClassname(ModelClient modelClient) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = TestClassnameResponse(modelClient); - return localVarResponse.Data; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestClassnameRequestAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// To test class name in snake case To test class name in snake case /// /// Thrown when fails to make API call /// client model - /// ApiResponse of ModelClient - public Org.OpenAPITools.Client.ApiResponse TestClassnameResponse(ModelClient modelClient) + /// Cancellation Token to cancel the request. + /// Task of ModelClient + public async System.Threading.Tasks.Task TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'modelClient' is set - if (modelClient == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'modelClient' when calling FakeClassnameTags123Api->TestClassname"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = modelClient; - - // authentication (api_key_query) required - if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key_query"))) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "api_key_query", this.Configuration.GetApiKeyWithPrefix("api_key_query"))); - } - - // make the HTTP request - var localVarResponse = this.Client.Patch("/fake_classname_test", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestClassname", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse result = await TestClassnameWithHttpInfoAsync(modelClient, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -280,17 +110,14 @@ public Org.OpenAPITools.Client.ApiResponse TestClassnameResponse(Mo /// client model /// Cancellation Token to cancel the request. /// Task of ModelClient - public async System.Threading.Tasks.Task TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await TestClassnameResponseAsync(modelClient, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateTestClassnameRequestAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await TestClassnameWithHttpInfoAsync(modelClient, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// To test class name in snake case To test class name in snake case @@ -299,95 +126,58 @@ private System.Threading.Tasks.ValueTask ValidateTestClassnameRequestAsync(Model /// client model /// Cancellation Token to cancel the request. /// Task of ApiResponse (ModelClient) - public async System.Threading.Tasks.Task> TestClassnameResponseAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> TestClassnameWithHttpInfoAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'modelClient' is set if (modelClient == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'modelClient' when calling FakeClassnameTags123Api->TestClassname"); + throw new ArgumentNullException(nameof(modelClient)); - await ValidateTestClassnameRequestAsync(modelClient, cancellationToken); + await ValidateTestClassnameRequestAsync(modelClient, cancellationToken).ConfigureAwait(false); - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); + string path = "/fake_classname_test"; - string path = "/fake_classname_test"; + path = $"{path}?"; + - path = $"{path}?"; - + if (path.EndsWith("&")) + path = path[..^1]; - if (path.EndsWith("&")) - path = path[..^1]; + if (path.EndsWith("?")) + path = path[..^1]; - if (path.EndsWith("?")) - path = path[..^1]; + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + // todo localVarRequestOptions.Data = modelClient; - string[] contentTypes = new string[] { - "application/json" - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } + // authentication (api_key_query) required + //todo if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key_query"))) + //todo localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "api_key_query", this.Configuration.GetApiKeyWithPrefix("api_key_query"))); - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] _contentTypes = new string[] { + string[] contentTypes = new string[] { "application/json" }; - // to determine the Accept header - string[] _accepts = new string[] { - "application/json" - }; + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - localVarRequestOptions.Data = modelClient; + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // authentication (api_key_query) required - if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key_query"))) - { - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "api_key_query", this.Configuration.GetApiKeyWithPrefix("api_key_query"))); - } + ApiResponse apiResponse = new(responseMessage, responseContent); - // make the HTTP request + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - var localVarResponse = await this.AsynchronousClient.PatchAsync("/fake_classname_test", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("TestClassname", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + return apiResponse; } - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs index 422582940b91..69f4202763cc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs @@ -19,207 +19,11 @@ namespace Org.OpenAPITools.Api { - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IPetApiSync : IApiAccessor - { - #region Synchronous Operations - /// - /// Add a new pet to the store - /// - /// Thrown when fails to make API call - /// Pet object that needs to be added to the store - /// - void AddPet(Pet pet); - - /// - /// Add a new pet to the store - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Pet object that needs to be added to the store - /// ApiResponse of Object(void) - ApiResponse AddPetResponse(Pet pet); - /// - /// Deletes a pet - /// - /// Thrown when fails to make API call - /// Pet id to delete - /// (optional) - /// - void DeletePet(long petId, string apiKey = default(string)); - - /// - /// Deletes a pet - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Pet id to delete - /// (optional) - /// ApiResponse of Object(void) - ApiResponse DeletePetResponse(long petId, string apiKey = default(string)); - /// - /// Finds Pets by status - /// - /// - /// Multiple status values can be provided with comma separated strings - /// - /// Thrown when fails to make API call - /// Status values that need to be considered for filter - /// List<Pet> - List FindPetsByStatus(List status); - - /// - /// Finds Pets by status - /// - /// - /// Multiple status values can be provided with comma separated strings - /// - /// Thrown when fails to make API call - /// Status values that need to be considered for filter - /// ApiResponse of List<Pet> - ApiResponse> FindPetsByStatusResponse(List status); - /// - /// Finds Pets by tags - /// - /// - /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - /// - /// Thrown when fails to make API call - /// Tags to filter by - /// List<Pet> - List FindPetsByTags(List tags); - - /// - /// Finds Pets by tags - /// - /// - /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - /// - /// Thrown when fails to make API call - /// Tags to filter by - /// ApiResponse of List<Pet> - ApiResponse> FindPetsByTagsResponse(List tags); - /// - /// Find pet by ID - /// - /// - /// Returns a single pet - /// - /// Thrown when fails to make API call - /// ID of pet to return - /// Pet - Pet GetPetById(long petId); - - /// - /// Find pet by ID - /// - /// - /// Returns a single pet - /// - /// Thrown when fails to make API call - /// ID of pet to return - /// ApiResponse of Pet - ApiResponse GetPetByIdResponse(long petId); - /// - /// Update an existing pet - /// - /// Thrown when fails to make API call - /// Pet object that needs to be added to the store - /// - void UpdatePet(Pet pet); - - /// - /// Update an existing pet - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Pet object that needs to be added to the store - /// ApiResponse of Object(void) - ApiResponse UpdatePetResponse(Pet pet); - /// - /// Updates a pet in the store with form data - /// - /// Thrown when fails to make API call - /// ID of pet that needs to be updated - /// Updated name of the pet (optional) - /// Updated status of the pet (optional) - /// - void UpdatePetWithForm(long petId, string name = default(string), string status = default(string)); - - /// - /// Updates a pet in the store with form data - /// - /// - /// - /// - /// Thrown when fails to make API call - /// ID of pet that needs to be updated - /// Updated name of the pet (optional) - /// Updated status of the pet (optional) - /// ApiResponse of Object(void) - ApiResponse UpdatePetWithFormResponse(long petId, string name = default(string), string status = default(string)); - /// - /// uploads an image - /// - /// Thrown when fails to make API call - /// ID of pet to update - /// Additional data to pass to server (optional) - /// file to upload (optional) - /// ApiResponse - ApiResponse UploadFile(long petId, string additionalMetadata = default(string), System.IO.Stream file = default(System.IO.Stream)); - - /// - /// uploads an image - /// - /// - /// - /// - /// Thrown when fails to make API call - /// ID of pet to update - /// Additional data to pass to server (optional) - /// file to upload (optional) - /// ApiResponse of ApiResponse - ApiResponse UploadFileResponse(long petId, string additionalMetadata = default(string), System.IO.Stream file = default(System.IO.Stream)); - /// - /// uploads an image (required) - /// - /// Thrown when fails to make API call - /// ID of pet to update - /// file to upload - /// Additional data to pass to server (optional) - /// ApiResponse - ApiResponse UploadFileWithRequiredFile(long petId, System.IO.Stream requiredFile, string additionalMetadata = default(string)); - - /// - /// uploads an image (required) - /// - /// - /// - /// - /// Thrown when fails to make API call - /// ID of pet to update - /// file to upload - /// Additional data to pass to server (optional) - /// ApiResponse of ApiResponse - ApiResponse UploadFileWithRequiredFileResponse(long petId, System.IO.Stream requiredFile, string additionalMetadata = default(string)); - #endregion Synchronous Operations - } - /// /// Represents a collection of functions to interact with the API endpoints /// - public interface IPetApiAsync : IApiAccessor + public interface IPetApi { - #region Asynchronous Operations /// /// Add a new pet to the store /// @@ -229,9 +33,9 @@ public interface IPetApiAsync : IApiAccessor /// Thrown when fails to make API call /// Pet object that needs to be added to the store /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task AddPetAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse + System.Threading.Tasks.Task> AddPetWithHttpInfoAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null); + /// /// Add a new pet to the store /// @@ -242,7 +46,8 @@ public interface IPetApiAsync : IApiAccessor /// Pet object that needs to be added to the store /// Cancellation Token to cancel the request. /// Task of ApiResponse - System.Threading.Tasks.Task> AddPetResponseAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task AddPetAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null); + /// /// Deletes a pet /// @@ -253,9 +58,9 @@ public interface IPetApiAsync : IApiAccessor /// Pet id to delete /// (optional) /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task DeletePetAsync(long petId, string??? apiKey = null, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse + System.Threading.Tasks.Task> DeletePetWithHttpInfoAsync(long petId, string??? apiKey = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// Deletes a pet /// @@ -267,7 +72,8 @@ public interface IPetApiAsync : IApiAccessor /// (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse - System.Threading.Tasks.Task> DeletePetResponseAsync(long petId, string??? apiKey = null, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task DeletePetAsync(long petId, string??? apiKey = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// Finds Pets by status /// @@ -277,9 +83,9 @@ public interface IPetApiAsync : IApiAccessor /// Thrown when fails to make API call /// Status values that need to be considered for filter /// Cancellation Token to cancel the request. - /// Task of List<Pet> - System.Threading.Tasks.Task> FindPetsByStatusAsync(List status, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse (List<Pet>) + System.Threading.Tasks.Task>> FindPetsByStatusWithHttpInfoAsync(List status, System.Threading.CancellationToken? cancellationToken = null); + /// /// Finds Pets by status /// @@ -290,7 +96,18 @@ public interface IPetApiAsync : IApiAccessor /// Status values that need to be considered for filter /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Pet>) - System.Threading.Tasks.Task>> FindPetsByStatusResponseAsync(List status, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task> FindPetsByStatusAsync(List status, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma separated strings + /// + /// Status values that need to be considered for filter + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (List<Pet>?) + System.Threading.Tasks.Task?> FindPetsByStatusOrDefaultAsync(List status, System.Threading.CancellationToken? cancellationToken = null); /// /// Finds Pets by tags /// @@ -300,9 +117,9 @@ public interface IPetApiAsync : IApiAccessor /// Thrown when fails to make API call /// Tags to filter by /// Cancellation Token to cancel the request. - /// Task of List<Pet> - System.Threading.Tasks.Task> FindPetsByTagsAsync(List tags, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse (List<Pet>) + System.Threading.Tasks.Task>> FindPetsByTagsWithHttpInfoAsync(List tags, System.Threading.CancellationToken? cancellationToken = null); + /// /// Finds Pets by tags /// @@ -313,7 +130,18 @@ public interface IPetApiAsync : IApiAccessor /// Tags to filter by /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Pet>) - System.Threading.Tasks.Task>> FindPetsByTagsResponseAsync(List tags, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task> FindPetsByTagsAsync(List tags, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// Finds Pets by tags + /// + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (List<Pet>?) + System.Threading.Tasks.Task?> FindPetsByTagsOrDefaultAsync(List tags, System.Threading.CancellationToken? cancellationToken = null); /// /// Find pet by ID /// @@ -323,9 +151,9 @@ public interface IPetApiAsync : IApiAccessor /// Thrown when fails to make API call /// ID of pet to return /// Cancellation Token to cancel the request. - /// Task of Pet - System.Threading.Tasks.Task GetPetByIdAsync(long petId, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse (Pet) + System.Threading.Tasks.Task> GetPetByIdWithHttpInfoAsync(long petId, System.Threading.CancellationToken? cancellationToken = null); + /// /// Find pet by ID /// @@ -336,7 +164,18 @@ public interface IPetApiAsync : IApiAccessor /// ID of pet to return /// Cancellation Token to cancel the request. /// Task of ApiResponse (Pet) - System.Threading.Tasks.Task> GetPetByIdResponseAsync(long petId, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task GetPetByIdAsync(long petId, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// Find pet by ID + /// + /// + /// Returns a single pet + /// + /// ID of pet to return + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (Pet?) + System.Threading.Tasks.Task GetPetByIdOrDefaultAsync(long petId, System.Threading.CancellationToken? cancellationToken = null); /// /// Update an existing pet /// @@ -346,9 +185,9 @@ public interface IPetApiAsync : IApiAccessor /// Thrown when fails to make API call /// Pet object that needs to be added to the store /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task UpdatePetAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse + System.Threading.Tasks.Task> UpdatePetWithHttpInfoAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null); + /// /// Update an existing pet /// @@ -359,7 +198,8 @@ public interface IPetApiAsync : IApiAccessor /// Pet object that needs to be added to the store /// Cancellation Token to cancel the request. /// Task of ApiResponse - System.Threading.Tasks.Task> UpdatePetResponseAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task UpdatePetAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null); + /// /// Updates a pet in the store with form data /// @@ -371,9 +211,9 @@ public interface IPetApiAsync : IApiAccessor /// Updated name of the pet (optional) /// Updated status of the pet (optional) /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task UpdatePetWithFormAsync(long petId, string??? name = null, string??? status = null, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse + System.Threading.Tasks.Task> UpdatePetWithFormWithHttpInfoAsync(long petId, string??? name = null, string??? status = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// Updates a pet in the store with form data /// @@ -386,7 +226,8 @@ public interface IPetApiAsync : IApiAccessor /// Updated status of the pet (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse - System.Threading.Tasks.Task> UpdatePetWithFormResponseAsync(long petId, string??? name = null, string??? status = null, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task UpdatePetWithFormAsync(long petId, string??? name = null, string??? status = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// uploads an image /// @@ -398,9 +239,9 @@ public interface IPetApiAsync : IApiAccessor /// Additional data to pass to server (optional) /// file to upload (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task UploadFileAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse (ApiResponse) + System.Threading.Tasks.Task> UploadFileWithHttpInfoAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// uploads an image /// @@ -413,7 +254,20 @@ public interface IPetApiAsync : IApiAccessor /// file to upload (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse (ApiResponse) - System.Threading.Tasks.Task> UploadFileResponseAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task UploadFileAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// uploads an image + /// + /// + /// + /// + /// ID of pet to update + /// Additional data to pass to server (optional) + /// file to upload (optional) + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse?) + System.Threading.Tasks.Task UploadFileOrDefaultAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null); /// /// uploads an image (required) /// @@ -425,9 +279,9 @@ public interface IPetApiAsync : IApiAccessor /// file to upload /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata = null, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse (ApiResponse) + System.Threading.Tasks.Task> UploadFileWithRequiredFileWithHttpInfoAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata = null, System.Threading.CancellationToken? cancellationToken = null); + /// /// uploads an image (required) /// @@ -440,16 +294,20 @@ public interface IPetApiAsync : IApiAccessor /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse (ApiResponse) - System.Threading.Tasks.Task> UploadFileWithRequiredFileResponseAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata = null, System.Threading.CancellationToken? cancellationToken = null); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IPetApi : IPetApiSync, IPetApiAsync - { - + System.Threading.Tasks.Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata = null, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// uploads an image (required) + /// + /// + /// + /// + /// ID of pet to update + /// file to upload + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse?) + System.Threading.Tasks.Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata = null, System.Threading.CancellationToken? cancellationToken = null); } /// @@ -457,217 +315,32 @@ public interface IPetApi : IPetApiSync, IPetApiAsync /// public partial class PetApi : IPetApi { - private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null; private readonly System.Net.Http.HttpClient _httpClient; - private readonly Newtonsoft.Json.JsonConverter[] _jsonConverters; /// /// Initializes a new instance of the class. /// /// - public PetApi() : this((string)null) + public PetApi(System.Net.Http.HttpClient httpClient) { + _httpClient = httpClient; } /// - /// Initializes a new instance of the class. + /// Returns the token to be used in the api query /// - /// - public PetApi(System.Net.Http.HttpClient httpClient, Newtonsoft.Json.JsonConverter[] jsonConverters) : this((string)null) - { - _httpClient = httpClient; + public Func>? GetTokenAsync { get; set; } - _jsonConverters = jsonConverters; - } /// - /// Initializes a new instance of the class. + /// Validate the input before sending the request /// - /// - public PetApi(String basePath) - { - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateAddPetRequestAsync(Pet pet, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public PetApi(Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public PetApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// The client for accessing this underlying API asynchronously. - /// - public Org.OpenAPITools.Client.IAsynchronousClient AsynchronousClient { get; set; } - - /// - /// The client for accessing this underlying API synchronously. - /// - public Org.OpenAPITools.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public Org.OpenAPITools.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public Org.OpenAPITools.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } - - /// - /// Add a new pet to the store - /// - /// Thrown when fails to make API call - /// Pet object that needs to be added to the store - /// - public void AddPet(Pet pet) - { - AddPetResponse(pet); - } - - /// - /// Add a new pet to the store - /// - /// Thrown when fails to make API call - /// Pet object that needs to be added to the store - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse AddPetResponse(Pet pet) - { - // verify the required parameter 'pet' is set - if (pet == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'pet' when calling PetApi->AddPet"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json", - "application/xml" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = pet; - - // authentication (http_signature_test) required - if (this.Configuration.HttpSigningConfiguration != null) - { - var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "POST", "/pet", localVarRequestOptions); - foreach (var headerItem in HttpSigningHeaders) - { - if (localVarRequestOptions.HeaderParameters.ContainsKey(headerItem.Key)) - { - localVarRequestOptions.HeaderParameters[headerItem.Key] = new List() { headerItem.Value }; - } - else - { - localVarRequestOptions.HeaderParameters.Add(headerItem.Key, headerItem.Value); - } - } - } - // authentication (petstore_auth) required - // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - - // make the HTTP request - var localVarResponse = this.Client.Post("/pet", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("AddPet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Add a new pet to the store - /// - /// Thrown when fails to make API call - /// Pet object that needs to be added to the store - /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task AddPetAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null) - { - await AddPetResponseAsync(pet, cancellationToken).ConfigureAwait(false); - } - - private System.Threading.Tasks.ValueTask ValidateAddPetRequestAsync(Pet pet, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// Add a new pet to the store @@ -676,79 +349,36 @@ private System.Threading.Tasks.ValueTask ValidateAddPetRequestAsync(Pet pet, Sys /// Pet object that needs to be added to the store /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> AddPetResponseAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> AddPetWithHttpInfoAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'pet' is set if (pet == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'pet' when calling PetApi->AddPet"); - - await ValidateAddPetRequestAsync(pet, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/pet"; + throw new ArgumentNullException(nameof(pet)); - path = $"{path}?"; - + await ValidateAddPetRequestAsync(pet, cancellationToken).ConfigureAwait(false); - if (path.EndsWith("&")) - path = path[..^1]; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - if (path.EndsWith("?")) - path = path[..^1]; + string path = "/pet"; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + path = $"{path}?"; + - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); + if (path.EndsWith("&")) + path = path[..^1]; - string[] contentTypes = new string[] { - "application/json", - "application/xml" - }; + if (path.EndsWith("?")) + path = path[..^1]; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - "application/json", - "application/xml" - }; - - // to determine the Accept header - string[] _accepts = new string[] { - }; + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.Data = pet; + // todo localVarRequestOptions.Data = pet; // authentication (http_signature_test) required + //todo + /* if (this.Configuration.HttpSigningConfiguration != null) { var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "POST", "/pet", localVarRequestOptions); @@ -764,105 +394,46 @@ private System.Threading.Tasks.ValueTask ValidateAddPetRequestAsync(Pet pet, Sys } } } + */ // authentication (petstore_auth) required // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/pet", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("AddPet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Deletes a pet - /// - /// Thrown when fails to make API call - /// Pet id to delete - /// (optional) - /// - public void DeletePet(long petId, string apiKey = default(string)) - { - DeletePetResponse(petId, apiKey); - } + //todo if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - /// - /// Deletes a pet - /// - /// Thrown when fails to make API call - /// Pet id to delete - /// (optional) - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse DeletePetResponse(long petId, string apiKey = default(string)) - { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); - String[] _contentTypes = new String[] { + string[] contentTypes = new string[] { + "application/json", + "application/xml" }; - // to determine the Accept header - String[] _accepts = new String[] { - }; + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter - if (apiKey != null) - { - localVarRequestOptions.HeaderParameters.Add("api_key", Org.OpenAPITools.Client.ClientUtils.ParameterToString(apiKey)); // header parameter - } - - // authentication (petstore_auth) required - // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - var localVarResponse = this.Client.Delete("/pet/{petId}", localVarRequestOptions, this.Configuration); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("DeletePet", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// Deletes a pet + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// Pet id to delete /// (optional) /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task DeletePetAsync(long petId, string??? apiKey = null, System.Threading.CancellationToken? cancellationToken = null) - { - await DeletePetResponseAsync(petId, apiKey, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateDeletePetRequestAsync(long petId, string??? apiKey, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateDeletePetRequestAsync(long petId, string??? apiKey, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// Deletes a pet @@ -872,172 +443,78 @@ private System.Threading.Tasks.ValueTask ValidateDeletePetRequestAsync(long petI /// (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> DeletePetResponseAsync(long petId, string??? apiKey = null, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> DeletePetWithHttpInfoAsync(long petId, string??? apiKey = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateDeletePetRequestAsync(petId, apiKey, cancellationToken); + await ValidateDeletePetRequestAsync(petId, apiKey, cancellationToken).ConfigureAwait(false); - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/pet/{petId}"; - path = path.Replace("{petId}", Uri.EscapeDataString(petId)); - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + string path = "/pet/{petId}"; + path = path.Replace("{petId}", Uri.EscapeDataString(petId)); - if (apiKey != null) - request.Headers.Add(api_key, apiKey); - string[] contentTypes = new string[] { - }; + path = $"{path}?"; + - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + if (path.EndsWith("&")) + path = path[..^1]; + if (path.EndsWith("?")) + path = path[..^1]; - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + if (apiKey != null) + request.Headers.Add(api_key, apiKey); - ApiResponse apiResponse = new(responseMessage, responseContent); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - return apiResponse; - } + // authentication (petstore_auth) required + // oauth required + //todo if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - string[] _contentTypes = new string[] { + string[] contentTypes = new string[] { }; - // to determine the Accept header - string[] _accepts = new string[] { - }; + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter - if (apiKey != null) - { - localVarRequestOptions.HeaderParameters.Add("api_key", Org.OpenAPITools.Client.ClientUtils.ParameterToString(apiKey)); // header parameter - } + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // authentication (petstore_auth) required - // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - - // make the HTTP request + ApiResponse apiResponse = new(responseMessage, responseContent); - var localVarResponse = await this.AsynchronousClient.DeleteAsync("/pet/{petId}", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("DeletePet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + return apiResponse; } /// - /// Finds Pets by status Multiple status values can be provided with comma separated strings + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// Status values that need to be considered for filter - /// List<Pet> - public List FindPetsByStatus(List status) - { - Org.OpenAPITools.Client.ApiResponse> localVarResponse = FindPetsByStatusResponse(status); - return localVarResponse.Data; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFindPetsByStatusRequestAsync(List status, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// Finds Pets by status Multiple status values can be provided with comma separated strings /// /// Thrown when fails to make API call /// Status values that need to be considered for filter - /// ApiResponse of List<Pet> - public Org.OpenAPITools.Client.ApiResponse> FindPetsByStatusResponse(List status) + /// Cancellation Token to cancel the request. + /// Task of List<Pet> + public async System.Threading.Tasks.Task> FindPetsByStatusAsync(List status, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'status' is set - if (status == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'status' when calling PetApi->FindPetsByStatus"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/xml", - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "status", status)); - - // authentication (http_signature_test) required - if (this.Configuration.HttpSigningConfiguration != null) - { - var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "GET", "/pet/findByStatus", localVarRequestOptions); - foreach (var headerItem in HttpSigningHeaders) - { - if (localVarRequestOptions.HeaderParameters.ContainsKey(headerItem.Key)) - { - localVarRequestOptions.HeaderParameters[headerItem.Key] = new List() { headerItem.Value }; - } - else - { - localVarRequestOptions.HeaderParameters.Add(headerItem.Key, headerItem.Value); - } - } - } - // authentication (petstore_auth) required - // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - - // make the HTTP request - var localVarResponse = this.Client.Get>("/pet/findByStatus", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FindPetsByStatus", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse> result = await FindPetsByStatusWithHttpInfoAsync(status, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -1047,17 +524,14 @@ public Org.OpenAPITools.Client.ApiResponse> FindPetsByStatusResponse(L /// Status values that need to be considered for filter /// Cancellation Token to cancel the request. /// Task of List<Pet> - public async System.Threading.Tasks.Task> FindPetsByStatusAsync(List status, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task?> FindPetsByStatusOrDefaultAsync(List status, System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.ApiResponse> localVarResponse = await FindPetsByStatusResponseAsync(status, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateFindPetsByStatusRequestAsync(List status, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse> result = await FindPetsByStatusWithHttpInfoAsync(status, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// Finds Pets by status Multiple status values can be provided with comma separated strings @@ -1066,79 +540,37 @@ private System.Threading.Tasks.ValueTask ValidateFindPetsByStatusRequestAsync(Li /// Status values that need to be considered for filter /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Pet>) - public async System.Threading.Tasks.Task>> FindPetsByStatusResponseAsync(List status, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task>> FindPetsByStatusWithHttpInfoAsync(List status, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'status' is set if (status == null) - throw new Org.OpenAPITools.Client.ApiException>(400, "Missing required parameter 'status' when calling PetApi->FindPetsByStatus"); - - await ValidateFindPetsByStatusRequestAsync(status, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + throw new ArgumentNullException(nameof(status)); - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); + await ValidateFindPetsByStatusRequestAsync(status, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - string path = "/pet/findByStatus"; + string path = "/pet/findByStatus"; - path = $"{path}?"; - - path = $"{path}status={Uri.EscapeDataString(status.ToString())&"; + path = $"{path}?"; + + path = $"{path}status={Uri.EscapeDataString(status.ToString()!)&"; - if (path.EndsWith("&")) - path = path[..^1]; - if (path.EndsWith("?")) - path = path[..^1]; + if (path.EndsWith("&")) + path = path[..^1]; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + if (path.EndsWith("?")) + path = path[..^1]; + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - string[] contentTypes = new string[] { - }; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse> apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException>(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - }; - - // to determine the Accept header - string[] _accepts = new string[] { - "application/xml", - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "status", status)); // authentication (http_signature_test) required + //todo + /* if (this.Configuration.HttpSigningConfiguration != null) { var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "GET", "/pet/findByStatus", localVarRequestOptions); @@ -1154,102 +586,53 @@ private System.Threading.Tasks.ValueTask ValidateFindPetsByStatusRequestAsync(Li } } } + */ // authentication (petstore_auth) required // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } + //todo if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - // make the HTTP request - var localVarResponse = await this.AsynchronousClient.GetAsync>("/pet/findByStatus", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string[] contentTypes = new string[] { + }; - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FindPetsByStatus", localVarResponse); - if (_exception != null) throw _exception; - } + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - return localVarResponse; + ApiResponse> apiResponse = new(responseMessage, responseContent); + + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + + return apiResponse; } /// - /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// Tags to filter by - /// List<Pet> - public List FindPetsByTags(List tags) - { - Org.OpenAPITools.Client.ApiResponse> localVarResponse = FindPetsByTagsResponse(tags); - return localVarResponse.Data; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFindPetsByTagsRequestAsync(List tags, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// /// Thrown when fails to make API call /// Tags to filter by - /// ApiResponse of List<Pet> - public Org.OpenAPITools.Client.ApiResponse> FindPetsByTagsResponse(List tags) + /// Cancellation Token to cancel the request. + /// Task of List<Pet> + public async System.Threading.Tasks.Task> FindPetsByTagsAsync(List tags, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'tags' is set - if (tags == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'tags' when calling PetApi->FindPetsByTags"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/xml", - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "tags", tags)); - - // authentication (http_signature_test) required - if (this.Configuration.HttpSigningConfiguration != null) - { - var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "GET", "/pet/findByTags", localVarRequestOptions); - foreach (var headerItem in HttpSigningHeaders) - { - if (localVarRequestOptions.HeaderParameters.ContainsKey(headerItem.Key)) - { - localVarRequestOptions.HeaderParameters[headerItem.Key] = new List() { headerItem.Value }; - } - else - { - localVarRequestOptions.HeaderParameters.Add(headerItem.Key, headerItem.Value); - } - } - } - // authentication (petstore_auth) required - // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - - // make the HTTP request - var localVarResponse = this.Client.Get>("/pet/findByTags", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FindPetsByTags", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse> result = await FindPetsByTagsWithHttpInfoAsync(tags, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -1259,17 +642,14 @@ public Org.OpenAPITools.Client.ApiResponse> FindPetsByTagsResponse(Lis /// Tags to filter by /// Cancellation Token to cancel the request. /// Task of List<Pet> - public async System.Threading.Tasks.Task> FindPetsByTagsAsync(List tags, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task?> FindPetsByTagsOrDefaultAsync(List tags, System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.ApiResponse> localVarResponse = await FindPetsByTagsResponseAsync(tags, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateFindPetsByTagsRequestAsync(List tags, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse> result = await FindPetsByTagsWithHttpInfoAsync(tags, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -1278,79 +658,37 @@ private System.Threading.Tasks.ValueTask ValidateFindPetsByTagsRequestAsync(List /// Tags to filter by /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Pet>) - public async System.Threading.Tasks.Task>> FindPetsByTagsResponseAsync(List tags, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task>> FindPetsByTagsWithHttpInfoAsync(List tags, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'tags' is set if (tags == null) - throw new Org.OpenAPITools.Client.ApiException>(400, "Missing required parameter 'tags' when calling PetApi->FindPetsByTags"); - - await ValidateFindPetsByTagsRequestAsync(tags, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/pet/findByTags"; - - path = $"{path}?"; - - path = $"{path}tags={Uri.EscapeDataString(tags.ToString())&"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - - - - string[] contentTypes = new string[] { - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + throw new ArgumentNullException(nameof(tags)); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + await ValidateFindPetsByTagsRequestAsync(tags, cancellationToken).ConfigureAwait(false); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + string path = "/pet/findByTags"; - ApiResponse> apiResponse = new(responseMessage, responseContent); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException>(apiResponse); + path = $"{path}?"; + + path = $"{path}tags={Uri.EscapeDataString(tags.ToString()!)&"; - return apiResponse; - } - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + if (path.EndsWith("&")) + path = path[..^1]; - string[] _contentTypes = new string[] { - }; + if (path.EndsWith("?")) + path = path[..^1]; - // to determine the Accept header - string[] _accepts = new string[] { - "application/xml", - "application/json" - }; + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "tags", tags)); // authentication (http_signature_test) required + //todo + /* if (this.Configuration.HttpSigningConfiguration != null) { var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "GET", "/pet/findByTags", localVarRequestOptions); @@ -1366,101 +704,41 @@ private System.Threading.Tasks.ValueTask ValidateFindPetsByTagsRequestAsync(List } } } + */ // authentication (petstore_auth) required // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - - // make the HTTP request + //todo if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - var localVarResponse = await this.AsynchronousClient.GetAsync>("/pet/findByTags", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("FindPetsByTags", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Find pet by ID Returns a single pet - /// - /// Thrown when fails to make API call - /// ID of pet to return - /// Pet - public Pet GetPetById(long petId) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = GetPetByIdResponse(petId); - return localVarResponse.Data; - } - - /// - /// Find pet by ID Returns a single pet - /// - /// Thrown when fails to make API call - /// ID of pet to return - /// ApiResponse of Pet - public Org.OpenAPITools.Client.ApiResponse GetPetByIdResponse(long petId) - { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { + string[] contentTypes = new string[] { }; - // to determine the Accept header - String[] _accepts = new String[] { - "application/xml", - "application/json" - }; + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // authentication (api_key) required - if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key"))) - { - localVarRequestOptions.HeaderParameters.Add("api_key", this.Configuration.GetApiKeyWithPrefix("api_key")); - } - - // make the HTTP request - var localVarResponse = this.Client.Get("/pet/{petId}", localVarRequestOptions, this.Configuration); + ApiResponse> apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("GetPetById", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// Find pet by ID Returns a single pet + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// ID of pet to return /// Cancellation Token to cancel the request. - /// Task of Pet - public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System.Threading.CancellationToken? cancellationToken = null) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetPetByIdResponseAsync(petId, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateGetPetByIdRequestAsync(long petId, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } + protected virtual System.Threading.Tasks.ValueTask ValidateGetPetByIdRequestAsync(long petId, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// Find pet by ID Returns a single pet @@ -1468,269 +746,140 @@ private System.Threading.Tasks.ValueTask ValidateGetPetByIdRequestAsync(long pet /// Thrown when fails to make API call /// ID of pet to return /// Cancellation Token to cancel the request. - /// Task of ApiResponse (Pet) - public async System.Threading.Tasks.Task> GetPetByIdResponseAsync(long petId, System.Threading.CancellationToken? cancellationToken = null) - { - - await ValidateGetPetByIdRequestAsync(petId, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/pet/{petId}"; - path = path.Replace("{petId}", Uri.EscapeDataString(petId)); - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - - - - string[] contentTypes = new string[] { - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - }; - - // to determine the Accept header - string[] _accepts = new string[] { - "application/xml", - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter - - // authentication (api_key) required - if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key"))) - { - localVarRequestOptions.HeaderParameters.Add("api_key", this.Configuration.GetApiKeyWithPrefix("api_key")); - } - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync("/pet/{petId}", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("GetPetById", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Update an existing pet - /// - /// Thrown when fails to make API call - /// Pet object that needs to be added to the store - /// - public void UpdatePet(Pet pet) - { - UpdatePetResponse(pet); - } - - /// - /// Update an existing pet - /// - /// Thrown when fails to make API call - /// Pet object that needs to be added to the store - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse UpdatePetResponse(Pet pet) + /// Task of Pet + public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'pet' is set - if (pet == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'pet' when calling PetApi->UpdatePet"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json", - "application/xml" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = pet; - - // authentication (http_signature_test) required - if (this.Configuration.HttpSigningConfiguration != null) - { - var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "PUT", "/pet", localVarRequestOptions); - foreach (var headerItem in HttpSigningHeaders) - { - if (localVarRequestOptions.HeaderParameters.ContainsKey(headerItem.Key)) - { - localVarRequestOptions.HeaderParameters[headerItem.Key] = new List() { headerItem.Value }; - } - else - { - localVarRequestOptions.HeaderParameters.Add(headerItem.Key, headerItem.Value); - } - } - } - // authentication (petstore_auth) required - // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - - // make the HTTP request - var localVarResponse = this.Client.Put("/pet", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("UpdatePet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse result = await GetPetByIdWithHttpInfoAsync(petId, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// - /// Update an existing pet + /// Find pet by ID Returns a single pet /// /// Thrown when fails to make API call - /// Pet object that needs to be added to the store + /// ID of pet to return /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task UpdatePetAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null) - { - await UpdatePetResponseAsync(pet, cancellationToken).ConfigureAwait(false); - } - - private System.Threading.Tasks.ValueTask ValidateUpdatePetRequestAsync(Pet pet, System.Threading.CancellationToken? cancellationToken) + /// Task of Pet + public async System.Threading.Tasks.Task GetPetByIdOrDefaultAsync(long petId, System.Threading.CancellationToken? cancellationToken = null) { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await GetPetByIdWithHttpInfoAsync(petId, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// - /// Update an existing pet + /// Find pet by ID Returns a single pet /// /// Thrown when fails to make API call - /// Pet object that needs to be added to the store + /// ID of pet to return /// Cancellation Token to cancel the request. - /// Task of ApiResponse - public async System.Threading.Tasks.Task> UpdatePetResponseAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null) + /// Task of ApiResponse (Pet) + public async System.Threading.Tasks.Task> GetPetByIdWithHttpInfoAsync(long petId, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'pet' is set - if (pet == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'pet' when calling PetApi->UpdatePet"); - await ValidateUpdatePetRequestAsync(pet, cancellationToken); + await ValidateGetPetByIdRequestAsync(petId, cancellationToken).ConfigureAwait(false); - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); + string path = "/pet/{petId}"; + path = path.Replace("{petId}", Uri.EscapeDataString(petId)); - string path = "/pet"; - path = $"{path}?"; - + path = $"{path}?"; + - if (path.EndsWith("&")) - path = path[..^1]; + if (path.EndsWith("&")) + path = path[..^1]; - if (path.EndsWith("?")) - path = path[..^1]; + if (path.EndsWith("?")) + path = path[..^1]; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); - string[] contentTypes = new string[] { - "application/json", - "application/xml" - }; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + // authentication (api_key) required + //isKeyInHeader + string? token = GetTokenAsync != null + ? await GetTokenAsync().ConfigureAwait(false) + : null; + if (token != null) + request.Headers.Add("authorization", $"Bearer {token}"); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + string[] contentTypes = new string[] { + }; - ApiResponse apiResponse = new(responseMessage, responseContent); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - return apiResponse; - } + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - string[] _contentTypes = new string[] { - "application/json", - "application/xml" - }; + ApiResponse apiResponse = new(responseMessage, responseContent); - // to determine the Accept header - string[] _accepts = new string[] { - }; + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + + return apiResponse; + } + + /// + /// Validate the input before sending the request + /// + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetRequestAsync(Pet pet, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + + + + /// + /// Update an existing pet + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task> UpdatePetWithHttpInfoAsync(Pet pet, System.Threading.CancellationToken? cancellationToken = null) + { + if (pet == null) + throw new ArgumentNullException(nameof(pet)); + + await ValidateUpdatePetRequestAsync(pet, cancellationToken).ConfigureAwait(false); + + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + + string path = "/pet"; + + + path = $"{path}?"; + - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (path.EndsWith("&")) + path = path[..^1]; - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + if (path.EndsWith("?")) + path = path[..^1]; - localVarRequestOptions.Data = pet; + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + + + + // todo localVarRequestOptions.Data = pet; // authentication (http_signature_test) required + //todo + /* if (this.Configuration.HttpSigningConfiguration != null) { var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "PUT", "/pet", localVarRequestOptions); @@ -1746,113 +895,47 @@ private System.Threading.Tasks.ValueTask ValidateUpdatePetRequestAsync(Pet pet, } } } + */ // authentication (petstore_auth) required // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PutAsync("/pet", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("UpdatePet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Updates a pet in the store with form data - /// - /// Thrown when fails to make API call - /// ID of pet that needs to be updated - /// Updated name of the pet (optional) - /// Updated status of the pet (optional) - /// - public void UpdatePetWithForm(long petId, string name = default(string), string status = default(string)) - { - UpdatePetWithFormResponse(petId, name, status); - } - - /// - /// Updates a pet in the store with form data - /// - /// Thrown when fails to make API call - /// ID of pet that needs to be updated - /// Updated name of the pet (optional) - /// Updated status of the pet (optional) - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse UpdatePetWithFormResponse(long petId, string name = default(string), string status = default(string)) - { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + //todo if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - String[] _contentTypes = new String[] { - "application/x-www-form-urlencoded" - }; + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); - // to determine the Accept header - String[] _accepts = new String[] { + string[] contentTypes = new string[] { + "application/json", + "application/xml" }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter - if (name != null) - { - localVarRequestOptions.FormParameters.Add("name", Org.OpenAPITools.Client.ClientUtils.ParameterToString(name)); // form parameter - } - if (status != null) - { - localVarRequestOptions.FormParameters.Add("status", Org.OpenAPITools.Client.ClientUtils.ParameterToString(status)); // form parameter - } + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - // authentication (petstore_auth) required - // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - var localVarResponse = this.Client.Post("/pet/{petId}", localVarRequestOptions, this.Configuration); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("UpdatePetWithForm", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// Updates a pet in the store with form data + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// ID of pet that needs to be updated /// Updated name of the pet (optional) /// Updated status of the pet (optional) /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task UpdatePetWithFormAsync(long petId, string??? name = null, string??? status = null, System.Threading.CancellationToken? cancellationToken = null) - { - await UpdatePetWithFormResponseAsync(petId, name, status, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetWithFormRequestAsync(long petId, string??? name, string??? status, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateUpdatePetWithFormRequestAsync(long petId, string??? name, string??? status, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// Updates a pet in the store with form data @@ -1863,114 +946,76 @@ private System.Threading.Tasks.ValueTask ValidateUpdatePetWithFormRequestAsync(l /// Updated status of the pet (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> UpdatePetWithFormResponseAsync(long petId, string??? name = null, string??? status = null, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> UpdatePetWithFormWithHttpInfoAsync(long petId, string??? name = null, string??? status = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateUpdatePetWithFormRequestAsync(petId, name, status, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/pet/{petId}"; - path = path.Replace("{petId}", Uri.EscapeDataString(petId)); - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + await ValidateUpdatePetWithFormRequestAsync(petId, name, status, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); + string path = "/pet/{petId}"; + path = path.Replace("{petId}", Uri.EscapeDataString(petId)); - string[] contentTypes = new string[] { - "application/x-www-form-urlencoded" - }; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + path = $"{path}?"; + - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - "application/x-www-form-urlencoded" - }; + if (path.EndsWith("&")) + path = path[..^1]; - // to determine the Accept header - string[] _accepts = new string[] { - }; + if (path.EndsWith("?")) + path = path[..^1]; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter if (name != null) { - localVarRequestOptions.FormParameters.Add("name", Org.OpenAPITools.Client.ClientUtils.ParameterToString(name)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("name", Org.OpenAPITools.Client.ClientUtils.ParameterToString(name)); // form parameter } if (status != null) { - localVarRequestOptions.FormParameters.Add("status", Org.OpenAPITools.Client.ClientUtils.ParameterToString(status)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("status", Org.OpenAPITools.Client.ClientUtils.ParameterToString(status)); // form parameter } + // authentication (petstore_auth) required // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } + //todo if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - // make the HTTP request + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); - var localVarResponse = await this.AsynchronousClient.PostAsync("/pet/{petId}", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("UpdatePetWithForm", localVarResponse); - if (_exception != null) throw _exception; - } + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + + + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - return localVarResponse; + ApiResponse apiResponse = new(responseMessage, responseContent); + + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + + return apiResponse; } /// - /// uploads an image + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// ID of pet to update /// Additional data to pass to server (optional) /// file to upload (optional) - /// ApiResponse - public ApiResponse UploadFile(long petId, string additionalMetadata = default(string), System.IO.Stream file = default(System.IO.Stream)) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = UploadFileResponse(petId, additionalMetadata, file); - return localVarResponse.Data; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateUploadFileRequestAsync(long petId, string??? additionalMetadata, System.IO.Stream??? file, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// uploads an image @@ -1979,53 +1024,12 @@ private System.Threading.Tasks.ValueTask ValidateUpdatePetWithFormRequestAsync(l /// ID of pet to update /// Additional data to pass to server (optional) /// file to upload (optional) - /// ApiResponse of ApiResponse - public Org.OpenAPITools.Client.ApiResponse UploadFileResponse(long petId, string additionalMetadata = default(string), System.IO.Stream file = default(System.IO.Stream)) + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task UploadFileAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "multipart/form-data" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter - if (additionalMetadata != null) - { - localVarRequestOptions.FormParameters.Add("additionalMetadata", Org.OpenAPITools.Client.ClientUtils.ParameterToString(additionalMetadata)); // form parameter - } - if (file != null) - { - localVarRequestOptions.FileParameters.Add("file", file); - } - - // authentication (petstore_auth) required - // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - - // make the HTTP request - var localVarResponse = this.Client.Post("/pet/{petId}/uploadImage", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("UploadFile", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse result = await UploadFileWithHttpInfoAsync(petId, additionalMetadata, file, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -2037,17 +1041,14 @@ private System.Threading.Tasks.ValueTask ValidateUpdatePetWithFormRequestAsync(l /// file to upload (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task UploadFileAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await UploadFileResponseAsync(petId, additionalMetadata, file, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateUploadFileRequestAsync(long petId, string??? additionalMetadata, System.IO.Stream??? file, System.Threading.CancellationToken? cancellationToken) + public async System.Threading.Tasks.Task UploadFileOrDefaultAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null) { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await UploadFileWithHttpInfoAsync(petId, additionalMetadata, file, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// uploads an image @@ -2058,116 +1059,77 @@ private System.Threading.Tasks.ValueTask ValidateUploadFileRequestAsync(long pet /// file to upload (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse (ApiResponse) - public async System.Threading.Tasks.Task> UploadFileResponseAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> UploadFileWithHttpInfoAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateUploadFileRequestAsync(petId, additionalMetadata, file, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/pet/{petId}/uploadImage"; - path = path.Replace("{petId}", Uri.EscapeDataString(petId)); - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("multipart/form-data")); - - string[] contentTypes = new string[] { - "multipart/form-data" - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + await ValidateUploadFileRequestAsync(petId, additionalMetadata, file, cancellationToken).ConfigureAwait(false); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); + string path = "/pet/{petId}/uploadImage"; + path = path.Replace("{petId}", Uri.EscapeDataString(petId)); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - ApiResponse apiResponse = new(responseMessage, responseContent); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); + path = $"{path}?"; + - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - "multipart/form-data" - }; + if (path.EndsWith("&")) + path = path[..^1]; - // to determine the Accept header - string[] _accepts = new string[] { - "application/json" - }; + if (path.EndsWith("?")) + path = path[..^1]; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter if (additionalMetadata != null) { - localVarRequestOptions.FormParameters.Add("additionalMetadata", Org.OpenAPITools.Client.ClientUtils.ParameterToString(additionalMetadata)); // form parameter + // todo localVarRequestOptions.FormParameters.Add("additionalMetadata", Org.OpenAPITools.Client.ClientUtils.ParameterToString(additionalMetadata)); // form parameter } if (file != null) { - localVarRequestOptions.FileParameters.Add("file", file); + // todo localVarRequestOptions.FileParameters.Add("file", file); } + // authentication (petstore_auth) required // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } + //todo if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - // make the HTTP request + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("multipart/form-data")); - var localVarResponse = await this.AsynchronousClient.PostAsync("/pet/{petId}/uploadImage", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string[] contentTypes = new string[] { + "multipart/form-data" + }; - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("UploadFile", localVarResponse); - if (_exception != null) throw _exception; - } + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - return localVarResponse; + ApiResponse apiResponse = new(responseMessage, responseContent); + + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + + return apiResponse; } /// - /// uploads an image (required) + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// ID of pet to update /// file to upload /// Additional data to pass to server (optional) - /// ApiResponse - public ApiResponse UploadFileWithRequiredFile(long petId, System.IO.Stream requiredFile, string additionalMetadata = default(string)) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = UploadFileWithRequiredFileResponse(petId, requiredFile, additionalMetadata); - return localVarResponse.Data; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateUploadFileWithRequiredFileRequestAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// uploads an image (required) @@ -2176,54 +1138,12 @@ private System.Threading.Tasks.ValueTask ValidateUploadFileRequestAsync(long pet /// ID of pet to update /// file to upload /// Additional data to pass to server (optional) - /// ApiResponse of ApiResponse - public Org.OpenAPITools.Client.ApiResponse UploadFileWithRequiredFileResponse(long petId, System.IO.Stream requiredFile, string additionalMetadata = default(string)) + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata = null, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'requiredFile' is set - if (requiredFile == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'requiredFile' when calling PetApi->UploadFileWithRequiredFile"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "multipart/form-data" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter - if (additionalMetadata != null) - { - localVarRequestOptions.FormParameters.Add("additionalMetadata", Org.OpenAPITools.Client.ClientUtils.ParameterToString(additionalMetadata)); // form parameter - } - localVarRequestOptions.FileParameters.Add("requiredFile", requiredFile); - - // authentication (petstore_auth) required - // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } - - // make the HTTP request - var localVarResponse = this.Client.Post("/fake/{petId}/uploadImageWithRequiredFile", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("UploadFileWithRequiredFile", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse result = await UploadFileWithRequiredFileWithHttpInfoAsync(petId, requiredFile, additionalMetadata, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -2235,17 +1155,14 @@ private System.Threading.Tasks.ValueTask ValidateUploadFileRequestAsync(long pet /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata = null, System.Threading.CancellationToken? cancellationToken = null) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await UploadFileWithRequiredFileResponseAsync(petId, requiredFile, additionalMetadata, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateUploadFileWithRequiredFileRequestAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata, System.Threading.CancellationToken? cancellationToken) + public async System.Threading.Tasks.Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata = null, System.Threading.CancellationToken? cancellationToken = null) { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await UploadFileWithRequiredFileWithHttpInfoAsync(petId, requiredFile, additionalMetadata, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// uploads an image (required) @@ -2256,102 +1173,65 @@ private System.Threading.Tasks.ValueTask ValidateUploadFileWithRequiredFileReque /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// Task of ApiResponse (ApiResponse) - public async System.Threading.Tasks.Task> UploadFileWithRequiredFileResponseAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata = null, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> UploadFileWithRequiredFileWithHttpInfoAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata = null, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'requiredFile' is set if (requiredFile == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'requiredFile' when calling PetApi->UploadFileWithRequiredFile"); - - await ValidateUploadFileWithRequiredFileRequestAsync(petId, requiredFile, additionalMetadata, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/fake/{petId}/uploadImageWithRequiredFile"; - path = path.Replace("{petId}", Uri.EscapeDataString(petId)); + throw new ArgumentNullException(nameof(requiredFile)); - path = $"{path}?"; - + await ValidateUploadFileWithRequiredFileRequestAsync(petId, requiredFile, additionalMetadata, cancellationToken).ConfigureAwait(false); - if (path.EndsWith("&")) - path = path[..^1]; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - if (path.EndsWith("?")) - path = path[..^1]; + string path = "/fake/{petId}/uploadImageWithRequiredFile"; + path = path.Replace("{petId}", Uri.EscapeDataString(petId)); - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("multipart/form-data")); + path = $"{path}?"; + - string[] contentTypes = new string[] { - "multipart/form-data" - }; + if (path.EndsWith("&")) + path = path[..^1]; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + if (path.EndsWith("?")) + path = path[..^1]; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); + if (additionalMetadata != null) + { + // todo localVarRequestOptions.FormParameters.Add("additionalMetadata", Org.OpenAPITools.Client.ClientUtils.ParameterToString(additionalMetadata)); // form parameter + } + // todo localVarRequestOptions.FileParameters.Add("requiredFile", requiredFile); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - return apiResponse; - } + // authentication (petstore_auth) required + // oauth required + //todo if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("multipart/form-data")); - string[] _contentTypes = new string[] { + string[] contentTypes = new string[] { "multipart/form-data" }; - // to determine the Accept header - string[] _accepts = new string[] { - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter - if (additionalMetadata != null) - { - localVarRequestOptions.FormParameters.Add("additionalMetadata", Org.OpenAPITools.Client.ClientUtils.ParameterToString(additionalMetadata)); // form parameter - } - localVarRequestOptions.FileParameters.Add("requiredFile", requiredFile); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - // authentication (petstore_auth) required - // oauth required - if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) - { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - } + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - // make the HTTP request + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - var localVarResponse = await this.AsynchronousClient.PostAsync("/fake/{petId}/uploadImageWithRequiredFile", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("UploadFileWithRequiredFile", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs index 8a59305ca6fd..a182683c6885 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs @@ -19,13 +19,11 @@ namespace Org.OpenAPITools.Api { - /// /// Represents a collection of functions to interact with the API endpoints /// - public interface IStoreApiSync : IApiAccessor + public interface IStoreApi { - #region Synchronous Operations /// /// Delete purchase order by ID /// @@ -34,9 +32,10 @@ public interface IStoreApiSync : IApiAccessor /// /// Thrown when fails to make API call /// ID of the order that needs to be deleted - /// - void DeleteOrder(string orderId); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> DeleteOrderWithHttpInfoAsync(string orderId, System.Threading.CancellationToken? cancellationToken = null); + /// /// Delete purchase order by ID /// @@ -45,8 +44,10 @@ public interface IStoreApiSync : IApiAccessor /// /// Thrown when fails to make API call /// ID of the order that needs to be deleted - /// ApiResponse of Object(void) - ApiResponse DeleteOrderResponse(string orderId); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task DeleteOrderAsync(string orderId, System.Threading.CancellationToken? cancellationToken = null); + /// /// Returns pet inventories by status /// @@ -54,9 +55,10 @@ public interface IStoreApiSync : IApiAccessor /// Returns a map of status codes to quantities /// /// Thrown when fails to make API call - /// Dictionary<string, int> - Dictionary GetInventory(); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (Dictionary<string, int>) + System.Threading.Tasks.Task>> GetInventoryWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null); + /// /// Returns pet inventories by status /// @@ -64,19 +66,19 @@ public interface IStoreApiSync : IApiAccessor /// Returns a map of status codes to quantities /// /// Thrown when fails to make API call - /// ApiResponse of Dictionary<string, int> - ApiResponse> GetInventoryResponse(); + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (Dictionary<string, int>) + System.Threading.Tasks.Task> GetInventoryAsync(System.Threading.CancellationToken? cancellationToken = null); + /// - /// Find purchase order by ID + /// Returns pet inventories by status /// /// - /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// Returns a map of status codes to quantities /// - /// Thrown when fails to make API call - /// ID of pet that needs to be fetched - /// Order - Order GetOrderById(long orderId); - + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (Dictionary<string, int>?) + System.Threading.Tasks.Task?> GetInventoryOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null); /// /// Find purchase order by ID /// @@ -85,102 +87,44 @@ public interface IStoreApiSync : IApiAccessor /// /// Thrown when fails to make API call /// ID of pet that needs to be fetched - /// ApiResponse of Order - ApiResponse GetOrderByIdResponse(long orderId); - /// - /// Place an order for a pet - /// - /// Thrown when fails to make API call - /// order placed for purchasing the pet - /// Order - Order PlaceOrder(Order order); - - /// - /// Place an order for a pet - /// - /// - /// - /// - /// Thrown when fails to make API call - /// order placed for purchasing the pet - /// ApiResponse of Order - ApiResponse PlaceOrderResponse(Order order); - #endregion Synchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IStoreApiAsync : IApiAccessor - { - #region Asynchronous Operations - /// - /// Delete purchase order by ID - /// - /// - /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// - /// Thrown when fails to make API call - /// ID of the order that needs to be deleted - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task DeleteOrderAsync(string orderId, System.Threading.CancellationToken? cancellationToken = null); - - /// - /// Delete purchase order by ID - /// - /// - /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// - /// Thrown when fails to make API call - /// ID of the order that needs to be deleted /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> DeleteOrderResponseAsync(string orderId, System.Threading.CancellationToken? cancellationToken = null); - /// - /// Returns pet inventories by status - /// - /// - /// Returns a map of status codes to quantities - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of Dictionary<string, int> - System.Threading.Tasks.Task> GetInventoryAsync(System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse (Order) + System.Threading.Tasks.Task> GetOrderByIdWithHttpInfoAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null); + /// - /// Returns pet inventories by status + /// Find purchase order by ID /// /// - /// Returns a map of status codes to quantities + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions /// /// Thrown when fails to make API call + /// ID of pet that needs to be fetched /// Cancellation Token to cancel the request. - /// Task of ApiResponse (Dictionary<string, int>) - System.Threading.Tasks.Task>> GetInventoryResponseAsync(System.Threading.CancellationToken? cancellationToken = null); + /// Task of ApiResponse (Order) + System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null); + /// /// Find purchase order by ID /// /// /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions /// - /// Thrown when fails to make API call /// ID of pet that needs to be fetched /// Cancellation Token to cancel the request. - /// Task of Order - System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse (Order?) + System.Threading.Tasks.Task GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null); /// - /// Find purchase order by ID + /// Place an order for a pet /// /// - /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// /// /// Thrown when fails to make API call - /// ID of pet that needs to be fetched + /// order placed for purchasing the pet /// Cancellation Token to cancel the request. /// Task of ApiResponse (Order) - System.Threading.Tasks.Task> GetOrderByIdResponseAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task> PlaceOrderWithHttpInfoAsync(Order order, System.Threading.CancellationToken? cancellationToken = null); + /// /// Place an order for a pet /// @@ -190,29 +134,19 @@ public interface IStoreApiAsync : IApiAccessor /// Thrown when fails to make API call /// order placed for purchasing the pet /// Cancellation Token to cancel the request. - /// Task of Order + /// Task of ApiResponse (Order) System.Threading.Tasks.Task PlaceOrderAsync(Order order, System.Threading.CancellationToken? cancellationToken = null); - + /// /// Place an order for a pet /// /// /// /// - /// Thrown when fails to make API call /// order placed for purchasing the pet /// Cancellation Token to cancel the request. - /// Task of ApiResponse (Order) - System.Threading.Tasks.Task> PlaceOrderResponseAsync(Order order, System.Threading.CancellationToken? cancellationToken = null); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IStoreApi : IStoreApiSync, IStoreApiAsync - { - + /// Task of ApiResponse (Order?) + System.Threading.Tasks.Task PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken? cancellationToken = null); } /// @@ -220,193 +154,32 @@ public interface IStoreApi : IStoreApiSync, IStoreApiAsync /// public partial class StoreApi : IStoreApi { - private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null; private readonly System.Net.Http.HttpClient _httpClient; - private readonly Newtonsoft.Json.JsonConverter[] _jsonConverters; /// /// Initializes a new instance of the class. /// /// - public StoreApi() : this((string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - public StoreApi(System.Net.Http.HttpClient httpClient, Newtonsoft.Json.JsonConverter[] jsonConverters) : this((string)null) + public StoreApi(System.Net.Http.HttpClient httpClient) { _httpClient = httpClient; - - _jsonConverters = jsonConverters; - } - - /// - /// Initializes a new instance of the class. - /// - /// - public StoreApi(String basePath) - { - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public StoreApi(Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public StoreApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// The client for accessing this underlying API asynchronously. - /// - public Org.OpenAPITools.Client.IAsynchronousClient AsynchronousClient { get; set; } - - /// - /// The client for accessing this underlying API synchronously. - /// - public Org.OpenAPITools.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public Org.OpenAPITools.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public Org.OpenAPITools.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } - - /// - /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// - /// Thrown when fails to make API call - /// ID of the order that needs to be deleted - /// - public void DeleteOrder(string orderId) - { - DeleteOrderResponse(orderId); } /// - /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// Returns the token to be used in the api query /// - /// Thrown when fails to make API call - /// ID of the order that needs to be deleted - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse DeleteOrderResponse(string orderId) - { - // verify the required parameter 'orderId' is set - if (orderId == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'orderId' when calling StoreApi->DeleteOrder"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("order_id", Org.OpenAPITools.Client.ClientUtils.ParameterToString(orderId)); // path parameter - + public Func>? GetTokenAsync { get; set; } - // make the HTTP request - var localVarResponse = this.Client.Delete("/store/order/{order_id}", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("DeleteOrder", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } /// - /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// ID of the order that needs to be deleted /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task DeleteOrderAsync(string orderId, System.Threading.CancellationToken? cancellationToken = null) - { - await DeleteOrderResponseAsync(orderId, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateDeleteOrderRequestAsync(string orderId, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateDeleteOrderRequestAsync(string orderId, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -415,138 +188,72 @@ private System.Threading.Tasks.ValueTask ValidateDeleteOrderRequestAsync(string /// ID of the order that needs to be deleted /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> DeleteOrderResponseAsync(string orderId, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> DeleteOrderWithHttpInfoAsync(string orderId, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'orderId' is set if (orderId == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'orderId' when calling StoreApi->DeleteOrder"); + throw new ArgumentNullException(nameof(orderId)); - await ValidateDeleteOrderRequestAsync(orderId, cancellationToken); + await ValidateDeleteOrderRequestAsync(orderId, cancellationToken).ConfigureAwait(false); - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); + string path = "/store/order/{order_id}"; + path = path.Replace("{order_id}", Uri.EscapeDataString(orderId)); - string path = "/store/order/{order_id}"; - path = path.Replace("{order_id}", Uri.EscapeDataString(orderId)); - path = $"{path}?"; - + path = $"{path}?"; + - if (path.EndsWith("&")) - path = path[..^1]; + if (path.EndsWith("&")) + path = path[..^1]; - if (path.EndsWith("?")) - path = path[..^1]; + if (path.EndsWith("?")) + path = path[..^1]; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - string[] contentTypes = new string[] { - }; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - }; - - // to determine the Accept header - string[] _accepts = new string[] { + string[] contentTypes = new string[] { }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - localVarRequestOptions.PathParameters.Add("order_id", Org.OpenAPITools.Client.ClientUtils.ParameterToString(orderId)); // path parameter + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - // make the HTTP request + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - var localVarResponse = await this.AsynchronousClient.DeleteAsync("/store/order/{order_id}", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("DeleteOrder", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// Returns pet inventories by status Returns a map of status codes to quantities + /// Validate the input before sending the request /// - /// Thrown when fails to make API call - /// Dictionary<string, int> - public Dictionary GetInventory() - { - Org.OpenAPITools.Client.ApiResponse> localVarResponse = GetInventoryResponse(); - return localVarResponse.Data; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateGetInventoryRequestAsync(System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// Returns pet inventories by status Returns a map of status codes to quantities /// /// Thrown when fails to make API call - /// ApiResponse of Dictionary<string, int> - public Org.OpenAPITools.Client.ApiResponse> GetInventoryResponse() + /// Cancellation Token to cancel the request. + /// Task of Dictionary<string, int> + public async System.Threading.Tasks.Task> GetInventoryAsync(System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - // authentication (api_key) required - if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key"))) - { - localVarRequestOptions.HeaderParameters.Add("api_key", this.Configuration.GetApiKeyWithPrefix("api_key")); - } - - // make the HTTP request - var localVarResponse = this.Client.Get>("/store/inventory", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("GetInventory", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse> result = await GetInventoryWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -555,17 +262,14 @@ public Org.OpenAPITools.Client.ApiResponse> GetInventory /// Thrown when fails to make API call /// Cancellation Token to cancel the request. /// Task of Dictionary<string, int> - public async System.Threading.Tasks.Task> GetInventoryAsync(System.Threading.CancellationToken? cancellationToken = null) - { - Org.OpenAPITools.Client.ApiResponse> localVarResponse = await GetInventoryResponseAsync(cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateGetInventoryRequestAsync(System.Threading.CancellationToken? cancellationToken) + public async System.Threading.Tasks.Task?> GetInventoryOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null) { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse> result = await GetInventoryWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// Returns pet inventories by status Returns a map of status codes to quantities @@ -573,139 +277,79 @@ private System.Threading.Tasks.ValueTask ValidateGetInventoryRequestAsync(System /// Thrown when fails to make API call /// Cancellation Token to cancel the request. /// Task of ApiResponse (Dictionary<string, int>) - public async System.Threading.Tasks.Task>> GetInventoryResponseAsync(System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task>> GetInventoryWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { - await ValidateGetInventoryRequestAsync(cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - + await ValidateGetInventoryRequestAsync(cancellationToken).ConfigureAwait(false); - string path = "/store/inventory"; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - path = $"{path}?"; - + string path = "/store/inventory"; - if (path.EndsWith("&")) - path = path[..^1]; - if (path.EndsWith("?")) - path = path[..^1]; + path = $"{path}?"; + - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + if (path.EndsWith("&")) + path = path[..^1]; + if (path.EndsWith("?")) + path = path[..^1]; + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - string[] contentTypes = new string[] { - }; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse> apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException>(apiResponse); + // authentication (api_key) required + //isKeyInHeader + string? token = GetTokenAsync != null + ? await GetTokenAsync().ConfigureAwait(false) + : null; - return apiResponse; - } + if (token != null) + request.Headers.Add("authorization", $"Bearer {token}"); - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - string[] _contentTypes = new string[] { + string[] contentTypes = new string[] { }; - // to determine the Accept header - string[] _accepts = new string[] { - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - // authentication (api_key) required - if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key"))) - { - localVarRequestOptions.HeaderParameters.Add("api_key", this.Configuration.GetApiKeyWithPrefix("api_key")); - } - - // make the HTTP request + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - var localVarResponse = await this.AsynchronousClient.GetAsync>("/store/inventory", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + ApiResponse> apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("GetInventory", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// ID of pet that needs to be fetched - /// Order - public Order GetOrderById(long orderId) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = GetOrderByIdResponse(orderId); - return localVarResponse.Data; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateGetOrderByIdRequestAsync(long orderId, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions /// /// Thrown when fails to make API call /// ID of pet that needs to be fetched - /// ApiResponse of Order - public Org.OpenAPITools.Client.ApiResponse GetOrderByIdResponse(long orderId) + /// Cancellation Token to cancel the request. + /// Task of Order + public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/xml", - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("order_id", Org.OpenAPITools.Client.ClientUtils.ParameterToString(orderId)); // path parameter - - - // make the HTTP request - var localVarResponse = this.Client.Get("/store/order/{order_id}", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("GetOrderById", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse result = await GetOrderByIdWithHttpInfoAsync(orderId, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -715,17 +359,14 @@ public Org.OpenAPITools.Client.ApiResponse GetOrderByIdResponse(long orde /// ID of pet that needs to be fetched /// Cancellation Token to cancel the request. /// Task of Order - public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetOrderByIdResponseAsync(orderId, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateGetOrderByIdRequestAsync(long orderId, System.Threading.CancellationToken? cancellationToken) + public async System.Threading.Tasks.Task GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null) { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await GetOrderByIdWithHttpInfoAsync(orderId, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -734,143 +375,74 @@ private System.Threading.Tasks.ValueTask ValidateGetOrderByIdRequestAsync(long o /// ID of pet that needs to be fetched /// Cancellation Token to cancel the request. /// Task of ApiResponse (Order) - public async System.Threading.Tasks.Task> GetOrderByIdResponseAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> GetOrderByIdWithHttpInfoAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateGetOrderByIdRequestAsync(orderId, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/store/order/{order_id}"; - path = path.Replace("{order_id}", Uri.EscapeDataString(orderId)); + await ValidateGetOrderByIdRequestAsync(orderId, cancellationToken).ConfigureAwait(false); - path = $"{path}?"; - + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - if (path.EndsWith("&")) - path = path[..^1]; + string path = "/store/order/{order_id}"; + path = path.Replace("{order_id}", Uri.EscapeDataString(orderId)); - if (path.EndsWith("?")) - path = path[..^1]; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + path = $"{path}?"; + + if (path.EndsWith("&")) + path = path[..^1]; - string[] contentTypes = new string[] { - }; + if (path.EndsWith("?")) + path = path[..^1]; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - ApiResponse apiResponse = new(responseMessage, responseContent); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - }; - - // to determine the Accept header - string[] _accepts = new string[] { - "application/xml", - "application/json" + string[] contentTypes = new string[] { }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - localVarRequestOptions.PathParameters.Add("order_id", Org.OpenAPITools.Client.ClientUtils.ParameterToString(orderId)); // path parameter + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request + ApiResponse apiResponse = new(responseMessage, responseContent); - var localVarResponse = await this.AsynchronousClient.GetAsync("/store/order/{order_id}", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("GetOrderById", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + return apiResponse; } /// - /// Place an order for a pet + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// order placed for purchasing the pet - /// Order - public Order PlaceOrder(Order order) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = PlaceOrderResponse(order); - return localVarResponse.Data; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidatePlaceOrderRequestAsync(Order order, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// Place an order for a pet /// /// Thrown when fails to make API call /// order placed for purchasing the pet - /// ApiResponse of Order - public Org.OpenAPITools.Client.ApiResponse PlaceOrderResponse(Order order) + /// Cancellation Token to cancel the request. + /// Task of Order + public async System.Threading.Tasks.Task PlaceOrderAsync(Order order, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'order' is set - if (order == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'order' when calling StoreApi->PlaceOrder"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/xml", - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = order; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/store/order", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("PlaceOrder", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse result = await PlaceOrderWithHttpInfoAsync(order, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -880,17 +452,14 @@ public Org.OpenAPITools.Client.ApiResponse PlaceOrderResponse(Order order /// order placed for purchasing the pet /// Cancellation Token to cancel the request. /// Task of Order - public async System.Threading.Tasks.Task PlaceOrderAsync(Order order, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken? cancellationToken = null) { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await PlaceOrderResponseAsync(order, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidatePlaceOrderRequestAsync(Order order, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await PlaceOrderWithHttpInfoAsync(order, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// Place an order for a pet @@ -899,92 +468,56 @@ private System.Threading.Tasks.ValueTask ValidatePlaceOrderRequestAsync(Order or /// order placed for purchasing the pet /// Cancellation Token to cancel the request. /// Task of ApiResponse (Order) - public async System.Threading.Tasks.Task> PlaceOrderResponseAsync(Order order, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> PlaceOrderWithHttpInfoAsync(Order order, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'order' is set if (order == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'order' when calling StoreApi->PlaceOrder"); - - await ValidatePlaceOrderRequestAsync(order, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); + throw new ArgumentNullException(nameof(order)); + await ValidatePlaceOrderRequestAsync(order, cancellationToken).ConfigureAwait(false); - string path = "/store/order"; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - path = $"{path}?"; - + string path = "/store/order"; - if (path.EndsWith("&")) - path = path[..^1]; - if (path.EndsWith("?")) - path = path[..^1]; + path = $"{path}?"; + - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + if (path.EndsWith("&")) + path = path[..^1]; + if (path.EndsWith("?")) + path = path[..^1]; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - string[] contentTypes = new string[] { - "application/json" - }; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + // todo localVarRequestOptions.Data = order; - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { + string[] contentTypes = new string[] { "application/json" }; - // to determine the Accept header - string[] _accepts = new string[] { - "application/xml", - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - localVarRequestOptions.Data = order; + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request + ApiResponse apiResponse = new(responseMessage, responseContent); - var localVarResponse = await this.AsynchronousClient.PostAsync("/store/order", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("PlaceOrder", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + return apiResponse; } - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs index 56f43b6a4f52..ba76f373a2e2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs @@ -19,177 +19,11 @@ namespace Org.OpenAPITools.Api { - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IUserApiSync : IApiAccessor - { - #region Synchronous Operations - /// - /// Create user - /// - /// - /// This can only be done by the logged in user. - /// - /// Thrown when fails to make API call - /// Created user object - /// - void CreateUser(User user); - - /// - /// Create user - /// - /// - /// This can only be done by the logged in user. - /// - /// Thrown when fails to make API call - /// Created user object - /// ApiResponse of Object(void) - ApiResponse CreateUserResponse(User user); - /// - /// Creates list of users with given input array - /// - /// Thrown when fails to make API call - /// List of user object - /// - void CreateUsersWithArrayInput(List user); - - /// - /// Creates list of users with given input array - /// - /// - /// - /// - /// Thrown when fails to make API call - /// List of user object - /// ApiResponse of Object(void) - ApiResponse CreateUsersWithArrayInputResponse(List user); - /// - /// Creates list of users with given input array - /// - /// Thrown when fails to make API call - /// List of user object - /// - void CreateUsersWithListInput(List user); - - /// - /// Creates list of users with given input array - /// - /// - /// - /// - /// Thrown when fails to make API call - /// List of user object - /// ApiResponse of Object(void) - ApiResponse CreateUsersWithListInputResponse(List user); - /// - /// Delete user - /// - /// - /// This can only be done by the logged in user. - /// - /// Thrown when fails to make API call - /// The name that needs to be deleted - /// - void DeleteUser(string username); - - /// - /// Delete user - /// - /// - /// This can only be done by the logged in user. - /// - /// Thrown when fails to make API call - /// The name that needs to be deleted - /// ApiResponse of Object(void) - ApiResponse DeleteUserResponse(string username); - /// - /// Get user by user name - /// - /// Thrown when fails to make API call - /// The name that needs to be fetched. Use user1 for testing. - /// User - User GetUserByName(string username); - - /// - /// Get user by user name - /// - /// - /// - /// - /// Thrown when fails to make API call - /// The name that needs to be fetched. Use user1 for testing. - /// ApiResponse of User - ApiResponse GetUserByNameResponse(string username); - /// - /// Logs user into the system - /// - /// Thrown when fails to make API call - /// The user name for login - /// The password for login in clear text - /// string - string LoginUser(string username, string password); - - /// - /// Logs user into the system - /// - /// - /// - /// - /// Thrown when fails to make API call - /// The user name for login - /// The password for login in clear text - /// ApiResponse of string - ApiResponse LoginUserResponse(string username, string password); - /// - /// Logs out current logged in user session - /// - /// Thrown when fails to make API call - /// - void LogoutUser(); - - /// - /// Logs out current logged in user session - /// - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of Object(void) - ApiResponse LogoutUserResponse(); - /// - /// Updated user - /// - /// - /// This can only be done by the logged in user. - /// - /// Thrown when fails to make API call - /// name that need to be deleted - /// Updated user object - /// - void UpdateUser(string username, User user); - - /// - /// Updated user - /// - /// - /// This can only be done by the logged in user. - /// - /// Thrown when fails to make API call - /// name that need to be deleted - /// Updated user object - /// ApiResponse of Object(void) - ApiResponse UpdateUserResponse(string username, User user); - #endregion Synchronous Operations - } - /// /// Represents a collection of functions to interact with the API endpoints /// - public interface IUserApiAsync : IApiAccessor + public interface IUserApi { - #region Asynchronous Operations /// /// Create user /// @@ -199,9 +33,9 @@ public interface IUserApiAsync : IApiAccessor /// Thrown when fails to make API call /// Created user object /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task CreateUserAsync(User user, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse + System.Threading.Tasks.Task> CreateUserWithHttpInfoAsync(User user, System.Threading.CancellationToken? cancellationToken = null); + /// /// Create user /// @@ -212,7 +46,8 @@ public interface IUserApiAsync : IApiAccessor /// Created user object /// Cancellation Token to cancel the request. /// Task of ApiResponse - System.Threading.Tasks.Task> CreateUserResponseAsync(User user, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task CreateUserAsync(User user, System.Threading.CancellationToken? cancellationToken = null); + /// /// Creates list of users with given input array /// @@ -222,9 +57,9 @@ public interface IUserApiAsync : IApiAccessor /// Thrown when fails to make API call /// List of user object /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task CreateUsersWithArrayInputAsync(List user, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse + System.Threading.Tasks.Task> CreateUsersWithArrayInputWithHttpInfoAsync(List user, System.Threading.CancellationToken? cancellationToken = null); + /// /// Creates list of users with given input array /// @@ -235,7 +70,8 @@ public interface IUserApiAsync : IApiAccessor /// List of user object /// Cancellation Token to cancel the request. /// Task of ApiResponse - System.Threading.Tasks.Task> CreateUsersWithArrayInputResponseAsync(List user, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task CreateUsersWithArrayInputAsync(List user, System.Threading.CancellationToken? cancellationToken = null); + /// /// Creates list of users with given input array /// @@ -245,9 +81,9 @@ public interface IUserApiAsync : IApiAccessor /// Thrown when fails to make API call /// List of user object /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task CreateUsersWithListInputAsync(List user, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse + System.Threading.Tasks.Task> CreateUsersWithListInputWithHttpInfoAsync(List user, System.Threading.CancellationToken? cancellationToken = null); + /// /// Creates list of users with given input array /// @@ -258,7 +94,8 @@ public interface IUserApiAsync : IApiAccessor /// List of user object /// Cancellation Token to cancel the request. /// Task of ApiResponse - System.Threading.Tasks.Task> CreateUsersWithListInputResponseAsync(List user, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task CreateUsersWithListInputAsync(List user, System.Threading.CancellationToken? cancellationToken = null); + /// /// Delete user /// @@ -268,9 +105,9 @@ public interface IUserApiAsync : IApiAccessor /// Thrown when fails to make API call /// The name that needs to be deleted /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task DeleteUserAsync(string username, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse + System.Threading.Tasks.Task> DeleteUserWithHttpInfoAsync(string username, System.Threading.CancellationToken? cancellationToken = null); + /// /// Delete user /// @@ -281,7 +118,8 @@ public interface IUserApiAsync : IApiAccessor /// The name that needs to be deleted /// Cancellation Token to cancel the request. /// Task of ApiResponse - System.Threading.Tasks.Task> DeleteUserResponseAsync(string username, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task DeleteUserAsync(string username, System.Threading.CancellationToken? cancellationToken = null); + /// /// Get user by user name /// @@ -291,9 +129,9 @@ public interface IUserApiAsync : IApiAccessor /// Thrown when fails to make API call /// The name that needs to be fetched. Use user1 for testing. /// Cancellation Token to cancel the request. - /// Task of User - System.Threading.Tasks.Task GetUserByNameAsync(string username, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse (User) + System.Threading.Tasks.Task> GetUserByNameWithHttpInfoAsync(string username, System.Threading.CancellationToken? cancellationToken = null); + /// /// Get user by user name /// @@ -304,7 +142,18 @@ public interface IUserApiAsync : IApiAccessor /// The name that needs to be fetched. Use user1 for testing. /// Cancellation Token to cancel the request. /// Task of ApiResponse (User) - System.Threading.Tasks.Task> GetUserByNameResponseAsync(string username, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task GetUserByNameAsync(string username, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// Get user by user name + /// + /// + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (User?) + System.Threading.Tasks.Task GetUserByNameOrDefaultAsync(string username, System.Threading.CancellationToken? cancellationToken = null); /// /// Logs user into the system /// @@ -315,9 +164,9 @@ public interface IUserApiAsync : IApiAccessor /// The user name for login /// The password for login in clear text /// Cancellation Token to cancel the request. - /// Task of string - System.Threading.Tasks.Task LoginUserAsync(string username, string password, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse (string) + System.Threading.Tasks.Task> LoginUserWithHttpInfoAsync(string username, string password, System.Threading.CancellationToken? cancellationToken = null); + /// /// Logs user into the system /// @@ -329,7 +178,19 @@ public interface IUserApiAsync : IApiAccessor /// The password for login in clear text /// Cancellation Token to cancel the request. /// Task of ApiResponse (string) - System.Threading.Tasks.Task> LoginUserResponseAsync(string username, string password, System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task LoginUserAsync(string username, string password, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// Logs user into the system + /// + /// + /// + /// + /// The user name for login + /// The password for login in clear text + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (string?) + System.Threading.Tasks.Task LoginUserOrDefaultAsync(string username, string password, System.Threading.CancellationToken? cancellationToken = null); /// /// Logs out current logged in user session /// @@ -338,9 +199,9 @@ public interface IUserApiAsync : IApiAccessor /// /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task LogoutUserAsync(System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse + System.Threading.Tasks.Task> LogoutUserWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null); + /// /// Logs out current logged in user session /// @@ -350,7 +211,8 @@ public interface IUserApiAsync : IApiAccessor /// Thrown when fails to make API call /// Cancellation Token to cancel the request. /// Task of ApiResponse - System.Threading.Tasks.Task> LogoutUserResponseAsync(System.Threading.CancellationToken? cancellationToken = null); + System.Threading.Tasks.Task LogoutUserAsync(System.Threading.CancellationToken? cancellationToken = null); + /// /// Updated user /// @@ -361,9 +223,9 @@ public interface IUserApiAsync : IApiAccessor /// name that need to be deleted /// Updated user object /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task UpdateUserAsync(string username, User user, System.Threading.CancellationToken? cancellationToken = null); - + /// Task of ApiResponse + System.Threading.Tasks.Task> UpdateUserWithHttpInfoAsync(string username, User user, System.Threading.CancellationToken? cancellationToken = null); + /// /// Updated user /// @@ -375,16 +237,8 @@ public interface IUserApiAsync : IApiAccessor /// Updated user object /// Cancellation Token to cancel the request. /// Task of ApiResponse - System.Threading.Tasks.Task> UpdateUserResponseAsync(string username, User user, System.Threading.CancellationToken? cancellationToken = null); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IUserApi : IUserApiSync, IUserApiAsync - { - + System.Threading.Tasks.Task UpdateUserAsync(string username, User user, System.Threading.CancellationToken? cancellationToken = null); + } /// @@ -392,194 +246,32 @@ public interface IUserApi : IUserApiSync, IUserApiAsync /// public partial class UserApi : IUserApi { - private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null; private readonly System.Net.Http.HttpClient _httpClient; - private readonly Newtonsoft.Json.JsonConverter[] _jsonConverters; /// /// Initializes a new instance of the class. /// /// - public UserApi() : this((string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - public UserApi(System.Net.Http.HttpClient httpClient, Newtonsoft.Json.JsonConverter[] jsonConverters) : this((string)null) + public UserApi(System.Net.Http.HttpClient httpClient) { _httpClient = httpClient; - - _jsonConverters = jsonConverters; - } - - /// - /// Initializes a new instance of the class. - /// - /// - public UserApi(String basePath) - { - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public UserApi(Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public UserApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; } /// - /// The client for accessing this underlying API asynchronously. + /// Returns the token to be used in the api query /// - public Org.OpenAPITools.Client.IAsynchronousClient AsynchronousClient { get; set; } + public Func>? GetTokenAsync { get; set; } - /// - /// The client for accessing this underlying API synchronously. - /// - public Org.OpenAPITools.Client.ISynchronousClient Client { get; set; } /// - /// Gets the base path of the API client. + /// Validate the input before sending the request /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public Org.OpenAPITools.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public Org.OpenAPITools.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } - - /// - /// Create user This can only be done by the logged in user. - /// - /// Thrown when fails to make API call - /// Created user object - /// - public void CreateUser(User user) - { - CreateUserResponse(user); - } - - /// - /// Create user This can only be done by the logged in user. - /// - /// Thrown when fails to make API call - /// Created user object - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse CreateUserResponse(User user) - { - // verify the required parameter 'user' is set - if (user == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'user' when calling UserApi->CreateUser"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = user; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/user", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("CreateUser", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Create user This can only be done by the logged in user. - /// - /// Thrown when fails to make API call /// Created user object /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task CreateUserAsync(User user, System.Threading.CancellationToken? cancellationToken = null) - { - await CreateUserResponseAsync(user, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateCreateUserRequestAsync(User user, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateCreateUserRequestAsync(User user, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// Create user This can only be done by the logged in user. @@ -588,322 +280,65 @@ private System.Threading.Tasks.ValueTask ValidateCreateUserRequestAsync(User use /// Created user object /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> CreateUserResponseAsync(User user, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> CreateUserWithHttpInfoAsync(User user, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'user' is set if (user == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'user' when calling UserApi->CreateUser"); - - await ValidateCreateUserRequestAsync(user, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/user"; - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - - string[] contentTypes = new string[] { - "application/json" - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - "application/json" - }; - - // to determine the Accept header - string[] _accepts = new string[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = user; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/user", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("CreateUser", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Creates list of users with given input array - /// - /// Thrown when fails to make API call - /// List of user object - /// - public void CreateUsersWithArrayInput(List user) - { - CreateUsersWithArrayInputResponse(user); - } - - /// - /// Creates list of users with given input array - /// - /// Thrown when fails to make API call - /// List of user object - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse CreateUsersWithArrayInputResponse(List user) - { - // verify the required parameter 'user' is set - if (user == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'user' when calling UserApi->CreateUsersWithArrayInput"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = user; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/user/createWithArray", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("CreateUsersWithArrayInput", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Creates list of users with given input array - /// - /// Thrown when fails to make API call - /// List of user object - /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task CreateUsersWithArrayInputAsync(List user, System.Threading.CancellationToken? cancellationToken = null) - { - await CreateUsersWithArrayInputResponseAsync(user, cancellationToken).ConfigureAwait(false); - } - - private System.Threading.Tasks.ValueTask ValidateCreateUsersWithArrayInputRequestAsync(List user, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } - - /// - /// Creates list of users with given input array - /// - /// Thrown when fails to make API call - /// List of user object - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - public async System.Threading.Tasks.Task> CreateUsersWithArrayInputResponseAsync(List user, System.Threading.CancellationToken? cancellationToken = null) - { - // verify the required parameter 'user' is set - if (user == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'user' when calling UserApi->CreateUsersWithArrayInput"); - - await ValidateCreateUsersWithArrayInputRequestAsync(user, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/user/createWithArray"; - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - - - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - - string[] contentTypes = new string[] { - "application/json" - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - "application/json" - }; + throw new ArgumentNullException(nameof(user)); - // to determine the Accept header - string[] _accepts = new string[] { - }; + await ValidateCreateUserRequestAsync(user, cancellationToken).ConfigureAwait(false); - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + string path = "/user"; - localVarRequestOptions.Data = user; + path = $"{path}?"; + - // make the HTTP request + if (path.EndsWith("&")) + path = path[..^1]; - var localVarResponse = await this.AsynchronousClient.PostAsync("/user/createWithArray", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + if (path.EndsWith("?")) + path = path[..^1]; - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("CreateUsersWithArrayInput", localVarResponse); - if (_exception != null) throw _exception; - } + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - return localVarResponse; - } - /// - /// Creates list of users with given input array - /// - /// Thrown when fails to make API call - /// List of user object - /// - public void CreateUsersWithListInput(List user) - { - CreateUsersWithListInputResponse(user); - } - /// - /// Creates list of users with given input array - /// - /// Thrown when fails to make API call - /// List of user object - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse CreateUsersWithListInputResponse(List user) - { - // verify the required parameter 'user' is set - if (user == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'user' when calling UserApi->CreateUsersWithListInput"); + // todo localVarRequestOptions.Data = user; - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - String[] _contentTypes = new String[] { - "application/json" - }; + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - // to determine the Accept header - String[] _accepts = new String[] { + string[] contentTypes = new string[] { + "application/json" }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.Data = user; + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - var localVarResponse = this.Client.Post("/user/createWithList", localVarRequestOptions, this.Configuration); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("CreateUsersWithListInput", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// Creates list of users with given input array + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// List of user object /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task CreateUsersWithListInputAsync(List user, System.Threading.CancellationToken? cancellationToken = null) - { - await CreateUsersWithListInputResponseAsync(user, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithArrayInputRequestAsync(List user, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateCreateUsersWithListInputRequestAsync(List user, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// Creates list of users with given input array @@ -912,159 +347,132 @@ private System.Threading.Tasks.ValueTask ValidateCreateUsersWithListInputRequest /// List of user object /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> CreateUsersWithListInputResponseAsync(List user, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> CreateUsersWithArrayInputWithHttpInfoAsync(List user, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'user' is set if (user == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'user' when calling UserApi->CreateUsersWithListInput"); - - await ValidateCreateUsersWithListInputRequestAsync(user, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/user/createWithList"; + throw new ArgumentNullException(nameof(user)); - path = $"{path}?"; - + await ValidateCreateUsersWithArrayInputRequestAsync(user, cancellationToken).ConfigureAwait(false); - if (path.EndsWith("&")) - path = path[..^1]; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - if (path.EndsWith("?")) - path = path[..^1]; + string path = "/user/createWithArray"; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + path = $"{path}?"; + - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + if (path.EndsWith("&")) + path = path[..^1]; - string[] contentTypes = new string[] { - "application/json" - }; + if (path.EndsWith("?")) + path = path[..^1]; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + // todo localVarRequestOptions.Data = user; - ApiResponse apiResponse = new(responseMessage, responseContent); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { + string[] contentTypes = new string[] { "application/json" }; - // to determine the Accept header - string[] _accepts = new string[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.Data = user; + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request + ApiResponse apiResponse = new(responseMessage, responseContent); - var localVarResponse = await this.AsynchronousClient.PostAsync("/user/createWithList", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("CreateUsersWithListInput", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + return apiResponse; } /// - /// Delete user This can only be done by the logged in user. + /// Validate the input before sending the request /// - /// Thrown when fails to make API call - /// The name that needs to be deleted - /// - public void DeleteUser(string username) - { - DeleteUserResponse(username); - } + /// List of user object + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithListInputRequestAsync(List user, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + + /// - /// Delete user This can only be done by the logged in user. + /// Creates list of users with given input array /// /// Thrown when fails to make API call - /// The name that needs to be deleted - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse DeleteUserResponse(string username) + /// List of user object + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task> CreateUsersWithListInputWithHttpInfoAsync(List user, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'username' is set - if (username == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'username' when calling UserApi->DeleteUser"); + if (user == null) + throw new ArgumentNullException(nameof(user)); + + await ValidateCreateUsersWithListInputRequestAsync(user, cancellationToken).ConfigureAwait(false); + + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + + string path = "/user/createWithList"; + + + path = $"{path}?"; + + + if (path.EndsWith("&")) + path = path[..^1]; + + if (path.EndsWith("?")) + path = path[..^1]; + + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - String[] _contentTypes = new String[] { - }; - // to determine the Accept header - String[] _accepts = new String[] { + // todo localVarRequestOptions.Data = user; + + + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + + string[] contentTypes = new string[] { + "application/json" }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.PathParameters.Add("username", Org.OpenAPITools.Client.ClientUtils.ParameterToString(username)); // path parameter + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - var localVarResponse = this.Client.Delete("/user/{username}", localVarRequestOptions, this.Configuration); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("DeleteUser", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// Delete user This can only be done by the logged in user. + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// The name that needs to be deleted /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task DeleteUserAsync(string username, System.Threading.CancellationToken? cancellationToken = null) - { - await DeleteUserResponseAsync(username, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateDeleteUserRequestAsync(string username, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateDeleteUserRequestAsync(string username, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// Delete user This can only be done by the logged in user. @@ -1073,141 +481,74 @@ private System.Threading.Tasks.ValueTask ValidateDeleteUserRequestAsync(string u /// The name that needs to be deleted /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> DeleteUserResponseAsync(string username, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> DeleteUserWithHttpInfoAsync(string username, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'username' is set if (username == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'username' when calling UserApi->DeleteUser"); - - await ValidateDeleteUserRequestAsync(username, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/user/{username}"; - path = path.Replace("{username}", Uri.EscapeDataString(username)); + throw new ArgumentNullException(nameof(username)); - path = $"{path}?"; - + await ValidateDeleteUserRequestAsync(username, cancellationToken).ConfigureAwait(false); - if (path.EndsWith("&")) - path = path[..^1]; + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - if (path.EndsWith("?")) - path = path[..^1]; + string path = "/user/{username}"; + path = path.Replace("{username}", Uri.EscapeDataString(username)); - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + path = $"{path}?"; + - string[] contentTypes = new string[] { - }; + if (path.EndsWith("&")) + path = path[..^1]; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + if (path.EndsWith("?")) + path = path[..^1]; + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - ApiResponse apiResponse = new(responseMessage, responseContent); - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - return apiResponse; - } - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - }; - - // to determine the Accept header - string[] _accepts = new string[] { + string[] contentTypes = new string[] { }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - localVarRequestOptions.PathParameters.Add("username", Org.OpenAPITools.Client.ClientUtils.ParameterToString(username)); // path parameter + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - // make the HTTP request + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - var localVarResponse = await this.AsynchronousClient.DeleteAsync("/user/{username}", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("DeleteUser", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// Get user by user name + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// The name that needs to be fetched. Use user1 for testing. - /// User - public User GetUserByName(string username) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = GetUserByNameResponse(username); - return localVarResponse.Data; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateGetUserByNameRequestAsync(string username, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// Get user by user name /// /// Thrown when fails to make API call /// The name that needs to be fetched. Use user1 for testing. - /// ApiResponse of User - public Org.OpenAPITools.Client.ApiResponse GetUserByNameResponse(string username) + /// Cancellation Token to cancel the request. + /// Task of User + public async System.Threading.Tasks.Task GetUserByNameAsync(string username, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'username' is set - if (username == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'username' when calling UserApi->GetUserByName"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/xml", - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("username", Org.OpenAPITools.Client.ClientUtils.ParameterToString(username)); // path parameter - - - // make the HTTP request - var localVarResponse = this.Client.Get("/user/{username}", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("GetUserByName", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse result = await GetUserByNameWithHttpInfoAsync(username, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -1217,17 +558,14 @@ public Org.OpenAPITools.Client.ApiResponse GetUserByNameResponse(string us /// The name that needs to be fetched. Use user1 for testing. /// Cancellation Token to cancel the request. /// Task of User - public async System.Threading.Tasks.Task GetUserByNameAsync(string username, System.Threading.CancellationToken? cancellationToken = null) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetUserByNameResponseAsync(username, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateGetUserByNameRequestAsync(string username, System.Threading.CancellationToken? cancellationToken) + public async System.Threading.Tasks.Task GetUserByNameOrDefaultAsync(string username, System.Threading.CancellationToken? cancellationToken = null) { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await GetUserByNameWithHttpInfoAsync(username, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// Get user by user name @@ -1236,103 +574,65 @@ private System.Threading.Tasks.ValueTask ValidateGetUserByNameRequestAsync(strin /// The name that needs to be fetched. Use user1 for testing. /// Cancellation Token to cancel the request. /// Task of ApiResponse (User) - public async System.Threading.Tasks.Task> GetUserByNameResponseAsync(string username, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> GetUserByNameWithHttpInfoAsync(string username, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'username' is set if (username == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'username' when calling UserApi->GetUserByName"); - - await ValidateGetUserByNameRequestAsync(username, cancellationToken); + throw new ArgumentNullException(nameof(username)); - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + await ValidateGetUserByNameRequestAsync(username, cancellationToken).ConfigureAwait(false); - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + string path = "/user/{username}"; + path = path.Replace("{username}", Uri.EscapeDataString(username)); - string path = "/user/{username}"; - path = path.Replace("{username}", Uri.EscapeDataString(username)); - path = $"{path}?"; - - if (path.EndsWith("&")) - path = path[..^1]; + path = $"{path}?"; + - if (path.EndsWith("?")) - path = path[..^1]; + if (path.EndsWith("&")) + path = path[..^1]; - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + if (path.EndsWith("?")) + path = path[..^1]; + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - string[] contentTypes = new string[] { - }; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); - - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - }; - - // to determine the Accept header - string[] _accepts = new string[] { - "application/xml", - "application/json" + string[] contentTypes = new string[] { }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - localVarRequestOptions.PathParameters.Add("username", Org.OpenAPITools.Client.ClientUtils.ParameterToString(username)); // path parameter + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request + ApiResponse apiResponse = new(responseMessage, responseContent); - var localVarResponse = await this.AsynchronousClient.GetAsync("/user/{username}", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("GetUserByName", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + return apiResponse; } /// - /// Logs user into the system + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// The user name for login /// The password for login in clear text - /// string - public string LoginUser(string username, string password) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = LoginUserResponse(username, password); - return localVarResponse.Data; - } + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateLoginUserRequestAsync(string username, string password, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); /// /// Logs user into the system @@ -1340,48 +640,12 @@ public string LoginUser(string username, string password) /// Thrown when fails to make API call /// The user name for login /// The password for login in clear text - /// ApiResponse of string - public Org.OpenAPITools.Client.ApiResponse LoginUserResponse(string username, string password) + /// Cancellation Token to cancel the request. + /// Task of string + public async System.Threading.Tasks.Task LoginUserAsync(string username, string password, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'username' is set - if (username == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'username' when calling UserApi->LoginUser"); - - // verify the required parameter 'password' is set - if (password == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'password' when calling UserApi->LoginUser"); - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/xml", - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "username", username)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "password", password)); - - - // make the HTTP request - var localVarResponse = this.Client.Get("/user/login", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("LoginUser", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + Org.OpenAPITools.Client.ApiResponse result = await LoginUserWithHttpInfoAsync(username, password, cancellationToken).ConfigureAwait(false); + return result.Data ?? throw new NullReferenceException(); } /// @@ -1392,17 +656,14 @@ public Org.OpenAPITools.Client.ApiResponse LoginUserResponse(string user /// The password for login in clear text /// Cancellation Token to cancel the request. /// Task of string - public async System.Threading.Tasks.Task LoginUserAsync(string username, string password, System.Threading.CancellationToken? cancellationToken = null) - { - Org.OpenAPITools.Client.ApiResponse localVarResponse = await LoginUserResponseAsync(username, password, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - private System.Threading.Tasks.ValueTask ValidateLoginUserRequestAsync(string username, string password, System.Threading.CancellationToken? cancellationToken) + public async System.Threading.Tasks.Task LoginUserOrDefaultAsync(string username, string password, System.Threading.CancellationToken? cancellationToken = null) { - // todo - return new System.Threading.Tasks.ValueTask(); - } + Org.OpenAPITools.Client.ApiResponse result = await LoginUserWithHttpInfoAsync(username, password, cancellationToken).ConfigureAwait(false); + + return result.IsSuccessStatusCode + ? result.Data + : null; + } /// /// Logs user into the system @@ -1412,160 +673,69 @@ private System.Threading.Tasks.ValueTask ValidateLoginUserRequestAsync(string us /// The password for login in clear text /// Cancellation Token to cancel the request. /// Task of ApiResponse (string) - public async System.Threading.Tasks.Task> LoginUserResponseAsync(string username, string password, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> LoginUserWithHttpInfoAsync(string username, string password, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'username' is set if (username == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'username' when calling UserApi->LoginUser"); - // verify the required parameter 'password' is set + throw new ArgumentNullException(nameof(username)); if (password == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'password' when calling UserApi->LoginUser"); - - await ValidateLoginUserRequestAsync(username, password, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/user/login"; - - path = $"{path}?"; - - path = $"{path}username={Uri.EscapeDataString(username.ToString())&"; - - path = $"{path}password={Uri.EscapeDataString(password.ToString())&"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; + throw new ArgumentNullException(nameof(password)); - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + await ValidateLoginUserRequestAsync(username, password, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + string path = "/user/login"; - string[] contentTypes = new string[] { - }; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + path = $"{path}?"; + + path = $"{path}username={Uri.EscapeDataString(username.ToString()!)&"; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + path = $"{path}password={Uri.EscapeDataString(password.ToString()!)&"; - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + if (path.EndsWith("&")) + path = path[..^1]; - ApiResponse apiResponse = new(responseMessage, responseContent); + if (path.EndsWith("?")) + path = path[..^1]; - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - return apiResponse; - } - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - string[] _contentTypes = new string[] { - }; - - // to determine the Accept header - string[] _accepts = new string[] { - "application/xml", - "application/json" - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "username", username)); - localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "password", password)); - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync("/user/login", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("LoginUser", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Logs out current logged in user session - /// - /// Thrown when fails to make API call - /// - public void LogoutUser() - { - LogoutUserResponse(); - } - /// - /// Logs out current logged in user session - /// - /// Thrown when fails to make API call - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse LogoutUserResponse() - { - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - String[] _contentTypes = new String[] { - }; - // to determine the Accept header - String[] _accepts = new String[] { + string[] contentTypes = new string[] { }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - var localVarResponse = this.Client.Get("/user/logout", localVarRequestOptions, this.Configuration); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("LogoutUser", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// Logs out current logged in user session + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task LogoutUserAsync(System.Threading.CancellationToken? cancellationToken = null) - { - await LogoutUserResponseAsync(cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateLogoutUserRequestAsync(System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateLogoutUserRequestAsync(System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// Logs out current logged in user session @@ -1573,161 +743,61 @@ private System.Threading.Tasks.ValueTask ValidateLogoutUserRequestAsync(System.T /// Thrown when fails to make API call /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> LogoutUserResponseAsync(System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> LogoutUserWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { - await ValidateLogoutUserRequestAsync(cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - - - string path = "/user/logout"; - - path = $"{path}?"; - - - if (path.EndsWith("&")) - path = path[..^1]; - - if (path.EndsWith("?")) - path = path[..^1]; - - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - - - - string[] contentTypes = new string[] { - }; - - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - - - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); + await ValidateLogoutUserRequestAsync(cancellationToken).ConfigureAwait(false); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - ApiResponse apiResponse = new(responseMessage, responseContent); + string path = "/user/logout"; - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - return apiResponse; - } + path = $"{path}?"; + - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + if (path.EndsWith("&")) + path = path[..^1]; - string[] _contentTypes = new string[] { - }; - - // to determine the Accept header - string[] _accepts = new string[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request + if (path.EndsWith("?")) + path = path[..^1]; - var localVarResponse = await this.AsynchronousClient.GetAsync("/user/logout", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("LogoutUser", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Updated user This can only be done by the logged in user. - /// - /// Thrown when fails to make API call - /// name that need to be deleted - /// Updated user object - /// - public void UpdateUser(string username, User user) - { - UpdateUserResponse(username, user); - } - /// - /// Updated user This can only be done by the logged in user. - /// - /// Thrown when fails to make API call - /// name that need to be deleted - /// Updated user object - /// ApiResponse of Object(void) - public Org.OpenAPITools.Client.ApiResponse UpdateUserResponse(string username, User user) - { - // verify the required parameter 'username' is set - if (username == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'username' when calling UserApi->UpdateUser"); - // verify the required parameter 'user' is set - if (user == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'user' when calling UserApi->UpdateUser"); - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - String[] _contentTypes = new String[] { - "application/json" - }; - // to determine the Accept header - String[] _accepts = new String[] { + string[] contentTypes = new string[] { }; - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.PathParameters.Add("username", Org.OpenAPITools.Client.ClientUtils.ParameterToString(username)); // path parameter - localVarRequestOptions.Data = user; + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request - var localVarResponse = this.Client.Put("/user/{username}", localVarRequestOptions, this.Configuration); + ApiResponse apiResponse = new(responseMessage, responseContent); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("UpdateUser", localVarResponse); - if (_exception != null) throw _exception; - } + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - return localVarResponse; + return apiResponse; } /// - /// Updated user This can only be done by the logged in user. + /// Validate the input before sending the request /// - /// Thrown when fails to make API call /// name that need to be deleted /// Updated user object /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task UpdateUserAsync(string username, User user, System.Threading.CancellationToken? cancellationToken = null) - { - await UpdateUserResponseAsync(username, user, cancellationToken).ConfigureAwait(false); - } + protected virtual System.Threading.Tasks.ValueTask ValidateUpdateUserRequestAsync(string username, User user, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + - private System.Threading.Tasks.ValueTask ValidateUpdateUserRequestAsync(string username, User user, System.Threading.CancellationToken? cancellationToken) - { - // todo - return new System.Threading.Tasks.ValueTask(); - } /// /// Updated user This can only be done by the logged in user. @@ -1737,93 +807,58 @@ private System.Threading.Tasks.ValueTask ValidateUpdateUserRequestAsync(string u /// Updated user object /// Cancellation Token to cancel the request. /// Task of ApiResponse - public async System.Threading.Tasks.Task> UpdateUserResponseAsync(string username, User user, System.Threading.CancellationToken? cancellationToken = null) + public async System.Threading.Tasks.Task> UpdateUserWithHttpInfoAsync(string username, User user, System.Threading.CancellationToken? cancellationToken = null) { - // verify the required parameter 'username' is set if (username == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'username' when calling UserApi->UpdateUser"); - // verify the required parameter 'user' is set + throw new ArgumentNullException(nameof(username)); if (user == null) - throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'user' when calling UserApi->UpdateUser"); - - await ValidateUpdateUserRequestAsync(username, user, cancellationToken); - - if (_httpClient != null) - { - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); + throw new ArgumentNullException(nameof(user)); - request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); + await ValidateUpdateUserRequestAsync(username, user, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); - string path = "/user/{username}"; - path = path.Replace("{username}", Uri.EscapeDataString(username)); + string path = "/user/{username}"; + path = path.Replace("{username}", Uri.EscapeDataString(username)); - path = $"{path}?"; - - if (path.EndsWith("&")) - path = path[..^1]; - if (path.EndsWith("?")) - path = path[..^1]; + path = $"{path}?"; + - request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); + if (path.EndsWith("&")) + path = path[..^1]; + if (path.EndsWith("?")) + path = path[..^1]; - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + request.RequestUri = new Uri($"{_httpClient.BaseAddress}{path}"); - string[] contentTypes = new string[] { - "application/json" - }; - if (contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + // todo localVarRequestOptions.Data = user; - System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()); - string responseContent = await responseMessage.Content.ReadAsStringAsync(); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - ApiResponse apiResponse = new(responseMessage, responseContent); - - if (!responseMessage.IsSuccessStatusCode) - throw new ApiException(apiResponse); - - return apiResponse; - } - - Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); - - string[] _contentTypes = new string[] { + string[] contentTypes = new string[] { "application/json" }; - // to determine the Accept header - string[] _accepts = new string[] { - }; - - var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - localVarRequestOptions.PathParameters.Add("username", Org.OpenAPITools.Client.ClientUtils.ParameterToString(username)); // path parameter - localVarRequestOptions.Data = user; + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - // make the HTTP request + ApiResponse apiResponse = new(responseMessage, responseContent); - var localVarResponse = await this.AsynchronousClient.PutAsync("/user/{username}", localVarRequestOptions, this.Configuration, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + if (apiResponse.IsSuccessStatusCode) + apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("UpdateUser", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; + return apiResponse; } - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs index 520896de7ea5..e69de29bb2d1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs @@ -1,834 +0,0 @@ -/* - * OpenAPI Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * The version of the OpenAPI document: 1.0.0 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters; -using System.Text; -using System.Threading; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; -using RestSharp; -using RestSharp.Deserializers; -using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs; -using RestSharpMethod = RestSharp.Method; -using Polly; - -namespace Org.OpenAPITools.Client -{ - /// - /// Allows RestSharp to Serialize/Deserialize JSON using our custom logic, but only when ContentType is JSON. - /// - internal class CustomJsonCodec : RestSharp.Serializers.ISerializer, RestSharp.Deserializers.IDeserializer - { - private readonly IReadableConfiguration _configuration; - private static readonly string _contentType = "application/json"; - private readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings - { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - } - }; - - public CustomJsonCodec(IReadableConfiguration configuration) - { - _configuration = configuration; - } - - public CustomJsonCodec(JsonSerializerSettings serializerSettings, IReadableConfiguration configuration) - { - _serializerSettings = serializerSettings; - _configuration = configuration; - } - - /// - /// Serialize the object into a JSON string. - /// - /// Object to be serialized. - /// A JSON string. - public string Serialize(object obj) - { - if (obj != null && obj is Org.OpenAPITools.Model.AbstractOpenAPISchema) - { - // the object to be serialized is an oneOf/anyOf schema - return ((Org.OpenAPITools.Model.AbstractOpenAPISchema)obj).ToJson(); - } - else - { - return JsonConvert.SerializeObject(obj, _serializerSettings); - } - } - - public T Deserialize(IRestResponse response) - { - var result = (T)Deserialize(response, typeof(T)); - return result; - } - - /// - /// Deserialize the JSON string into a proper object. - /// - /// The HTTP response. - /// Object type. - /// Object representation of the JSON string. - internal object Deserialize(IRestResponse response, Type type) - { - IList headers = response.Headers; - if (type == typeof(byte[])) // return byte array - { - return response.RawBytes; - } - - // TODO: ? if (type.IsAssignableFrom(typeof(Stream))) - if (type == typeof(Stream)) - { - if (headers != null) - { - var filePath = String.IsNullOrEmpty(_configuration.TempFolderPath) - ? Path.GetTempPath() - : _configuration.TempFolderPath; - var regex = new Regex(@"Content-Disposition=.*filename=['""]?([^'""\s]+)['""]?$"); - foreach (var header in headers) - { - var match = regex.Match(header.ToString()); - if (match.Success) - { - string fileName = filePath + ClientUtils.SanitizeFilename(match.Groups[1].Value.Replace("\"", "").Replace("'", "")); - File.WriteAllBytes(fileName, response.RawBytes); - return new FileStream(fileName, FileMode.Open); - } - } - } - var stream = new MemoryStream(response.RawBytes); - return stream; - } - - if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object - { - return DateTime.Parse(response.Content, null, System.Globalization.DateTimeStyles.RoundtripKind); - } - - if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type - { - return Convert.ChangeType(response.Content, type); - } - - // at this point, it must be a model (json) - try - { - return JsonConvert.DeserializeObject(response.Content, type, _serializerSettings); - } - catch (Exception e) - { - throw new ApiException(500, e.Message); - } - } - - public string RootElement { get; set; } - public string Namespace { get; set; } - public string DateFormat { get; set; } - - public string ContentType - { - get { return _contentType; } - set { throw new InvalidOperationException("Not allowed to set content type."); } - } - } - /// - /// Provides a default implementation of an Api client (both synchronous and asynchronous implementatios), - /// encapsulating general REST accessor use cases. - /// - public partial class ApiClient : ISynchronousClient, IAsynchronousClient - { - private readonly String _baseUrl; - - /// - /// Specifies the settings on a object. - /// These settings can be adjusted to accomodate custom serialization rules. - /// - public JsonSerializerSettings SerializerSettings { get; set; } = new JsonSerializerSettings - { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - } - }; - - /// - /// Allows for extending request processing for generated code. - /// - /// The RestSharp request object - partial void InterceptRequest(IRestRequest request); - - /// - /// Allows for extending response processing for generated code. - /// - /// The RestSharp request object - /// The RestSharp response object - partial void InterceptResponse(IRestRequest request, IRestResponse response); - - /// - /// Initializes a new instance of the , defaulting to the global configurations' base url. - /// - public ApiClient() - { - _baseUrl = Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath; - } - - /// - /// Initializes a new instance of the - /// - /// The target service's base path in URL format. - /// - public ApiClient(String basePath) - { - if (string.IsNullOrEmpty(basePath)) - throw new ArgumentException("basePath cannot be empty"); - - _baseUrl = basePath; - } - - /// - /// Constructs the RestSharp version of an http method - /// - /// Swagger Client Custom HttpMethod - /// RestSharp's HttpMethod instance. - /// - private RestSharpMethod Method(HttpMethod method) - { - RestSharpMethod other; - switch (method) - { - case HttpMethod.Get: - other = RestSharpMethod.GET; - break; - case HttpMethod.Post: - other = RestSharpMethod.POST; - break; - case HttpMethod.Put: - other = RestSharpMethod.PUT; - break; - case HttpMethod.Delete: - other = RestSharpMethod.DELETE; - break; - case HttpMethod.Head: - other = RestSharpMethod.HEAD; - break; - case HttpMethod.Options: - other = RestSharpMethod.OPTIONS; - break; - case HttpMethod.Patch: - other = RestSharpMethod.PATCH; - break; - default: - throw new ArgumentOutOfRangeException("method", method, null); - } - - return other; - } - - /// - /// Provides all logic for constructing a new RestSharp . - /// At this point, all information for querying the service is known. Here, it is simply - /// mapped into the RestSharp request. - /// - /// The http verb. - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// [private] A new RestRequest instance. - /// - private RestRequest NewRequest( - HttpMethod method, - String path, - RequestOptions options, - IReadableConfiguration configuration) - { - if (path == null) throw new ArgumentNullException("path"); - if (options == null) throw new ArgumentNullException("options"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - RestRequest request = new RestRequest(Method(method)) - { - Resource = path, - JsonSerializer = new CustomJsonCodec(SerializerSettings, configuration) - }; - - if (options.PathParameters != null) - { - foreach (var pathParam in options.PathParameters) - { - request.AddParameter(pathParam.Key, pathParam.Value, ParameterType.UrlSegment); - } - } - - if (options.QueryParameters != null) - { - foreach (var queryParam in options.QueryParameters) - { - foreach (var value in queryParam.Value) - { - request.AddQueryParameter(queryParam.Key, value); - } - } - } - - if (configuration.DefaultHeaders != null) - { - foreach (var headerParam in configuration.DefaultHeaders) - { - request.AddHeader(headerParam.Key, headerParam.Value); - } - } - - if (options.HeaderParameters != null) - { - foreach (var headerParam in options.HeaderParameters) - { - foreach (var value in headerParam.Value) - { - request.AddHeader(headerParam.Key, value); - } - } - } - - if (options.FormParameters != null) - { - foreach (var formParam in options.FormParameters) - { - request.AddParameter(formParam.Key, formParam.Value); - } - } - - if (options.Data != null) - { - if (options.HeaderParameters != null) - { - var contentTypes = options.HeaderParameters["Content-Type"]; - if (contentTypes == null || contentTypes.Any(header => header.Contains("application/json"))) - { - request.RequestFormat = DataFormat.Json; - } - else - { - // TODO: Generated client user should add additional handlers. RestSharp only supports XML and JSON, with XML as default. - } - } - else - { - // Here, we'll assume JSON APIs are more common. XML can be forced by adding produces/consumes to openapi spec explicitly. - request.RequestFormat = DataFormat.Json; - } - - request.AddJsonBody(options.Data); - } - - if (options.FileParameters != null) - { - foreach (var fileParam in options.FileParameters) - { - var bytes = ClientUtils.ReadAsBytes(fileParam.Value); - var fileStream = fileParam.Value as FileStream; - if (fileStream != null) - request.Files.Add(FileParameter.Create(fileParam.Key, bytes, System.IO.Path.GetFileName(fileStream.Name))); - else - request.Files.Add(FileParameter.Create(fileParam.Key, bytes, "no_file_name_provided")); - } - } - - if (options.Cookies != null && options.Cookies.Count > 0) - { - foreach (var cookie in options.Cookies) - { - request.AddCookie(cookie.Name, cookie.Value); - } - } - - return request; - } - - private ApiResponse ToApiResponse(IRestResponse response) - { - T result = response.Data; - string rawContent = response.Content; - - var transformed = new ApiResponse(response.StatusCode, new Multimap(), result, rawContent) - { - ErrorText = response.ErrorMessage, - Cookies = new List() - }; - - if (response.Headers != null) - { - foreach (var responseHeader in response.Headers) - { - transformed.Headers.Add(responseHeader.Name, ClientUtils.ParameterToString(responseHeader.Value)); - } - } - - if (response.Cookies != null) - { - foreach (var responseCookies in response.Cookies) - { - transformed.Cookies.Add( - new Cookie( - responseCookies.Name, - responseCookies.Value, - responseCookies.Path, - responseCookies.Domain) - ); - } - } - - return transformed; - } - - private ApiResponse Exec(RestRequest req, IReadableConfiguration configuration) - { - RestClient client = new RestClient(_baseUrl); - - client.ClearHandlers(); - var existingDeserializer = req.JsonSerializer as IDeserializer; - if (existingDeserializer != null) - { - client.AddHandler("application/json", () => existingDeserializer); - client.AddHandler("text/json", () => existingDeserializer); - client.AddHandler("text/x-json", () => existingDeserializer); - client.AddHandler("text/javascript", () => existingDeserializer); - client.AddHandler("*+json", () => existingDeserializer); - } - else - { - var customDeserializer = new CustomJsonCodec(SerializerSettings, configuration); - client.AddHandler("application/json", () => customDeserializer); - client.AddHandler("text/json", () => customDeserializer); - client.AddHandler("text/x-json", () => customDeserializer); - client.AddHandler("text/javascript", () => customDeserializer); - client.AddHandler("*+json", () => customDeserializer); - } - - var xmlDeserializer = new XmlDeserializer(); - client.AddHandler("application/xml", () => xmlDeserializer); - client.AddHandler("text/xml", () => xmlDeserializer); - client.AddHandler("*+xml", () => xmlDeserializer); - client.AddHandler("*", () => xmlDeserializer); - - client.Timeout = configuration.Timeout; - - if (configuration.Proxy != null) - { - client.Proxy = configuration.Proxy; - } - - if (configuration.UserAgent != null) - { - client.UserAgent = configuration.UserAgent; - } - - if (configuration.ClientCertificates != null) - { - client.ClientCertificates = configuration.ClientCertificates; - } - - InterceptRequest(req); - - IRestResponse response; - if (RetryConfiguration.RetryPolicy != null) - { - var policy = RetryConfiguration.RetryPolicy; - var policyResult = policy.ExecuteAndCapture(() => client.Execute(req)); - response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize(policyResult.Result) : new RestResponse - { - Request = req, - ErrorException = policyResult.FinalException - }; - } - else - { - response = client.Execute(req); - } - - InterceptResponse(req, response); - - var result = ToApiResponse(response); - if (response.ErrorMessage != null) - { - result.ErrorText = response.ErrorMessage; - } - - if (response.Cookies != null && response.Cookies.Count > 0) - { - if (result.Cookies == null) result.Cookies = new List(); - foreach (var restResponseCookie in response.Cookies) - { - var cookie = new Cookie( - restResponseCookie.Name, - restResponseCookie.Value, - restResponseCookie.Path, - restResponseCookie.Domain - ) - { - Comment = restResponseCookie.Comment, - CommentUri = restResponseCookie.CommentUri, - Discard = restResponseCookie.Discard, - Expired = restResponseCookie.Expired, - Expires = restResponseCookie.Expires, - HttpOnly = restResponseCookie.HttpOnly, - Port = restResponseCookie.Port, - Secure = restResponseCookie.Secure, - Version = restResponseCookie.Version - }; - - result.Cookies.Add(cookie); - } - } - return result; - } - - private async Task> ExecAsync(RestRequest req, IReadableConfiguration configuration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - RestClient client = new RestClient(_baseUrl); - - client.ClearHandlers(); - var existingDeserializer = req.JsonSerializer as IDeserializer; - if (existingDeserializer != null) - { - client.AddHandler("application/json", () => existingDeserializer); - client.AddHandler("text/json", () => existingDeserializer); - client.AddHandler("text/x-json", () => existingDeserializer); - client.AddHandler("text/javascript", () => existingDeserializer); - client.AddHandler("*+json", () => existingDeserializer); - } - else - { - var customDeserializer = new CustomJsonCodec(SerializerSettings, configuration); - client.AddHandler("application/json", () => customDeserializer); - client.AddHandler("text/json", () => customDeserializer); - client.AddHandler("text/x-json", () => customDeserializer); - client.AddHandler("text/javascript", () => customDeserializer); - client.AddHandler("*+json", () => customDeserializer); - } - - var xmlDeserializer = new XmlDeserializer(); - client.AddHandler("application/xml", () => xmlDeserializer); - client.AddHandler("text/xml", () => xmlDeserializer); - client.AddHandler("*+xml", () => xmlDeserializer); - client.AddHandler("*", () => xmlDeserializer); - - client.Timeout = configuration.Timeout; - - if (configuration.Proxy != null) - { - client.Proxy = configuration.Proxy; - } - - if (configuration.UserAgent != null) - { - client.UserAgent = configuration.UserAgent; - } - - if (configuration.ClientCertificates != null) - { - client.ClientCertificates = configuration.ClientCertificates; - } - - InterceptRequest(req); - - IRestResponse response; - if (RetryConfiguration.AsyncRetryPolicy != null) - { - var policy = RetryConfiguration.AsyncRetryPolicy; - var policyResult = await policy.ExecuteAndCaptureAsync(() => client.ExecuteAsync(req, cancellationToken)).ConfigureAwait(false); - response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize(policyResult.Result) : new RestResponse - { - Request = req, - ErrorException = policyResult.FinalException - }; - } - else - { - response = await client.ExecuteAsync(req, cancellationToken).ConfigureAwait(false); - } - - // if the response type is oneOf/anyOf, call FromJSON to deserialize the data - if (typeof(Org.OpenAPITools.Model.AbstractOpenAPISchema).IsAssignableFrom(typeof(T))) - { - T instance = (T)Activator.CreateInstance(typeof(T)); - MethodInfo method = typeof(T).GetMethod("FromJson"); - method.Invoke(instance, new object[] { response.Content }); - response.Data = instance; - } - - InterceptResponse(req, response); - - var result = ToApiResponse(response); - if (response.ErrorMessage != null) - { - result.ErrorText = response.ErrorMessage; - } - - if (response.Cookies != null && response.Cookies.Count > 0) - { - if (result.Cookies == null) result.Cookies = new List(); - foreach (var restResponseCookie in response.Cookies) - { - var cookie = new Cookie( - restResponseCookie.Name, - restResponseCookie.Value, - restResponseCookie.Path, - restResponseCookie.Domain - ) - { - Comment = restResponseCookie.Comment, - CommentUri = restResponseCookie.CommentUri, - Discard = restResponseCookie.Discard, - Expired = restResponseCookie.Expired, - Expires = restResponseCookie.Expires, - HttpOnly = restResponseCookie.HttpOnly, - Port = restResponseCookie.Port, - Secure = restResponseCookie.Secure, - Version = restResponseCookie.Version - }; - - result.Cookies.Add(cookie); - } - } - return result; - } - - #region IAsynchronousClient - /// - /// Make a HTTP GET request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> GetAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Get, path, options, config), config, cancellationToken); - } - - /// - /// Make a HTTP POST request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> PostAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Post, path, options, config), config, cancellationToken); - } - - /// - /// Make a HTTP PUT request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> PutAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Put, path, options, config), config, cancellationToken); - } - - /// - /// Make a HTTP DELETE request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> DeleteAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Delete, path, options, config), config, cancellationToken); - } - - /// - /// Make a HTTP HEAD request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> HeadAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Head, path, options, config), config, cancellationToken); - } - - /// - /// Make a HTTP OPTION request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> OptionsAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Options, path, options, config), config, cancellationToken); - } - - /// - /// Make a HTTP PATCH request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> PatchAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Patch, path, options, config), config, cancellationToken); - } - #endregion IAsynchronousClient - - #region ISynchronousClient - /// - /// Make a HTTP GET request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Get(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Get, path, options, config), config); - } - - /// - /// Make a HTTP POST request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Post(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Post, path, options, config), config); - } - - /// - /// Make a HTTP PUT request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Put(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Put, path, options, config), config); - } - - /// - /// Make a HTTP DELETE request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Delete(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Delete, path, options, config), config); - } - - /// - /// Make a HTTP HEAD request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Head(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Head, path, options, config), config); - } - - /// - /// Make a HTTP OPTION request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Options(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Options, path, options, config), config); - } - - /// - /// Make a HTTP PATCH request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Patch(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Patch, path, options, config), config); - } - #endregion ISynchronousClient - } -} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiException.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiException.cs index 7c3b47b3cf13..b804a84b7ea4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiException.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiException.cs @@ -15,64 +15,36 @@ namespace Org.OpenAPITools.Client /// /// API Exception /// - public class ApiException : Exception + public class ApiException : Exception { /// - /// Gets or sets the error code (HTTP status code) + /// The reason the api request failed /// - /// The error code (HTTP status code). - public int ErrorCode { get; set; } + public string? ReasonPhrase { get; } /// - /// Gets or sets the error content (body json object) + /// The HttpStatusCode /// - /// The error content (Http response body). - public object ErrorContent { get; private set; } + public System.Net.HttpStatusCode StatusCode { get; } /// - /// Gets or sets the HTTP headers + /// The raw data returned by the api /// - /// HTTP headers - public Multimap Headers { get; private set; } - + public string RawData { get; } + /// - /// The unsuccessful server request. + /// Construct the ApiException from parts of the reponse /// - public ApiResponse ApiResponse; - - public ApiException(ApiResponse apiResponse) + /// + /// + /// + public ApiException(string? reasonPhrase, System.Net.HttpStatusCode statusCode, string rawData) : base(reasonPhrase ?? rawData) { - ApiResponse = apiResponse; - } + ReasonPhrase = reasonPhrase; - /// - /// Initializes a new instance of the class. - /// - public ApiException() { } - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Error message. - public ApiException(int errorCode, string message) : base(message) - { - this.ErrorCode = errorCode; - } + StatusCode = statusCode; - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Error message. - /// Error content. - /// HTTP Headers. - public ApiException(int errorCode, string message, object errorContent = null, Multimap headers = null) : base(message) - { - this.ErrorCode = errorCode; - this.ErrorContent = errorContent; - this.Headers = headers; + RawData = rawData; } } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiResponse.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiResponse.cs index e10fe5c7ced4..865a0a77c8d3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiResponse.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiResponse.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.Net; +using Newtonsoft.Json; namespace Org.OpenAPITools.Client { @@ -20,32 +21,16 @@ namespace Org.OpenAPITools.Client public interface IApiResponse { /// - /// The data type of + /// The data type of /// Type ResponseType { get; } - /// - /// The content of this response - /// - Object Content { get; } - /// /// Gets or sets the status code (HTTP status code) /// /// The status code. HttpStatusCode StatusCode { get; } - /// - /// Gets or sets the HTTP headers - /// - /// HTTP headers - Multimap Headers { get; } - - /// - /// Gets or sets any error text defined by the calling client. - /// - String ErrorText { get; set; } - /// /// Gets or sets any cookies passed along on the response. /// @@ -54,38 +39,26 @@ public interface IApiResponse /// /// The raw content of this response /// - string RawContent { get; } + string RawData { get; } } /// /// API Response /// - public class ApiResponse : IApiResponse + public partial class ApiResponse : IApiResponse { #region Properties /// - /// Gets or sets the status code (HTTP status code) - /// - /// The status code. - public HttpStatusCode StatusCode { get; } - - /// - /// Gets or sets the HTTP headers + /// The deserialized data /// - /// HTTP headers - public Multimap Headers { get; } + public T? Data { get; set; } /// - /// Gets or sets the data (parsed HTTP body) - /// - /// The data. - public T Data { get; } - - /// - /// Gets or sets any error text defined by the calling client. + /// Gets or sets the status code (HTTP status code) /// - public String ErrorText { get; set; } + /// The status code. + public HttpStatusCode StatusCode { get; } /// /// Gets or sets any cookies passed along on the response. @@ -101,77 +74,39 @@ public Type ResponseType } /// - /// The data type of + /// The raw data /// - public object Content - { - get { return Data; } - } + public string RawData { get; } /// - /// The raw content + /// The IsSuccessStatusCode from the api response /// - public string RawContent { get; } + public bool IsSuccessStatusCode { get; } /// - /// The servers response to our request. + /// The reason phrase contained in the api response /// - public System.Net.Http.HttpResponseMessage Response { get; } - - #endregion Properties - - #region Constructors - - public ApiResponse(System.Net.Http.HttpResponseMessage response, string rawContent) - { - Response = response; - RawContent = rawContent; - } + public string? ReasonPhrase { get; } /// - /// Initializes a new instance of the class. + /// The headers contained in the api response /// - /// HTTP status code. - /// HTTP headers. - /// Data (parsed HTTP body) - /// Raw content. - public ApiResponse(HttpStatusCode statusCode, Multimap headers, T data, string rawContent) - { - StatusCode = statusCode; - Headers = headers; - Data = data; - RawContent = rawContent; - } + public System.Net.Http.Headers.HttpResponseHeaders Headers { get; } - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// HTTP headers. - /// Data (parsed HTTP body) - public ApiResponse(HttpStatusCode statusCode, Multimap headers, T data) : this(statusCode, headers, data, null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Data (parsed HTTP body) - /// Raw content. - public ApiResponse(HttpStatusCode statusCode, T data, string rawContent) : this(statusCode, null, data, rawContent) - { - } + #endregion Properties /// - /// Initializes a new instance of the class. + /// Construct the reponse using an HttpResponseMessage /// - /// HTTP status code. - /// Data (parsed HTTP body) - public ApiResponse(HttpStatusCode statusCode, T data) : this(statusCode, data, null) + /// + /// + public ApiResponse(System.Net.Http.HttpResponseMessage response, string rawData) { + StatusCode = response.StatusCode; + Headers = response.Headers; + IsSuccessStatusCode = response.IsSuccessStatusCode; + ReasonPhrase = response.ReasonPhrase; + RawData = rawData; } - - #endregion Constructors } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ClientUtils.cs index 844e7e9a8f4b..408f8d85d494 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -37,6 +37,23 @@ static ClientUtils() compareLogic = new CompareLogic(); } + /// + /// Custom JSON serializer + /// + public static readonly Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings = new Newtonsoft.Json.JsonSerializerSettings + { + // OpenAPI generated types generally hide default constructors. + ConstructorHandling = Newtonsoft.Json.ConstructorHandling.AllowNonPublicDefaultConstructor, + MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Error, + ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver + { + NamingStrategy = new Newtonsoft.Json.Serialization.CamelCaseNamingStrategy + { + OverrideSpecifiedNames = false + } + } + }; + /// /// Sanitize filename by removing the path /// @@ -85,6 +102,9 @@ public static Multimap ParameterToMultiMap(string collectionForm /// Formatted string. public static string ParameterToString(object obj, IReadableConfiguration configuration = null) { + throw new NotImplementedException(); + + /* if (obj is DateTime dateTime) // Return a formatted date string - Can be customized with Configuration.DateTimeFormat // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") @@ -103,6 +123,7 @@ public static string ParameterToString(object obj, IReadableConfiguration config return string.Join(",", collection.Cast()); return Convert.ToString(obj, CultureInfo.InvariantCulture); + */ } /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/Configuration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/Configuration.cs index bca7db624cd8..e69de29bb2d1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/Configuration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/Configuration.cs @@ -1,587 +0,0 @@ -/* - * OpenAPI Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * The version of the OpenAPI document: 1.0.0 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Security.Cryptography.X509Certificates; -using System.Text; - -namespace Org.OpenAPITools.Client -{ - /// - /// Represents a set of configuration settings - /// - public class Configuration : IReadableConfiguration - { - #region Constants - - /// - /// Version of the package. - /// - /// Version of the package. - public const string Version = "1.0.0"; - - /// - /// Identifier for ISO 8601 DateTime Format - /// - /// See https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 for more information. - // ReSharper disable once InconsistentNaming - public const string ISO8601_DATETIME_FORMAT = "o"; - - #endregion Constants - - #region Static Members - - /// - /// Default creation of exceptions for a given method name and response object - /// - public static readonly ExceptionFactory DefaultExceptionFactory = (methodName, response) => - { - var status = (int)response.StatusCode; - if (status >= 400) - { - return new ApiException(status, - string.Format("Error calling {0}: {1}", methodName, response.RawContent), - response.RawContent, response.Headers); - } - return null; - }; - - #endregion Static Members - - #region Private Members - - /// - /// Defines the base path of the target API server. - /// Example: http://localhost:3000/v1/ - /// - private String _basePath; - - /// - /// Gets or sets the API key based on the authentication name. - /// This is the key and value comprising the "secret" for acessing an API. - /// - /// The API key. - private IDictionary _apiKey; - - /// - /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name. - /// - /// The prefix of the API key. - private IDictionary _apiKeyPrefix; - - private string _dateTimeFormat = ISO8601_DATETIME_FORMAT; - private string _tempFolderPath = Path.GetTempPath(); - - /// - /// Gets or sets the servers defined in the OpenAPI spec. - /// - /// The servers - private IList> _servers; - - /// - /// HttpSigning configuration - /// - private HttpSigningConfiguration _HttpSigningConfiguration = null; - #endregion Private Members - - #region Constructors - - /// - /// Initializes a new instance of the class - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")] - public Configuration() - { - Proxy = null; - UserAgent = "OpenAPI-Generator/1.0.0/csharp"; - BasePath = "http://petstore.swagger.io:80/v2"; - DefaultHeaders = new ConcurrentDictionary(); - ApiKey = new ConcurrentDictionary(); - ApiKeyPrefix = new ConcurrentDictionary(); - Servers = new List>() - { - { - new Dictionary { - {"url", "http://{server}.swagger.io:{port}/v2"}, - {"description", "petstore server"}, - { - "variables", new Dictionary { - { - "server", new Dictionary { - {"description", "No description provided"}, - {"default_value", "petstore"}, - { - "enum_values", new List() { - "petstore", - "qa-petstore", - "dev-petstore" - } - } - } - }, - { - "port", new Dictionary { - {"description", "No description provided"}, - {"default_value", "80"}, - { - "enum_values", new List() { - "80", - "8080" - } - } - } - } - } - } - } - }, - { - new Dictionary { - {"url", "https://localhost:8080/{version}"}, - {"description", "The local server"}, - { - "variables", new Dictionary { - { - "version", new Dictionary { - {"description", "No description provided"}, - {"default_value", "v2"}, - { - "enum_values", new List() { - "v1", - "v2" - } - } - } - } - } - } - } - }, - { - new Dictionary { - {"url", "https://127.0.0.1/no_variable"}, - {"description", "The local server without variables"}, - } - } - }; - - // Setting Timeout has side effects (forces ApiClient creation). - Timeout = 100000; - } - - /// - /// Initializes a new instance of the class - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")] - public Configuration( - IDictionary defaultHeaders, - IDictionary apiKey, - IDictionary apiKeyPrefix, - string basePath = "http://petstore.swagger.io:80/v2") : this() - { - if (string.IsNullOrWhiteSpace(basePath)) - throw new ArgumentException("The provided basePath is invalid.", "basePath"); - if (defaultHeaders == null) - throw new ArgumentNullException("defaultHeaders"); - if (apiKey == null) - throw new ArgumentNullException("apiKey"); - if (apiKeyPrefix == null) - throw new ArgumentNullException("apiKeyPrefix"); - - BasePath = basePath; - - foreach (var keyValuePair in defaultHeaders) - { - DefaultHeaders.Add(keyValuePair); - } - - foreach (var keyValuePair in apiKey) - { - ApiKey.Add(keyValuePair); - } - - foreach (var keyValuePair in apiKeyPrefix) - { - ApiKeyPrefix.Add(keyValuePair); - } - } - - #endregion Constructors - - #region Properties - - /// - /// Gets or sets the base path for API access. - /// - public virtual string BasePath { - get { return _basePath; } - set { _basePath = value; } - } - - /// - /// Gets or sets the default header. - /// - [Obsolete("Use DefaultHeaders instead.")] - public virtual IDictionary DefaultHeader - { - get - { - return DefaultHeaders; - } - set - { - DefaultHeaders = value; - } - } - - /// - /// Gets or sets the default headers. - /// - public virtual IDictionary DefaultHeaders { get; set; } - - /// - /// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds. - /// - public virtual int Timeout { get; set; } - - /// - /// Gets or sets the proxy - /// - /// Proxy. - public virtual WebProxy Proxy { get; set; } - - /// - /// Gets or sets the HTTP user agent. - /// - /// Http user agent. - public virtual string UserAgent { get; set; } - - /// - /// Gets or sets the username (HTTP basic authentication). - /// - /// The username. - public virtual string Username { get; set; } - - /// - /// Gets or sets the password (HTTP basic authentication). - /// - /// The password. - public virtual string Password { get; set; } - - /// - /// Gets the API key with prefix. - /// - /// API key identifier (authentication scheme). - /// API key with prefix. - public string GetApiKeyWithPrefix(string apiKeyIdentifier) - { - string apiKeyValue; - ApiKey.TryGetValue(apiKeyIdentifier, out apiKeyValue); - string apiKeyPrefix; - if (ApiKeyPrefix.TryGetValue(apiKeyIdentifier, out apiKeyPrefix)) - { - return apiKeyPrefix + " " + apiKeyValue; - } - - return apiKeyValue; - } - - /// - /// Gets or sets certificate collection to be sent with requests. - /// - /// X509 Certificate collection. - public X509CertificateCollection ClientCertificates { get; set; } - - /// - /// Gets or sets the access token for OAuth2 authentication. - /// - /// This helper property simplifies code generation. - /// - /// The access token. - public virtual string AccessToken { get; set; } - - /// - /// Gets or sets the temporary folder path to store the files downloaded from the server. - /// - /// Folder path. - public virtual string TempFolderPath - { - get { return _tempFolderPath; } - - set - { - if (string.IsNullOrEmpty(value)) - { - _tempFolderPath = Path.GetTempPath(); - return; - } - - // create the directory if it does not exist - if (!Directory.Exists(value)) - { - Directory.CreateDirectory(value); - } - - // check if the path contains directory separator at the end - if (value[value.Length - 1] == Path.DirectorySeparatorChar) - { - _tempFolderPath = value; - } - else - { - _tempFolderPath = value + Path.DirectorySeparatorChar; - } - } - } - - /// - /// Gets or sets the date time format used when serializing in the ApiClient - /// By default, it's set to ISO 8601 - "o", for others see: - /// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx - /// and https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx - /// No validation is done to ensure that the string you're providing is valid - /// - /// The DateTimeFormat string - public virtual string DateTimeFormat - { - get { return _dateTimeFormat; } - set - { - if (string.IsNullOrEmpty(value)) - { - // Never allow a blank or null string, go back to the default - _dateTimeFormat = ISO8601_DATETIME_FORMAT; - return; - } - - // Caution, no validation when you choose date time format other than ISO 8601 - // Take a look at the above links - _dateTimeFormat = value; - } - } - - /// - /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name. - /// - /// Whatever you set here will be prepended to the value defined in AddApiKey. - /// - /// An example invocation here might be: - /// - /// ApiKeyPrefix["Authorization"] = "Bearer"; - /// - /// … where ApiKey["Authorization"] would then be used to set the value of your bearer token. - /// - /// - /// OAuth2 workflows should set tokens via AccessToken. - /// - /// - /// The prefix of the API key. - public virtual IDictionary ApiKeyPrefix - { - get { return _apiKeyPrefix; } - set - { - if (value == null) - { - throw new InvalidOperationException("ApiKeyPrefix collection may not be null."); - } - _apiKeyPrefix = value; - } - } - - /// - /// Gets or sets the API key based on the authentication name. - /// - /// The API key. - public virtual IDictionary ApiKey - { - get { return _apiKey; } - set - { - if (value == null) - { - throw new InvalidOperationException("ApiKey collection may not be null."); - } - _apiKey = value; - } - } - - /// - /// Gets or sets the servers. - /// - /// The servers. - public virtual IList> Servers - { - get { return _servers; } - set - { - if (value == null) - { - throw new InvalidOperationException("Servers may not be null."); - } - _servers = value; - } - } - - /// - /// Returns URL based on server settings without providing values - /// for the variables - /// - /// Array index of the server settings. - /// The server URL. - public string GetServerUrl(int index) - { - return GetServerUrl(index, null); - } - - /// - /// Returns URL based on server settings. - /// - /// Array index of the server settings. - /// Dictionary of the variables and the corresponding values. - /// The server URL. - public string GetServerUrl(int index, Dictionary inputVariables) - { - if (index < 0 || index >= Servers.Count) - { - throw new InvalidOperationException($"Invalid index {index} when selecting the server. Must be less than {Servers.Count}."); - } - - if (inputVariables == null) - { - inputVariables = new Dictionary(); - } - - IReadOnlyDictionary server = Servers[index]; - string url = (string)server["url"]; - - // go through variable and assign a value - foreach (KeyValuePair variable in (IReadOnlyDictionary)server["variables"]) - { - - IReadOnlyDictionary serverVariables = (IReadOnlyDictionary)(variable.Value); - - if (inputVariables.ContainsKey(variable.Key)) - { - if (((List)serverVariables["enum_values"]).Contains(inputVariables[variable.Key])) - { - url = url.Replace("{" + variable.Key + "}", inputVariables[variable.Key]); - } - else - { - throw new InvalidOperationException($"The variable `{variable.Key}` in the server URL has invalid value #{inputVariables[variable.Key]}. Must be {(List)serverVariables["enum_values"]}"); - } - } - else - { - // use defualt value - url = url.Replace("{" + variable.Key + "}", (string)serverVariables["default_value"]); - } - } - - return url; - } - - /// - /// Gets and Sets the HttpSigningConfiuration - /// - public HttpSigningConfiguration HttpSigningConfiguration - { - get { return _HttpSigningConfiguration; } - set { _HttpSigningConfiguration = value; } - } - - #endregion Properties - - #region Methods - - /// - /// Returns a string with essential information for debugging. - /// - public static String ToDebugReport() - { - String report = "C# SDK (Org.OpenAPITools) Debug Report:\n"; - report += " OS: " + System.Environment.OSVersion + "\n"; - report += " .NET Framework Version: " + System.Environment.Version + "\n"; - report += " Version of the API: 1.0.0\n"; - report += " SDK Package Version: 1.0.0\n"; - - return report; - } - - /// - /// Add Api Key Header. - /// - /// Api Key name. - /// Api Key value. - /// - public void AddApiKey(string key, string value) - { - ApiKey[key] = value; - } - - /// - /// Sets the API key prefix. - /// - /// Api Key name. - /// Api Key value. - public void AddApiKeyPrefix(string key, string value) - { - ApiKeyPrefix[key] = value; - } - - #endregion Methods - - #region Static Members - /// - /// Merge configurations. - /// - /// First configuration. - /// Second configuration. - /// Merged configuration. - public static IReadableConfiguration MergeConfigurations(IReadableConfiguration first, IReadableConfiguration second) - { - if (second == null) return first ?? GlobalConfiguration.Instance; - - Dictionary apiKey = first.ApiKey.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); - Dictionary apiKeyPrefix = first.ApiKeyPrefix.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); - Dictionary defaultHeaders = first.DefaultHeaders.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); - - foreach (var kvp in second.ApiKey) apiKey[kvp.Key] = kvp.Value; - foreach (var kvp in second.ApiKeyPrefix) apiKeyPrefix[kvp.Key] = kvp.Value; - foreach (var kvp in second.DefaultHeaders) defaultHeaders[kvp.Key] = kvp.Value; - - var config = new Configuration - { - ApiKey = apiKey, - ApiKeyPrefix = apiKeyPrefix, - DefaultHeaders = defaultHeaders, - BasePath = second.BasePath ?? first.BasePath, - Timeout = second.Timeout, - Proxy = second.Proxy ?? first.Proxy, - UserAgent = second.UserAgent ?? first.UserAgent, - Username = second.Username ?? first.Username, - Password = second.Password ?? first.Password, - AccessToken = second.AccessToken ?? first.AccessToken, - HttpSigningConfiguration = second.HttpSigningConfiguration ?? first.HttpSigningConfiguration, - TempFolderPath = second.TempFolderPath ?? first.TempFolderPath, - DateTimeFormat = second.DateTimeFormat ?? first.DateTimeFormat - }; - return config; - } - #endregion Static Members - } -} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/GlobalConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/GlobalConfiguration.cs index 4bc467ffa40c..e69de29bb2d1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/GlobalConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/GlobalConfiguration.cs @@ -1,67 +0,0 @@ -/* - * OpenAPI Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * The version of the OpenAPI document: 1.0.0 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System.Collections.Generic; - -namespace Org.OpenAPITools.Client -{ - /// - /// provides a compile-time extension point for globally configuring - /// API Clients. - /// - /// - /// A customized implementation via partial class may reside in another file and may - /// be excluded from automatic generation via a .openapi-generator-ignore file. - /// - public partial class GlobalConfiguration : Configuration - { - #region Private Members - - private static readonly object GlobalConfigSync = new { }; - private static IReadableConfiguration _globalConfiguration; - - #endregion Private Members - - #region Constructors - - /// - private GlobalConfiguration() - { - } - - /// - public GlobalConfiguration(IDictionary defaultHeader, IDictionary apiKey, IDictionary apiKeyPrefix, string basePath = "http://localhost:3000/api") : base(defaultHeader, apiKey, apiKeyPrefix, basePath) - { - } - - static GlobalConfiguration() - { - Instance = new GlobalConfiguration(); - } - - #endregion Constructors - - /// - /// Gets or sets the default Configuration. - /// - /// Configuration. - public static IReadableConfiguration Instance - { - get { return _globalConfiguration; } - set - { - lock (GlobalConfigSync) - { - _globalConfiguration = value; - } - } - } - } -} \ No newline at end of file diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/RetryConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/RetryConfiguration.cs index c93633a36d93..e69de29bb2d1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/RetryConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/RetryConfiguration.cs @@ -1,21 +0,0 @@ -using Polly; -using RestSharp; - -namespace Org.OpenAPITools.Client -{ - /// - /// Configuration class to set the polly retry policies to be applied to the requests. - /// - public class RetryConfiguration - { - /// - /// Retry policy - /// - public static Policy RetryPolicy { get; set; } - - /// - /// Async retry policy - /// - public static AsyncPolicy AsyncRetryPolicy { get; set; } - } -} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index 5f212ec734f2..6b0d8561ef24 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -43,17 +40,17 @@ public partial class AdditionalPropertiesClass : IEquatablemapWithUndeclaredPropertiesAnytype3. /// an object with no declared properties and no undeclared properties, hence it's an empty map.. /// mapWithUndeclaredPropertiesString. - public AdditionalPropertiesClass(Dictionary mapProperty = default(Dictionary), Dictionary> mapOfMapProperty = default(Dictionary>), Object anytype1 = default(Object), Object mapWithUndeclaredPropertiesAnytype1 = default(Object), Object mapWithUndeclaredPropertiesAnytype2 = default(Object), Dictionary mapWithUndeclaredPropertiesAnytype3 = default(Dictionary), Object emptyMap = default(Object), Dictionary mapWithUndeclaredPropertiesString = default(Dictionary)) + public AdditionalPropertiesClass(Dictionary mapProperty, Dictionary> mapOfMapProperty, Object anytype1, Object mapWithUndeclaredPropertiesAnytype1, Object mapWithUndeclaredPropertiesAnytype2, Dictionary mapWithUndeclaredPropertiesAnytype3, Object emptyMap, Dictionary mapWithUndeclaredPropertiesString) { - this.MapProperty = mapProperty; - this.MapOfMapProperty = mapOfMapProperty; - this.Anytype1 = anytype1; - this.MapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1; - this.MapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2; - this.MapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3; - this.EmptyMap = emptyMap; - this.MapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString; - this.AdditionalProperties = new Dictionary(); + MapProperty = mapProperty; + MapOfMapProperty = mapOfMapProperty; + Anytype1 = anytype1; + MapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1; + MapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2; + MapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3; + EmptyMap = emptyMap; + MapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString; + AdditionalProperties = new Dictionary(); } /// @@ -119,15 +116,15 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class AdditionalPropertiesClass {\n"); - sb.Append(" MapProperty: ").Append(MapProperty).Append("\n"); - sb.Append(" MapOfMapProperty: ").Append(MapOfMapProperty).Append("\n"); - sb.Append(" Anytype1: ").Append(Anytype1).Append("\n"); - sb.Append(" MapWithUndeclaredPropertiesAnytype1: ").Append(MapWithUndeclaredPropertiesAnytype1).Append("\n"); - sb.Append(" MapWithUndeclaredPropertiesAnytype2: ").Append(MapWithUndeclaredPropertiesAnytype2).Append("\n"); - sb.Append(" MapWithUndeclaredPropertiesAnytype3: ").Append(MapWithUndeclaredPropertiesAnytype3).Append("\n"); - sb.Append(" EmptyMap: ").Append(EmptyMap).Append("\n"); - sb.Append(" MapWithUndeclaredPropertiesString: ").Append(MapWithUndeclaredPropertiesString).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" MapProperty: ").Append(MapProperty).Append('\n'); + sb.Append(" MapOfMapProperty: ").Append(MapOfMapProperty).Append('\n'); + sb.Append(" Anytype1: ").Append(Anytype1).Append('\n'); + sb.Append(" MapWithUndeclaredPropertiesAnytype1: ").Append(MapWithUndeclaredPropertiesAnytype1).Append('\n'); + sb.Append(" MapWithUndeclaredPropertiesAnytype2: ").Append(MapWithUndeclaredPropertiesAnytype2).Append('\n'); + sb.Append(" MapWithUndeclaredPropertiesAnytype3: ").Append(MapWithUndeclaredPropertiesAnytype3).Append('\n'); + sb.Append(" EmptyMap: ").Append(EmptyMap).Append('\n'); + sb.Append(" MapWithUndeclaredPropertiesString: ").Append(MapWithUndeclaredPropertiesString).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -136,9 +133,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -146,7 +143,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as AdditionalPropertiesClass).AreEqual; } @@ -156,42 +153,11 @@ public override bool Equals(object input) /// /// Instance of AdditionalPropertiesClass to be compared /// Boolean - public bool Equals(AdditionalPropertiesClass input) + public bool Equals(AdditionalPropertiesClass? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.MapProperty != null) - hashCode = hashCode * 59 + this.MapProperty.GetHashCode(); - if (this.MapOfMapProperty != null) - hashCode = hashCode * 59 + this.MapOfMapProperty.GetHashCode(); - if (this.Anytype1 != null) - hashCode = hashCode * 59 + this.Anytype1.GetHashCode(); - if (this.MapWithUndeclaredPropertiesAnytype1 != null) - hashCode = hashCode * 59 + this.MapWithUndeclaredPropertiesAnytype1.GetHashCode(); - if (this.MapWithUndeclaredPropertiesAnytype2 != null) - hashCode = hashCode * 59 + this.MapWithUndeclaredPropertiesAnytype2.GetHashCode(); - if (this.MapWithUndeclaredPropertiesAnytype3 != null) - hashCode = hashCode * 59 + this.MapWithUndeclaredPropertiesAnytype3.GetHashCode(); - if (this.EmptyMap != null) - hashCode = hashCode * 59 + this.EmptyMap.GetHashCode(); - if (this.MapWithUndeclaredPropertiesString != null) - hashCode = hashCode * 59 + this.MapWithUndeclaredPropertiesString.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Animal.cs index 95c79122ad70..f1f0d480c74a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Animal.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; @@ -31,7 +28,7 @@ namespace Org.OpenAPITools.Model /// Animal /// [DataContract(Name = "Animal")] - [JsonConverter(typeof(JsonSubtypes), "ClassName")] + [Newtonsoft.Json.JsonConverter(typeof(JsonSubtypes), "ClassName")] [JsonSubtypes.KnownSubType(typeof(Cat), "Cat")] [JsonSubtypes.KnownSubType(typeof(Dog), "Dog")] public partial class Animal : IEquatable, IValidatableObject @@ -44,18 +41,20 @@ protected Animal() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// className (required). /// color (default to "red"). - public Animal(string className = default(string), string color = "red") + public Animal(string className, string color) { // to ensure "className" is required (not null) - this.ClassName = className ?? throw new ArgumentNullException("className is a required property for Animal and cannot be null"); + ClassName = className ?? throw new ArgumentNullException("className is a required property for Animal and cannot be null"); + // use default value if no "color" provided - this.Color = color ?? "red"; - this.AdditionalProperties = new Dictionary(); + Color = color ?? "red"; + AdditionalProperties = new Dictionary(); } /// @@ -84,9 +83,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Animal {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); - sb.Append(" Color: ").Append(Color).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ClassName: ").Append(ClassName).Append('\n'); + sb.Append(" Color: ").Append(Color).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -95,9 +94,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -105,7 +104,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Animal).AreEqual; } @@ -115,30 +114,11 @@ public override bool Equals(object input) /// /// Instance of Animal to be compared /// Boolean - public bool Equals(Animal input) + public bool Equals(Animal? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.ClassName != null) - hashCode = hashCode * 59 + this.ClassName.GetHashCode(); - if (this.Color != null) - hashCode = hashCode * 59 + this.Color.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ApiResponse.cs index c9a0a78efa72..6db3dd805658 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -38,12 +35,12 @@ public partial class ApiResponse : IEquatable, IValidatableObject /// code. /// type. /// message. - public ApiResponse(int code = default(int), string type = default(string), string message = default(string)) + public ApiResponse(int code, string type, string message) { - this.Code = code; - this.Type = type; - this.Message = message; - this.AdditionalProperties = new Dictionary(); + Code = code; + Type = type; + Message = message; + AdditionalProperties = new Dictionary(); } /// @@ -78,10 +75,10 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ApiResponse {\n"); - sb.Append(" Code: ").Append(Code).Append("\n"); - sb.Append(" Type: ").Append(Type).Append("\n"); - sb.Append(" Message: ").Append(Message).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Code: ").Append(Code).Append('\n'); + sb.Append(" Type: ").Append(Type).Append('\n'); + sb.Append(" Message: ").Append(Message).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -90,9 +87,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -100,7 +97,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ApiResponse).AreEqual; } @@ -110,31 +107,11 @@ public override bool Equals(object input) /// /// Instance of ApiResponse to be compared /// Boolean - public bool Equals(ApiResponse input) + public bool Equals(ApiResponse? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Code.GetHashCode(); - if (this.Type != null) - hashCode = hashCode * 59 + this.Type.GetHashCode(); - if (this.Message != null) - hashCode = hashCode * 59 + this.Message.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Apple.cs index b414d3021a66..d31a6896b523 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Apple.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -37,11 +34,11 @@ public partial class Apple : IEquatable, IValidatableObject /// /// cultivar. /// origin. - public Apple(string cultivar = default(string), string origin = default(string)) + public Apple(string cultivar, string origin) { - this.Cultivar = cultivar; - this.Origin = origin; - this.AdditionalProperties = new Dictionary(); + Cultivar = cultivar; + Origin = origin; + AdditionalProperties = new Dictionary(); } /// @@ -70,9 +67,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Apple {\n"); - sb.Append(" Cultivar: ").Append(Cultivar).Append("\n"); - sb.Append(" Origin: ").Append(Origin).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Cultivar: ").Append(Cultivar).Append('\n'); + sb.Append(" Origin: ").Append(Origin).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -81,9 +78,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -91,7 +88,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Apple).AreEqual; } @@ -101,30 +98,11 @@ public override bool Equals(object input) /// /// Instance of Apple to be compared /// Boolean - public bool Equals(Apple input) + public bool Equals(Apple? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Cultivar != null) - hashCode = hashCode * 59 + this.Cultivar.GetHashCode(); - if (this.Origin != null) - hashCode = hashCode * 59 + this.Origin.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AppleReq.cs index 7501463d8012..450159efe5f2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AppleReq.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -42,11 +39,12 @@ protected AppleReq() { } /// /// cultivar (required). /// mealy. - public AppleReq(string cultivar = default(string), bool mealy = default(bool)) + public AppleReq(string cultivar, bool mealy) { // to ensure "cultivar" is required (not null) - this.Cultivar = cultivar ?? throw new ArgumentNullException("cultivar is a required property for AppleReq and cannot be null"); - this.Mealy = mealy; + Cultivar = cultivar ?? throw new ArgumentNullException("cultivar is a required property for AppleReq and cannot be null"); + + Mealy = mealy; } /// @@ -69,8 +67,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class AppleReq {\n"); - sb.Append(" Cultivar: ").Append(Cultivar).Append("\n"); - sb.Append(" Mealy: ").Append(Mealy).Append("\n"); + sb.Append(" Cultivar: ").Append(Cultivar).Append('\n'); + sb.Append(" Mealy: ").Append(Mealy).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -79,9 +77,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -89,7 +87,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as AppleReq).AreEqual; } @@ -99,27 +97,11 @@ public override bool Equals(object input) /// /// Instance of AppleReq to be compared /// Boolean - public bool Equals(AppleReq input) + public bool Equals(AppleReq? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Cultivar != null) - hashCode = hashCode * 59 + this.Cultivar.GetHashCode(); - hashCode = hashCode * 59 + this.Mealy.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index bf2c8663ff64..7158c0fb9ea8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class ArrayOfArrayOfNumberOnly : IEquatable class. /// /// arrayArrayNumber. - public ArrayOfArrayOfNumberOnly(List> arrayArrayNumber = default(List>)) + public ArrayOfArrayOfNumberOnly(List> arrayArrayNumber) { - this.ArrayArrayNumber = arrayArrayNumber; - this.AdditionalProperties = new Dictionary(); + ArrayArrayNumber = arrayArrayNumber; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ArrayOfArrayOfNumberOnly {\n"); - sb.Append(" ArrayArrayNumber: ").Append(ArrayArrayNumber).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ArrayArrayNumber: ").Append(ArrayArrayNumber).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ArrayOfArrayOfNumberOnly).AreEqual; } @@ -92,28 +89,11 @@ public override bool Equals(object input) /// /// Instance of ArrayOfArrayOfNumberOnly to be compared /// Boolean - public bool Equals(ArrayOfArrayOfNumberOnly input) + public bool Equals(ArrayOfArrayOfNumberOnly? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.ArrayArrayNumber != null) - hashCode = hashCode * 59 + this.ArrayArrayNumber.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index 09a9bbb88500..954241248cd7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class ArrayOfNumberOnly : IEquatable, IValidat /// Initializes a new instance of the class. /// /// arrayNumber. - public ArrayOfNumberOnly(List arrayNumber = default(List)) + public ArrayOfNumberOnly(List arrayNumber) { - this.ArrayNumber = arrayNumber; - this.AdditionalProperties = new Dictionary(); + ArrayNumber = arrayNumber; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ArrayOfNumberOnly {\n"); - sb.Append(" ArrayNumber: ").Append(ArrayNumber).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ArrayNumber: ").Append(ArrayNumber).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ArrayOfNumberOnly).AreEqual; } @@ -92,28 +89,11 @@ public override bool Equals(object input) /// /// Instance of ArrayOfNumberOnly to be compared /// Boolean - public bool Equals(ArrayOfNumberOnly input) + public bool Equals(ArrayOfNumberOnly? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.ArrayNumber != null) - hashCode = hashCode * 59 + this.ArrayNumber.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayTest.cs index 4406ffb33ea8..a8aaae06b3dd 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -38,12 +35,12 @@ public partial class ArrayTest : IEquatable, IValidatableObject /// arrayOfString. /// arrayArrayOfInteger. /// arrayArrayOfModel. - public ArrayTest(List arrayOfString = default(List), List> arrayArrayOfInteger = default(List>), List> arrayArrayOfModel = default(List>)) + public ArrayTest(List arrayOfString, List> arrayArrayOfInteger, List> arrayArrayOfModel) { - this.ArrayOfString = arrayOfString; - this.ArrayArrayOfInteger = arrayArrayOfInteger; - this.ArrayArrayOfModel = arrayArrayOfModel; - this.AdditionalProperties = new Dictionary(); + ArrayOfString = arrayOfString; + ArrayArrayOfInteger = arrayArrayOfInteger; + ArrayArrayOfModel = arrayArrayOfModel; + AdditionalProperties = new Dictionary(); } /// @@ -78,10 +75,10 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ArrayTest {\n"); - sb.Append(" ArrayOfString: ").Append(ArrayOfString).Append("\n"); - sb.Append(" ArrayArrayOfInteger: ").Append(ArrayArrayOfInteger).Append("\n"); - sb.Append(" ArrayArrayOfModel: ").Append(ArrayArrayOfModel).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ArrayOfString: ").Append(ArrayOfString).Append('\n'); + sb.Append(" ArrayArrayOfInteger: ").Append(ArrayArrayOfInteger).Append('\n'); + sb.Append(" ArrayArrayOfModel: ").Append(ArrayArrayOfModel).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -90,9 +87,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -100,7 +97,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ArrayTest).AreEqual; } @@ -110,32 +107,11 @@ public override bool Equals(object input) /// /// Instance of ArrayTest to be compared /// Boolean - public bool Equals(ArrayTest input) + public bool Equals(ArrayTest? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.ArrayOfString != null) - hashCode = hashCode * 59 + this.ArrayOfString.GetHashCode(); - if (this.ArrayArrayOfInteger != null) - hashCode = hashCode * 59 + this.ArrayArrayOfInteger.GetHashCode(); - if (this.ArrayArrayOfModel != null) - hashCode = hashCode * 59 + this.ArrayArrayOfModel.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Banana.cs index a7513bb453af..659de37a23cd 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Banana.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class Banana : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// /// lengthCm. - public Banana(decimal lengthCm = default(decimal)) + public Banana(decimal lengthCm) { - this.LengthCm = lengthCm; - this.AdditionalProperties = new Dictionary(); + LengthCm = lengthCm; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Banana {\n"); - sb.Append(" LengthCm: ").Append(LengthCm).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" LengthCm: ").Append(LengthCm).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Banana).AreEqual; } @@ -92,27 +89,11 @@ public override bool Equals(object input) /// /// Instance of Banana to be compared /// Boolean - public bool Equals(Banana input) + public bool Equals(Banana? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.LengthCm.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BananaReq.cs index 6e7c0c7fb3bd..15fa5f0861f2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BananaReq.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -42,10 +39,11 @@ protected BananaReq() { } /// /// lengthCm (required). /// sweet. - public BananaReq(decimal lengthCm = default(decimal), bool sweet = default(bool)) + public BananaReq(decimal lengthCm, bool sweet) { - this.LengthCm = lengthCm; - this.Sweet = sweet; + LengthCm = lengthCm; + + Sweet = sweet; } /// @@ -68,8 +66,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class BananaReq {\n"); - sb.Append(" LengthCm: ").Append(LengthCm).Append("\n"); - sb.Append(" Sweet: ").Append(Sweet).Append("\n"); + sb.Append(" LengthCm: ").Append(LengthCm).Append('\n'); + sb.Append(" Sweet: ").Append(Sweet).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -78,9 +76,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -88,7 +86,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as BananaReq).AreEqual; } @@ -98,26 +96,11 @@ public override bool Equals(object input) /// /// Instance of BananaReq to be compared /// Boolean - public bool Equals(BananaReq input) + public bool Equals(BananaReq? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.LengthCm.GetHashCode(); - hashCode = hashCode * 59 + this.Sweet.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BasquePig.cs index 5c6f9a0e83db..0abea7b796fe 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BasquePig.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,15 +37,17 @@ protected BasquePig() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// className (required). - public BasquePig(string className = default(string)) + public BasquePig(string className) { // to ensure "className" is required (not null) - this.ClassName = className ?? throw new ArgumentNullException("className is a required property for BasquePig and cannot be null"); - this.AdditionalProperties = new Dictionary(); + ClassName = className ?? throw new ArgumentNullException("className is a required property for BasquePig and cannot be null"); + + AdditionalProperties = new Dictionary(); } /// @@ -71,8 +70,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class BasquePig {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ClassName: ").Append(ClassName).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -81,9 +80,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -91,7 +90,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as BasquePig).AreEqual; } @@ -101,28 +100,11 @@ public override bool Equals(object input) /// /// Instance of BasquePig to be compared /// Boolean - public bool Equals(BasquePig input) + public bool Equals(BasquePig? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.ClassName != null) - hashCode = hashCode * 59 + this.ClassName.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Capitalization.cs index a4ab27bd8986..0151b64a90a4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Capitalization.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -41,15 +38,15 @@ public partial class Capitalization : IEquatable, IValidatableOb /// capitalSnake. /// sCAETHFlowPoints. /// Name of the pet . - public Capitalization(string smallCamel = default(string), string capitalCamel = default(string), string smallSnake = default(string), string capitalSnake = default(string), string sCAETHFlowPoints = default(string), string aTTNAME = default(string)) + public Capitalization(string smallCamel, string capitalCamel, string smallSnake, string capitalSnake, string sCAETHFlowPoints, string aTTNAME) { - this.SmallCamel = smallCamel; - this.CapitalCamel = capitalCamel; - this.SmallSnake = smallSnake; - this.CapitalSnake = capitalSnake; - this.SCAETHFlowPoints = sCAETHFlowPoints; - this.ATT_NAME = aTTNAME; - this.AdditionalProperties = new Dictionary(); + SmallCamel = smallCamel; + CapitalCamel = capitalCamel; + SmallSnake = smallSnake; + CapitalSnake = capitalSnake; + SCAETHFlowPoints = sCAETHFlowPoints; + ATT_NAME = aTTNAME; + AdditionalProperties = new Dictionary(); } /// @@ -103,13 +100,13 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Capitalization {\n"); - sb.Append(" SmallCamel: ").Append(SmallCamel).Append("\n"); - sb.Append(" CapitalCamel: ").Append(CapitalCamel).Append("\n"); - sb.Append(" SmallSnake: ").Append(SmallSnake).Append("\n"); - sb.Append(" CapitalSnake: ").Append(CapitalSnake).Append("\n"); - sb.Append(" SCAETHFlowPoints: ").Append(SCAETHFlowPoints).Append("\n"); - sb.Append(" ATT_NAME: ").Append(ATT_NAME).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" SmallCamel: ").Append(SmallCamel).Append('\n'); + sb.Append(" CapitalCamel: ").Append(CapitalCamel).Append('\n'); + sb.Append(" SmallSnake: ").Append(SmallSnake).Append('\n'); + sb.Append(" CapitalSnake: ").Append(CapitalSnake).Append('\n'); + sb.Append(" SCAETHFlowPoints: ").Append(SCAETHFlowPoints).Append('\n'); + sb.Append(" ATT_NAME: ").Append(ATT_NAME).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -118,9 +115,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -128,7 +125,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Capitalization).AreEqual; } @@ -138,38 +135,11 @@ public override bool Equals(object input) /// /// Instance of Capitalization to be compared /// Boolean - public bool Equals(Capitalization input) + public bool Equals(Capitalization? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.SmallCamel != null) - hashCode = hashCode * 59 + this.SmallCamel.GetHashCode(); - if (this.CapitalCamel != null) - hashCode = hashCode * 59 + this.CapitalCamel.GetHashCode(); - if (this.SmallSnake != null) - hashCode = hashCode * 59 + this.SmallSnake.GetHashCode(); - if (this.CapitalSnake != null) - hashCode = hashCode * 59 + this.CapitalSnake.GetHashCode(); - if (this.SCAETHFlowPoints != null) - hashCode = hashCode * 59 + this.SCAETHFlowPoints.GetHashCode(); - if (this.ATT_NAME != null) - hashCode = hashCode * 59 + this.ATT_NAME.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Cat.cs index 1c6fa0f4220b..a515ed0423d7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Cat.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; @@ -31,7 +28,7 @@ namespace Org.OpenAPITools.Model /// Cat /// [DataContract(Name = "Cat")] - [JsonConverter(typeof(JsonSubtypes), "ClassName")] + [Newtonsoft.Json.JsonConverter(typeof(JsonSubtypes), "ClassName")] public partial class Cat : Animal, IEquatable, IValidatableObject { /// @@ -42,16 +39,17 @@ protected Cat() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// declawed. /// className (required) (default to "Cat"). /// color (default to "red"). - public Cat(bool declawed = default(bool), string className = "Cat", string color = "red") : base(className, color) + public Cat(bool declawed, string className, string color) : base(className, color) { - this.Declawed = declawed; - this.AdditionalProperties = new Dictionary(); + Declawed = declawed; + AdditionalProperties = new Dictionary(); } /// @@ -74,9 +72,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Cat {\n"); - sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" Declawed: ").Append(Declawed).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append('\n'); + sb.Append(" Declawed: ").Append(Declawed).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -85,9 +83,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public override string ToJson() + public override string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -95,7 +93,7 @@ public override string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Cat).AreEqual; } @@ -105,27 +103,11 @@ public override bool Equals(object input) /// /// Instance of Cat to be compared /// Boolean - public bool Equals(Cat input) + public bool Equals(Cat? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = base.GetHashCode(); - hashCode = hashCode * 59 + this.Declawed.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/CatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/CatAllOf.cs index ed6a94eedebc..4fcfa372ce05 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/CatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/CatAllOf.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class CatAllOf : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// /// declawed. - public CatAllOf(bool declawed = default(bool)) + public CatAllOf(bool declawed) { - this.Declawed = declawed; - this.AdditionalProperties = new Dictionary(); + Declawed = declawed; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class CatAllOf {\n"); - sb.Append(" Declawed: ").Append(Declawed).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Declawed: ").Append(Declawed).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as CatAllOf).AreEqual; } @@ -92,27 +89,11 @@ public override bool Equals(object input) /// /// Instance of CatAllOf to be compared /// Boolean - public bool Equals(CatAllOf input) + public bool Equals(CatAllOf? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Declawed.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Category.cs index 581a23ef2a59..4dbf9b46f2a7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Category.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,17 +37,19 @@ protected Category() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// id. /// name (required) (default to "default-name"). - public Category(long id = default(long), string name = "default-name") + public Category(long id, string name) { // to ensure "name" is required (not null) - this.Name = name ?? throw new ArgumentNullException("name is a required property for Category and cannot be null"); - this.Id = id; - this.AdditionalProperties = new Dictionary(); + Name = name ?? throw new ArgumentNullException("name is a required property for Category and cannot be null"); + + Id = id; + AdditionalProperties = new Dictionary(); } /// @@ -79,9 +78,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Category {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Id: ").Append(Id).Append('\n'); + sb.Append(" Name: ").Append(Name).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -90,9 +89,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -100,7 +99,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Category).AreEqual; } @@ -110,29 +109,11 @@ public override bool Equals(object input) /// /// Instance of Category to be compared /// Boolean - public bool Equals(Category input) + public bool Equals(Category? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs index 8c2d77ca45d0..c2f313b71dfd 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; @@ -31,13 +28,13 @@ namespace Org.OpenAPITools.Model /// ChildCat /// [DataContract(Name = "ChildCat")] - [JsonConverter(typeof(JsonSubtypes), "PetType")] + [Newtonsoft.Json.JsonConverter(typeof(JsonSubtypes), "PetType")] public partial class ChildCat : ParentPet, IEquatable, IValidatableObject { /// /// Defines PetType /// - [JsonConverter(typeof(StringEnumConverter))] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public enum PetTypeEnum { /// @@ -53,6 +50,7 @@ public enum PetTypeEnum /// [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = false)] public PetTypeEnum PetType { get; set; } + /// /// Initializes a new instance of the class. /// @@ -61,16 +59,18 @@ protected ChildCat() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// name. /// petType (required) (default to PetTypeEnum.ChildCat). - public ChildCat(string name = default(string), PetTypeEnum petType = PetTypeEnum.ChildCat) : base() + public ChildCat(string name, PetTypeEnum petType) : base() { - this.PetType = petType; - this.Name = name; - this.AdditionalProperties = new Dictionary(); + PetType = petType; + + Name = name; + AdditionalProperties = new Dictionary(); } /// @@ -93,10 +93,10 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ChildCat {\n"); - sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append('\n'); + sb.Append(" Name: ").Append(Name).Append('\n'); + sb.Append(" PetType: ").Append(PetType).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -105,9 +105,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public override string ToJson() + public override string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -115,7 +115,7 @@ public override string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ChildCat).AreEqual; } @@ -125,29 +125,11 @@ public override bool Equals(object input) /// /// Instance of ChildCat to be compared /// Boolean - public bool Equals(ChildCat input) + public bool Equals(ChildCat? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = base.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.PetType.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs index a8a0e05b660f..84dd1d83b5de 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -35,7 +32,7 @@ public partial class ChildCatAllOf : IEquatable, IValidatableObje /// /// Defines PetType /// - [JsonConverter(typeof(StringEnumConverter))] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public enum PetTypeEnum { /// @@ -51,16 +48,17 @@ public enum PetTypeEnum /// [DataMember(Name = "pet_type", EmitDefaultValue = false)] public PetTypeEnum? PetType { get; set; } + /// /// Initializes a new instance of the class. /// /// name. /// petType (default to PetTypeEnum.ChildCat). - public ChildCatAllOf(string name = default(string), PetTypeEnum? petType = PetTypeEnum.ChildCat) + public ChildCatAllOf(string name, PetTypeEnum? petType) { - this.Name = name; - this.PetType = petType; - this.AdditionalProperties = new Dictionary(); + Name = name; + PetType = petType; + AdditionalProperties = new Dictionary(); } /// @@ -83,9 +81,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ChildCatAllOf {\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Name: ").Append(Name).Append('\n'); + sb.Append(" PetType: ").Append(PetType).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -94,9 +92,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -104,7 +102,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ChildCatAllOf).AreEqual; } @@ -114,29 +112,11 @@ public override bool Equals(object input) /// /// Instance of ChildCatAllOf to be compared /// Boolean - public bool Equals(ChildCatAllOf input) + public bool Equals(ChildCatAllOf? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.PetType.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ClassModel.cs index bb2121cd5177..27a976b9f85d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ClassModel.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class ClassModel : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// /// _class. - public ClassModel(string _class = default(string)) + public ClassModel(string _class) { - this.Class = _class; - this.AdditionalProperties = new Dictionary(); + Class = _class; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ClassModel {\n"); - sb.Append(" Class: ").Append(Class).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Class: ").Append(Class).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ClassModel).AreEqual; } @@ -92,28 +89,11 @@ public override bool Equals(object input) /// /// Instance of ClassModel to be compared /// Boolean - public bool Equals(ClassModel input) + public bool Equals(ClassModel? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Class != null) - hashCode = hashCode * 59 + this.Class.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index 78f3c6c03e3a..cf08aa6da742 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,18 +37,21 @@ protected ComplexQuadrilateral() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// shapeType (required). /// quadrilateralType (required). - public ComplexQuadrilateral(string shapeType = default(string), string quadrilateralType = default(string)) + public ComplexQuadrilateral(string shapeType, string quadrilateralType) { // to ensure "shapeType" is required (not null) - this.ShapeType = shapeType ?? throw new ArgumentNullException("shapeType is a required property for ComplexQuadrilateral and cannot be null"); + ShapeType = shapeType ?? throw new ArgumentNullException("shapeType is a required property for ComplexQuadrilateral and cannot be null"); + // to ensure "quadrilateralType" is required (not null) - this.QuadrilateralType = quadrilateralType ?? throw new ArgumentNullException("quadrilateralType is a required property for ComplexQuadrilateral and cannot be null"); - this.AdditionalProperties = new Dictionary(); + QuadrilateralType = quadrilateralType ?? throw new ArgumentNullException("quadrilateralType is a required property for ComplexQuadrilateral and cannot be null"); + + AdditionalProperties = new Dictionary(); } /// @@ -80,9 +80,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ComplexQuadrilateral {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append('\n'); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -91,9 +91,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -101,7 +101,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ComplexQuadrilateral).AreEqual; } @@ -111,30 +111,11 @@ public override bool Equals(object input) /// /// Instance of ComplexQuadrilateral to be compared /// Boolean - public bool Equals(ComplexQuadrilateral input) + public bool Equals(ComplexQuadrilateral? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.ShapeType != null) - hashCode = hashCode * 59 + this.ShapeType.GetHashCode(); - if (this.QuadrilateralType != null) - hashCode = hashCode * 59 + this.QuadrilateralType.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DanishPig.cs index dd2de1d038a5..db3304315360 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DanishPig.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,15 +37,17 @@ protected DanishPig() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// className (required). - public DanishPig(string className = default(string)) + public DanishPig(string className) { // to ensure "className" is required (not null) - this.ClassName = className ?? throw new ArgumentNullException("className is a required property for DanishPig and cannot be null"); - this.AdditionalProperties = new Dictionary(); + ClassName = className ?? throw new ArgumentNullException("className is a required property for DanishPig and cannot be null"); + + AdditionalProperties = new Dictionary(); } /// @@ -71,8 +70,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class DanishPig {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ClassName: ").Append(ClassName).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -81,9 +80,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -91,7 +90,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as DanishPig).AreEqual; } @@ -101,28 +100,11 @@ public override bool Equals(object input) /// /// Instance of DanishPig to be compared /// Boolean - public bool Equals(DanishPig input) + public bool Equals(DanishPig? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.ClassName != null) - hashCode = hashCode * 59 + this.ClassName.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Dog.cs index 1ff9ab1624dc..524fb65920ca 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Dog.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; @@ -31,7 +28,7 @@ namespace Org.OpenAPITools.Model /// Dog /// [DataContract(Name = "Dog")] - [JsonConverter(typeof(JsonSubtypes), "ClassName")] + [Newtonsoft.Json.JsonConverter(typeof(JsonSubtypes), "ClassName")] public partial class Dog : Animal, IEquatable, IValidatableObject { /// @@ -42,16 +39,17 @@ protected Dog() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// breed. /// className (required) (default to "Dog"). /// color (default to "red"). - public Dog(string breed = default(string), string className = "Dog", string color = "red") : base(className, color) + public Dog(string breed, string className, string color) : base(className, color) { - this.Breed = breed; - this.AdditionalProperties = new Dictionary(); + Breed = breed; + AdditionalProperties = new Dictionary(); } /// @@ -74,9 +72,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Dog {\n"); - sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" Breed: ").Append(Breed).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append('\n'); + sb.Append(" Breed: ").Append(Breed).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -85,9 +83,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public override string ToJson() + public override string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -95,7 +93,7 @@ public override string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Dog).AreEqual; } @@ -105,28 +103,11 @@ public override bool Equals(object input) /// /// Instance of Dog to be compared /// Boolean - public bool Equals(Dog input) + public bool Equals(Dog? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = base.GetHashCode(); - if (this.Breed != null) - hashCode = hashCode * 59 + this.Breed.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DogAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DogAllOf.cs index cd2f1a0eeecc..07a08559f4e8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DogAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DogAllOf.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class DogAllOf : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// /// breed. - public DogAllOf(string breed = default(string)) + public DogAllOf(string breed) { - this.Breed = breed; - this.AdditionalProperties = new Dictionary(); + Breed = breed; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class DogAllOf {\n"); - sb.Append(" Breed: ").Append(Breed).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Breed: ").Append(Breed).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as DogAllOf).AreEqual; } @@ -92,28 +89,11 @@ public override bool Equals(object input) /// /// Instance of DogAllOf to be compared /// Boolean - public bool Equals(DogAllOf input) + public bool Equals(DogAllOf? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Breed != null) - hashCode = hashCode * 59 + this.Breed.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs index 28e2ea556933..32e37eaeb8fa 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -39,12 +36,12 @@ public partial class Drawing : Dictionary, IEquatable, I /// shapeOrNull. /// nullableShape. /// shapes. - public Drawing(Shape mainShape = default(Shape), ShapeOrNull shapeOrNull = default(ShapeOrNull), NullableShape nullableShape = default(NullableShape), List shapes = default(List)) : base() + public Drawing(Shape mainShape, ShapeOrNull shapeOrNull, NullableShape nullableShape, List shapes) : base() { - this.MainShape = mainShape; - this.ShapeOrNull = shapeOrNull; - this.NullableShape = nullableShape; - this.Shapes = shapes; + MainShape = mainShape; + ShapeOrNull = shapeOrNull; + NullableShape = nullableShape; + Shapes = shapes; } /// @@ -79,11 +76,11 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Drawing {\n"); - sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" MainShape: ").Append(MainShape).Append("\n"); - sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); - sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); - sb.Append(" Shapes: ").Append(Shapes).Append("\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append('\n'); + sb.Append(" MainShape: ").Append(MainShape).Append('\n'); + sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append('\n'); + sb.Append(" NullableShape: ").Append(NullableShape).Append('\n'); + sb.Append(" Shapes: ").Append(Shapes).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -92,9 +89,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public string ToJson() + public string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -102,7 +99,7 @@ public string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Drawing).AreEqual; } @@ -112,32 +109,11 @@ public override bool Equals(object input) /// /// Instance of Drawing to be compared /// Boolean - public bool Equals(Drawing input) + public bool Equals(Drawing? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = base.GetHashCode(); - if (this.MainShape != null) - hashCode = hashCode * 59 + this.MainShape.GetHashCode(); - if (this.ShapeOrNull != null) - hashCode = hashCode * 59 + this.ShapeOrNull.GetHashCode(); - if (this.NullableShape != null) - hashCode = hashCode * 59 + this.NullableShape.GetHashCode(); - if (this.Shapes != null) - hashCode = hashCode * 59 + this.Shapes.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs index 8befbb0b5047..ad8a2c787f48 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -35,7 +32,7 @@ public partial class EnumArrays : IEquatable, IValidatableObject /// /// Defines JustSymbol /// - [JsonConverter(typeof(StringEnumConverter))] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public enum JustSymbolEnum { /// @@ -57,10 +54,11 @@ public enum JustSymbolEnum /// [DataMember(Name = "just_symbol", EmitDefaultValue = false)] public JustSymbolEnum? JustSymbol { get; set; } + /// /// Defines ArrayEnum /// - [JsonConverter(typeof(StringEnumConverter))] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public enum ArrayEnumEnum { /// @@ -83,16 +81,17 @@ public enum ArrayEnumEnum /// [DataMember(Name = "array_enum", EmitDefaultValue = false)] public List ArrayEnum { get; set; } + /// /// Initializes a new instance of the class. /// /// justSymbol. /// arrayEnum. - public EnumArrays(JustSymbolEnum? justSymbol = default(JustSymbolEnum?), List arrayEnum = default(List)) + public EnumArrays(JustSymbolEnum? justSymbol, List arrayEnum) { - this.JustSymbol = justSymbol; - this.ArrayEnum = arrayEnum; - this.AdditionalProperties = new Dictionary(); + JustSymbol = justSymbol; + ArrayEnum = arrayEnum; + AdditionalProperties = new Dictionary(); } /// @@ -109,9 +108,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class EnumArrays {\n"); - sb.Append(" JustSymbol: ").Append(JustSymbol).Append("\n"); - sb.Append(" ArrayEnum: ").Append(ArrayEnum).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" JustSymbol: ").Append(JustSymbol).Append('\n'); + sb.Append(" ArrayEnum: ").Append(ArrayEnum).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -120,9 +119,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -130,7 +129,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as EnumArrays).AreEqual; } @@ -140,28 +139,11 @@ public override bool Equals(object input) /// /// Instance of EnumArrays to be compared /// Boolean - public bool Equals(EnumArrays input) + public bool Equals(EnumArrays? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.JustSymbol.GetHashCode(); - hashCode = hashCode * 59 + this.ArrayEnum.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumClass.cs index 99f8afbbbfd5..e2300190ba1d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumClass.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs index 233087cc1705..9f9248a9b220 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -35,7 +32,7 @@ public partial class EnumTest : IEquatable, IValidatableObject /// /// Defines EnumString /// - [JsonConverter(typeof(StringEnumConverter))] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public enum EnumStringEnum { /// @@ -63,10 +60,11 @@ public enum EnumStringEnum /// [DataMember(Name = "enum_string", EmitDefaultValue = false)] public EnumStringEnum? EnumString { get; set; } + /// /// Defines EnumStringRequired /// - [JsonConverter(typeof(StringEnumConverter))] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public enum EnumStringRequiredEnum { /// @@ -94,6 +92,7 @@ public enum EnumStringRequiredEnum /// [DataMember(Name = "enum_string_required", IsRequired = true, EmitDefaultValue = false)] public EnumStringRequiredEnum EnumStringRequired { get; set; } + /// /// Defines EnumInteger /// @@ -116,10 +115,11 @@ public enum EnumIntegerEnum /// [DataMember(Name = "enum_integer", EmitDefaultValue = false)] public EnumIntegerEnum? EnumInteger { get; set; } + /// /// Defines EnumNumber /// - [JsonConverter(typeof(StringEnumConverter))] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public enum EnumNumberEnum { /// @@ -141,26 +141,31 @@ public enum EnumNumberEnum /// [DataMember(Name = "enum_number", EmitDefaultValue = false)] public EnumNumberEnum? EnumNumber { get; set; } + /// /// Gets or Sets OuterEnum /// [DataMember(Name = "outerEnum", EmitDefaultValue = true)] public OuterEnum? OuterEnum { get; set; } + /// /// Gets or Sets OuterEnumInteger /// [DataMember(Name = "outerEnumInteger", EmitDefaultValue = false)] public OuterEnumInteger? OuterEnumInteger { get; set; } + /// /// Gets or Sets OuterEnumDefaultValue /// [DataMember(Name = "outerEnumDefaultValue", EmitDefaultValue = false)] public OuterEnumDefaultValue? OuterEnumDefaultValue { get; set; } + /// /// Gets or Sets OuterEnumIntegerDefaultValue /// [DataMember(Name = "outerEnumIntegerDefaultValue", EmitDefaultValue = false)] public OuterEnumIntegerDefaultValue? OuterEnumIntegerDefaultValue { get; set; } + /// /// Initializes a new instance of the class. /// @@ -169,6 +174,7 @@ protected EnumTest() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// @@ -180,17 +186,18 @@ protected EnumTest() /// outerEnumInteger. /// outerEnumDefaultValue. /// outerEnumIntegerDefaultValue. - public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?)) + public EnumTest(EnumStringEnum? enumString, EnumStringRequiredEnum enumStringRequired, EnumIntegerEnum? enumInteger, EnumNumberEnum? enumNumber, OuterEnum? outerEnum, OuterEnumInteger? outerEnumInteger, OuterEnumDefaultValue? outerEnumDefaultValue, OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue) { - this.EnumStringRequired = enumStringRequired; - this.EnumString = enumString; - this.EnumInteger = enumInteger; - this.EnumNumber = enumNumber; - this.OuterEnum = outerEnum; - this.OuterEnumInteger = outerEnumInteger; - this.OuterEnumDefaultValue = outerEnumDefaultValue; - this.OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; - this.AdditionalProperties = new Dictionary(); + EnumStringRequired = enumStringRequired; + + EnumString = enumString; + EnumInteger = enumInteger; + EnumNumber = enumNumber; + OuterEnum = outerEnum; + OuterEnumInteger = outerEnumInteger; + OuterEnumDefaultValue = outerEnumDefaultValue; + OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; + AdditionalProperties = new Dictionary(); } /// @@ -207,15 +214,15 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class EnumTest {\n"); - sb.Append(" EnumString: ").Append(EnumString).Append("\n"); - sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); - sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); - sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); - sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); - sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n"); - sb.Append(" OuterEnumDefaultValue: ").Append(OuterEnumDefaultValue).Append("\n"); - sb.Append(" OuterEnumIntegerDefaultValue: ").Append(OuterEnumIntegerDefaultValue).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" EnumString: ").Append(EnumString).Append('\n'); + sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append('\n'); + sb.Append(" EnumInteger: ").Append(EnumInteger).Append('\n'); + sb.Append(" EnumNumber: ").Append(EnumNumber).Append('\n'); + sb.Append(" OuterEnum: ").Append(OuterEnum).Append('\n'); + sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append('\n'); + sb.Append(" OuterEnumDefaultValue: ").Append(OuterEnumDefaultValue).Append('\n'); + sb.Append(" OuterEnumIntegerDefaultValue: ").Append(OuterEnumIntegerDefaultValue).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -224,9 +231,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -234,7 +241,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as EnumTest).AreEqual; } @@ -244,34 +251,11 @@ public override bool Equals(object input) /// /// Instance of EnumTest to be compared /// Boolean - public bool Equals(EnumTest input) + public bool Equals(EnumTest? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.EnumString.GetHashCode(); - hashCode = hashCode * 59 + this.EnumStringRequired.GetHashCode(); - hashCode = hashCode * 59 + this.EnumInteger.GetHashCode(); - hashCode = hashCode * 59 + this.EnumNumber.GetHashCode(); - hashCode = hashCode * 59 + this.OuterEnum.GetHashCode(); - hashCode = hashCode * 59 + this.OuterEnumInteger.GetHashCode(); - hashCode = hashCode * 59 + this.OuterEnumDefaultValue.GetHashCode(); - hashCode = hashCode * 59 + this.OuterEnumIntegerDefaultValue.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index ed443f68cf77..bc53813e9b4c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,18 +37,21 @@ protected EquilateralTriangle() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// shapeType (required). /// triangleType (required). - public EquilateralTriangle(string shapeType = default(string), string triangleType = default(string)) + public EquilateralTriangle(string shapeType, string triangleType) { // to ensure "shapeType" is required (not null) - this.ShapeType = shapeType ?? throw new ArgumentNullException("shapeType is a required property for EquilateralTriangle and cannot be null"); + ShapeType = shapeType ?? throw new ArgumentNullException("shapeType is a required property for EquilateralTriangle and cannot be null"); + // to ensure "triangleType" is required (not null) - this.TriangleType = triangleType ?? throw new ArgumentNullException("triangleType is a required property for EquilateralTriangle and cannot be null"); - this.AdditionalProperties = new Dictionary(); + TriangleType = triangleType ?? throw new ArgumentNullException("triangleType is a required property for EquilateralTriangle and cannot be null"); + + AdditionalProperties = new Dictionary(); } /// @@ -80,9 +80,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class EquilateralTriangle {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append('\n'); + sb.Append(" TriangleType: ").Append(TriangleType).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -91,9 +91,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -101,7 +101,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as EquilateralTriangle).AreEqual; } @@ -111,30 +111,11 @@ public override bool Equals(object input) /// /// Instance of EquilateralTriangle to be compared /// Boolean - public bool Equals(EquilateralTriangle input) + public bool Equals(EquilateralTriangle? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.ShapeType != null) - hashCode = hashCode * 59 + this.ShapeType.GetHashCode(); - if (this.TriangleType != null) - hashCode = hashCode * 59 + this.TriangleType.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/File.cs index af4a38ae023d..544530620237 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/File.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class File : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// /// Test capitalization. - public File(string sourceURI = default(string)) + public File(string sourceURI) { - this.SourceURI = sourceURI; - this.AdditionalProperties = new Dictionary(); + SourceURI = sourceURI; + AdditionalProperties = new Dictionary(); } /// @@ -63,8 +60,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class File {\n"); - sb.Append(" SourceURI: ").Append(SourceURI).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" SourceURI: ").Append(SourceURI).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -73,9 +70,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -83,7 +80,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as File).AreEqual; } @@ -93,28 +90,11 @@ public override bool Equals(object input) /// /// Instance of File to be compared /// Boolean - public bool Equals(File input) + public bool Equals(File? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.SourceURI != null) - hashCode = hashCode * 59 + this.SourceURI.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index cc6b3e34c5db..e9bb2ac40231 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -37,11 +34,11 @@ public partial class FileSchemaTestClass : IEquatable, IVal /// /// file. /// files. - public FileSchemaTestClass(File file = default(File), List files = default(List)) + public FileSchemaTestClass(File file, List files) { - this.File = file; - this.Files = files; - this.AdditionalProperties = new Dictionary(); + File = file; + Files = files; + AdditionalProperties = new Dictionary(); } /// @@ -70,9 +67,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class FileSchemaTestClass {\n"); - sb.Append(" File: ").Append(File).Append("\n"); - sb.Append(" Files: ").Append(Files).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" File: ").Append(File).Append('\n'); + sb.Append(" Files: ").Append(Files).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -81,9 +78,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -91,7 +88,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as FileSchemaTestClass).AreEqual; } @@ -101,30 +98,11 @@ public override bool Equals(object input) /// /// Instance of FileSchemaTestClass to be compared /// Boolean - public bool Equals(FileSchemaTestClass input) + public bool Equals(FileSchemaTestClass? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.File != null) - hashCode = hashCode * 59 + this.File.GetHashCode(); - if (this.Files != null) - hashCode = hashCode * 59 + this.Files.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Foo.cs index 836374681193..eb2a8133a628 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Foo.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,11 +33,11 @@ public partial class Foo : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// /// bar (default to "bar"). - public Foo(string bar = "bar") + public Foo(string bar) { // use default value if no "bar" provided - this.Bar = bar ?? "bar"; - this.AdditionalProperties = new Dictionary(); + Bar = bar ?? "bar"; + AdditionalProperties = new Dictionary(); } /// @@ -63,8 +60,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Foo {\n"); - sb.Append(" Bar: ").Append(Bar).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Bar: ").Append(Bar).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -73,9 +70,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -83,7 +80,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Foo).AreEqual; } @@ -93,28 +90,11 @@ public override bool Equals(object input) /// /// Instance of Foo to be compared /// Boolean - public bool Equals(Foo input) + public bool Equals(Foo? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Bar != null) - hashCode = hashCode * 59 + this.Bar.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FormatTest.cs index 9e7466bb502e..57abeb11ed28 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FormatTest.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,6 +37,7 @@ protected FormatTest() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// @@ -59,27 +57,31 @@ protected FormatTest() /// password (required). /// A string that is a 10 digit number. Can have leading zeros.. /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.. - public FormatTest(int integer = default(int), int int32 = default(int), long int64 = default(long), decimal number = default(decimal), float _float = default(float), double _double = default(double), decimal _decimal = default(decimal), string _string = default(string), byte[] _byte = default(byte[]), System.IO.Stream binary = default(System.IO.Stream), DateTime date = default(DateTime), DateTime dateTime = default(DateTime), Guid uuid = default(Guid), string password = default(string), string patternWithDigits = default(string), string patternWithDigitsAndDelimiter = default(string)) + public FormatTest(int integer, int int32, long int64, decimal number, float _float, double _double, decimal _decimal, string _string, byte[] _byte, System.IO.Stream binary, DateTime date, DateTime dateTime, Guid uuid, string password, string patternWithDigits, string patternWithDigitsAndDelimiter) { - this.Number = number; + Number = number; + // to ensure "_byte" is required (not null) - this.Byte = _byte ?? throw new ArgumentNullException("_byte is a required property for FormatTest and cannot be null"); - this.Date = date; + Byte = _byte ?? throw new ArgumentNullException("_byte is a required property for FormatTest and cannot be null"); + + Date = date; + // to ensure "password" is required (not null) - this.Password = password ?? throw new ArgumentNullException("password is a required property for FormatTest and cannot be null"); - this.Integer = integer; - this.Int32 = int32; - this.Int64 = int64; - this.Float = _float; - this.Double = _double; - this.Decimal = _decimal; - this.String = _string; - this.Binary = binary; - this.DateTime = dateTime; - this.Uuid = uuid; - this.PatternWithDigits = patternWithDigits; - this.PatternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter; - this.AdditionalProperties = new Dictionary(); + Password = password ?? throw new ArgumentNullException("password is a required property for FormatTest and cannot be null"); + + Integer = integer; + Int32 = int32; + Int64 = int64; + Float = _float; + Double = _double; + Decimal = _decimal; + String = _string; + Binary = binary; + DateTime = dateTime; + Uuid = uuid; + PatternWithDigits = patternWithDigits; + PatternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter; + AdditionalProperties = new Dictionary(); } /// @@ -146,7 +148,7 @@ protected FormatTest() /// Gets or Sets Date /// [DataMember(Name = "date", IsRequired = true, EmitDefaultValue = false)] - [JsonConverter(typeof(OpenAPIDateConverter))] + [Newtonsoft.Json.JsonConverter(typeof(OpenAPIDateConverter))] public DateTime Date { get; set; } /// @@ -195,23 +197,23 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class FormatTest {\n"); - sb.Append(" Integer: ").Append(Integer).Append("\n"); - sb.Append(" Int32: ").Append(Int32).Append("\n"); - sb.Append(" Int64: ").Append(Int64).Append("\n"); - sb.Append(" Number: ").Append(Number).Append("\n"); - sb.Append(" Float: ").Append(Float).Append("\n"); - sb.Append(" Double: ").Append(Double).Append("\n"); - sb.Append(" Decimal: ").Append(Decimal).Append("\n"); - sb.Append(" String: ").Append(String).Append("\n"); - sb.Append(" Byte: ").Append(Byte).Append("\n"); - sb.Append(" Binary: ").Append(Binary).Append("\n"); - sb.Append(" Date: ").Append(Date).Append("\n"); - sb.Append(" DateTime: ").Append(DateTime).Append("\n"); - sb.Append(" Uuid: ").Append(Uuid).Append("\n"); - sb.Append(" Password: ").Append(Password).Append("\n"); - sb.Append(" PatternWithDigits: ").Append(PatternWithDigits).Append("\n"); - sb.Append(" PatternWithDigitsAndDelimiter: ").Append(PatternWithDigitsAndDelimiter).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Integer: ").Append(Integer).Append('\n'); + sb.Append(" Int32: ").Append(Int32).Append('\n'); + sb.Append(" Int64: ").Append(Int64).Append('\n'); + sb.Append(" Number: ").Append(Number).Append('\n'); + sb.Append(" Float: ").Append(Float).Append('\n'); + sb.Append(" Double: ").Append(Double).Append('\n'); + sb.Append(" Decimal: ").Append(Decimal).Append('\n'); + sb.Append(" String: ").Append(String).Append('\n'); + sb.Append(" Byte: ").Append(Byte).Append('\n'); + sb.Append(" Binary: ").Append(Binary).Append('\n'); + sb.Append(" Date: ").Append(Date).Append('\n'); + sb.Append(" DateTime: ").Append(DateTime).Append('\n'); + sb.Append(" Uuid: ").Append(Uuid).Append('\n'); + sb.Append(" Password: ").Append(Password).Append('\n'); + sb.Append(" PatternWithDigits: ").Append(PatternWithDigits).Append('\n'); + sb.Append(" PatternWithDigitsAndDelimiter: ").Append(PatternWithDigitsAndDelimiter).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -220,9 +222,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -230,7 +232,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as FormatTest).AreEqual; } @@ -240,51 +242,11 @@ public override bool Equals(object input) /// /// Instance of FormatTest to be compared /// Boolean - public bool Equals(FormatTest input) + public bool Equals(FormatTest? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Integer.GetHashCode(); - hashCode = hashCode * 59 + this.Int32.GetHashCode(); - hashCode = hashCode * 59 + this.Int64.GetHashCode(); - hashCode = hashCode * 59 + this.Number.GetHashCode(); - hashCode = hashCode * 59 + this.Float.GetHashCode(); - hashCode = hashCode * 59 + this.Double.GetHashCode(); - hashCode = hashCode * 59 + this.Decimal.GetHashCode(); - if (this.String != null) - hashCode = hashCode * 59 + this.String.GetHashCode(); - if (this.Byte != null) - hashCode = hashCode * 59 + this.Byte.GetHashCode(); - if (this.Binary != null) - hashCode = hashCode * 59 + this.Binary.GetHashCode(); - if (this.Date != null) - hashCode = hashCode * 59 + this.Date.GetHashCode(); - if (this.DateTime != null) - hashCode = hashCode * 59 + this.DateTime.GetHashCode(); - if (this.Uuid != null) - hashCode = hashCode * 59 + this.Uuid.GetHashCode(); - if (this.Password != null) - hashCode = hashCode * 59 + this.Password.GetHashCode(); - if (this.PatternWithDigits != null) - hashCode = hashCode * 59 + this.PatternWithDigits.GetHashCode(); - if (this.PatternWithDigitsAndDelimiter != null) - hashCode = hashCode * 59 + this.PatternWithDigitsAndDelimiter.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Fruit.cs index 8226bbd0a2fe..f173794fade2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Fruit.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FruitReq.cs index 57d5d8d271bd..77141c1860d9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FruitReq.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GmFruit.cs index c168aa41d4ce..5d83a2d14eb4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GmFruit.cs @@ -17,12 +17,10 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index 9352d27022f2..ba8878068efe 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; @@ -31,7 +28,7 @@ namespace Org.OpenAPITools.Model /// GrandparentAnimal /// [DataContract(Name = "GrandparentAnimal")] - [JsonConverter(typeof(JsonSubtypes), "PetType")] + [Newtonsoft.Json.JsonConverter(typeof(JsonSubtypes), "PetType")] [JsonSubtypes.KnownSubType(typeof(ChildCat), "ChildCat")] [JsonSubtypes.KnownSubType(typeof(ParentPet), "ParentPet")] public partial class GrandparentAnimal : IEquatable, IValidatableObject @@ -44,15 +41,17 @@ protected GrandparentAnimal() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// petType (required). - public GrandparentAnimal(string petType = default(string)) + public GrandparentAnimal(string petType) { // to ensure "petType" is required (not null) - this.PetType = petType ?? throw new ArgumentNullException("petType is a required property for GrandparentAnimal and cannot be null"); - this.AdditionalProperties = new Dictionary(); + PetType = petType ?? throw new ArgumentNullException("petType is a required property for GrandparentAnimal and cannot be null"); + + AdditionalProperties = new Dictionary(); } /// @@ -75,8 +74,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class GrandparentAnimal {\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" PetType: ").Append(PetType).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -85,9 +84,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -95,7 +94,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as GrandparentAnimal).AreEqual; } @@ -105,28 +104,11 @@ public override bool Equals(object input) /// /// Instance of GrandparentAnimal to be compared /// Boolean - public bool Equals(GrandparentAnimal input) + public bool Equals(GrandparentAnimal? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.PetType != null) - hashCode = hashCode * 59 + this.PetType.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index 3a2c3d26a92c..e72e090775e3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -38,7 +35,7 @@ public partial class HasOnlyReadOnly : IEquatable, IValidatable [JsonConstructorAttribute] public HasOnlyReadOnly() { - this.AdditionalProperties = new Dictionary(); + AdditionalProperties = new Dictionary(); } /// @@ -85,9 +82,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class HasOnlyReadOnly {\n"); - sb.Append(" Bar: ").Append(Bar).Append("\n"); - sb.Append(" Foo: ").Append(Foo).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Bar: ").Append(Bar).Append('\n'); + sb.Append(" Foo: ").Append(Foo).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -96,9 +93,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -106,7 +103,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as HasOnlyReadOnly).AreEqual; } @@ -116,30 +113,11 @@ public override bool Equals(object input) /// /// Instance of HasOnlyReadOnly to be compared /// Boolean - public bool Equals(HasOnlyReadOnly input) + public bool Equals(HasOnlyReadOnly? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Bar != null) - hashCode = hashCode * 59 + this.Bar.GetHashCode(); - if (this.Foo != null) - hashCode = hashCode * 59 + this.Foo.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HealthCheckResult.cs index 1cd90560cbed..35c7bbd12da4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class HealthCheckResult : IEquatable, IValidat /// Initializes a new instance of the class. /// /// nullableMessage. - public HealthCheckResult(string nullableMessage = default(string)) + public HealthCheckResult(string nullableMessage) { - this.NullableMessage = nullableMessage; - this.AdditionalProperties = new Dictionary(); + NullableMessage = nullableMessage; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class HealthCheckResult {\n"); - sb.Append(" NullableMessage: ").Append(NullableMessage).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" NullableMessage: ").Append(NullableMessage).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as HealthCheckResult).AreEqual; } @@ -92,28 +89,11 @@ public override bool Equals(object input) /// /// Instance of HealthCheckResult to be compared /// Boolean - public bool Equals(HealthCheckResult input) + public bool Equals(HealthCheckResult? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.NullableMessage != null) - hashCode = hashCode * 59 + this.NullableMessage.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/InlineResponseDefault.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/InlineResponseDefault.cs index 5f4b24acafa1..3517725b1edc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/InlineResponseDefault.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/InlineResponseDefault.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class InlineResponseDefault : IEquatable, /// Initializes a new instance of the class. /// /// _string. - public InlineResponseDefault(Foo _string = default(Foo)) + public InlineResponseDefault(Foo _string) { - this.String = _string; - this.AdditionalProperties = new Dictionary(); + String = _string; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class InlineResponseDefault {\n"); - sb.Append(" String: ").Append(String).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" String: ").Append(String).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as InlineResponseDefault).AreEqual; } @@ -92,28 +89,11 @@ public override bool Equals(object input) /// /// Instance of InlineResponseDefault to be compared /// Boolean - public bool Equals(InlineResponseDefault input) + public bool Equals(InlineResponseDefault? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.String != null) - hashCode = hashCode * 59 + this.String.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index 46963173f71a..d93709692b9e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -42,12 +39,14 @@ protected IsoscelesTriangle() { } /// /// shapeType (required). /// triangleType (required). - public IsoscelesTriangle(string shapeType = default(string), string triangleType = default(string)) + public IsoscelesTriangle(string shapeType, string triangleType) { // to ensure "shapeType" is required (not null) - this.ShapeType = shapeType ?? throw new ArgumentNullException("shapeType is a required property for IsoscelesTriangle and cannot be null"); + ShapeType = shapeType ?? throw new ArgumentNullException("shapeType is a required property for IsoscelesTriangle and cannot be null"); + // to ensure "triangleType" is required (not null) - this.TriangleType = triangleType ?? throw new ArgumentNullException("triangleType is a required property for IsoscelesTriangle and cannot be null"); + TriangleType = triangleType ?? throw new ArgumentNullException("triangleType is a required property for IsoscelesTriangle and cannot be null"); + } /// @@ -70,8 +69,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class IsoscelesTriangle {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append('\n'); + sb.Append(" TriangleType: ").Append(TriangleType).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -80,9 +79,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -90,7 +89,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as IsoscelesTriangle).AreEqual; } @@ -100,28 +99,11 @@ public override bool Equals(object input) /// /// Instance of IsoscelesTriangle to be compared /// Boolean - public bool Equals(IsoscelesTriangle input) + public bool Equals(IsoscelesTriangle? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.ShapeType != null) - hashCode = hashCode * 59 + this.ShapeType.GetHashCode(); - if (this.TriangleType != null) - hashCode = hashCode * 59 + this.TriangleType.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/List.cs index ecf4e8ff00ea..555797a2747d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/List.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class List : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// /// _123list. - public List(string _123list = default(string)) + public List(string _123list) { - this._123List = _123list; - this.AdditionalProperties = new Dictionary(); + _123List = _123list; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class List {\n"); - sb.Append(" _123List: ").Append(_123List).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" _123List: ").Append(_123List).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as List).AreEqual; } @@ -92,28 +89,11 @@ public override bool Equals(object input) /// /// Instance of List to be compared /// Boolean - public bool Equals(List input) + public bool Equals(List? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this._123List != null) - hashCode = hashCode * 59 + this._123List.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Mammal.cs index c8e3229ed3b2..abebdf3a81e4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Mammal.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs index 0f9e49a98b35..4730b465418c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -35,7 +32,7 @@ public partial class MapTest : IEquatable, IValidatableObject /// /// Defines Inner /// - [JsonConverter(typeof(StringEnumConverter))] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public enum InnerEnum { /// @@ -58,6 +55,7 @@ public enum InnerEnum /// [DataMember(Name = "map_of_enum_string", EmitDefaultValue = false)] public Dictionary MapOfEnumString { get; set; } + /// /// Initializes a new instance of the class. /// @@ -65,13 +63,13 @@ public enum InnerEnum /// mapOfEnumString. /// directMap. /// indirectMap. - public MapTest(Dictionary> mapMapOfString = default(Dictionary>), Dictionary mapOfEnumString = default(Dictionary), Dictionary directMap = default(Dictionary), Dictionary indirectMap = default(Dictionary)) + public MapTest(Dictionary> mapMapOfString, Dictionary mapOfEnumString, Dictionary directMap, Dictionary indirectMap) { - this.MapMapOfString = mapMapOfString; - this.MapOfEnumString = mapOfEnumString; - this.DirectMap = directMap; - this.IndirectMap = indirectMap; - this.AdditionalProperties = new Dictionary(); + MapMapOfString = mapMapOfString; + MapOfEnumString = mapOfEnumString; + DirectMap = directMap; + IndirectMap = indirectMap; + AdditionalProperties = new Dictionary(); } /// @@ -106,11 +104,11 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class MapTest {\n"); - sb.Append(" MapMapOfString: ").Append(MapMapOfString).Append("\n"); - sb.Append(" MapOfEnumString: ").Append(MapOfEnumString).Append("\n"); - sb.Append(" DirectMap: ").Append(DirectMap).Append("\n"); - sb.Append(" IndirectMap: ").Append(IndirectMap).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" MapMapOfString: ").Append(MapMapOfString).Append('\n'); + sb.Append(" MapOfEnumString: ").Append(MapOfEnumString).Append('\n'); + sb.Append(" DirectMap: ").Append(DirectMap).Append('\n'); + sb.Append(" IndirectMap: ").Append(IndirectMap).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -119,9 +117,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -129,7 +127,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as MapTest).AreEqual; } @@ -139,33 +137,11 @@ public override bool Equals(object input) /// /// Instance of MapTest to be compared /// Boolean - public bool Equals(MapTest input) + public bool Equals(MapTest? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.MapMapOfString != null) - hashCode = hashCode * 59 + this.MapMapOfString.GetHashCode(); - hashCode = hashCode * 59 + this.MapOfEnumString.GetHashCode(); - if (this.DirectMap != null) - hashCode = hashCode * 59 + this.DirectMap.GetHashCode(); - if (this.IndirectMap != null) - hashCode = hashCode * 59 + this.IndirectMap.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index dc3d45a080a4..2300639e2580 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -38,12 +35,12 @@ public partial class MixedPropertiesAndAdditionalPropertiesClass : IEquatableuuid. /// dateTime. /// map. - public MixedPropertiesAndAdditionalPropertiesClass(Guid uuid = default(Guid), DateTime dateTime = default(DateTime), Dictionary map = default(Dictionary)) + public MixedPropertiesAndAdditionalPropertiesClass(Guid uuid, DateTime dateTime, Dictionary map) { - this.Uuid = uuid; - this.DateTime = dateTime; - this.Map = map; - this.AdditionalProperties = new Dictionary(); + Uuid = uuid; + DateTime = dateTime; + Map = map; + AdditionalProperties = new Dictionary(); } /// @@ -78,10 +75,10 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); - sb.Append(" Uuid: ").Append(Uuid).Append("\n"); - sb.Append(" DateTime: ").Append(DateTime).Append("\n"); - sb.Append(" Map: ").Append(Map).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append('\n'); + sb.Append(" DateTime: ").Append(DateTime).Append('\n'); + sb.Append(" Map: ").Append(Map).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -90,9 +87,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -100,7 +97,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedPropertiesAndAdditionalPropertiesClass).AreEqual; } @@ -110,32 +107,11 @@ public override bool Equals(object input) /// /// Instance of MixedPropertiesAndAdditionalPropertiesClass to be compared /// Boolean - public bool Equals(MixedPropertiesAndAdditionalPropertiesClass input) + public bool Equals(MixedPropertiesAndAdditionalPropertiesClass? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Uuid != null) - hashCode = hashCode * 59 + this.Uuid.GetHashCode(); - if (this.DateTime != null) - hashCode = hashCode * 59 + this.DateTime.GetHashCode(); - if (this.Map != null) - hashCode = hashCode * 59 + this.Map.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Model200Response.cs index b1e76d250816..7d739192998f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Model200Response.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -37,11 +34,11 @@ public partial class Model200Response : IEquatable, IValidatab /// /// name. /// _class. - public Model200Response(int name = default(int), string _class = default(string)) + public Model200Response(int name, string _class) { - this.Name = name; - this.Class = _class; - this.AdditionalProperties = new Dictionary(); + Name = name; + Class = _class; + AdditionalProperties = new Dictionary(); } /// @@ -70,9 +67,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Model200Response {\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" Class: ").Append(Class).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Name: ").Append(Name).Append('\n'); + sb.Append(" Class: ").Append(Class).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -81,9 +78,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -91,7 +88,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Model200Response).AreEqual; } @@ -101,29 +98,11 @@ public override bool Equals(object input) /// /// Instance of Model200Response to be compared /// Boolean - public bool Equals(Model200Response input) + public bool Equals(Model200Response? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Name.GetHashCode(); - if (this.Class != null) - hashCode = hashCode * 59 + this.Class.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ModelClient.cs index 16f1dc95bab9..bf54a452415d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ModelClient.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class ModelClient : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// /// _client. - public ModelClient(string _client = default(string)) + public ModelClient(string _client) { - this.__Client = _client; - this.AdditionalProperties = new Dictionary(); + __Client = _client; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ModelClient {\n"); - sb.Append(" __Client: ").Append(__Client).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" __Client: ").Append(__Client).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ModelClient).AreEqual; } @@ -92,28 +89,11 @@ public override bool Equals(object input) /// /// Instance of ModelClient to be compared /// Boolean - public bool Equals(ModelClient input) + public bool Equals(ModelClient? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.__Client != null) - hashCode = hashCode * 59 + this.__Client.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Name.cs index a6a01dd4ed3e..d50019f78f7b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Name.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,16 +37,18 @@ protected Name() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// name (required). /// property. - public Name(int name = default(int), string property = default(string)) + public Name(int name, string property) { - this._Name = name; - this.Property = property; - this.AdditionalProperties = new Dictionary(); + _Name = name; + + Property = property; + AdditionalProperties = new Dictionary(); } /// @@ -108,11 +107,11 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Name {\n"); - sb.Append(" _Name: ").Append(_Name).Append("\n"); - sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n"); - sb.Append(" Property: ").Append(Property).Append("\n"); - sb.Append(" _123Number: ").Append(_123Number).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" _Name: ").Append(_Name).Append('\n'); + sb.Append(" SnakeCase: ").Append(SnakeCase).Append('\n'); + sb.Append(" Property: ").Append(Property).Append('\n'); + sb.Append(" _123Number: ").Append(_123Number).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -121,9 +120,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -131,7 +130,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Name).AreEqual; } @@ -141,31 +140,11 @@ public override bool Equals(object input) /// /// Instance of Name to be compared /// Boolean - public bool Equals(Name input) + public bool Equals(Name? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this._Name.GetHashCode(); - hashCode = hashCode * 59 + this.SnakeCase.GetHashCode(); - if (this.Property != null) - hashCode = hashCode * 59 + this.Property.GetHashCode(); - hashCode = hashCode * 59 + this._123Number.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs index 4ceaab61bc63..76d2cefbc045 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -47,20 +44,20 @@ public partial class NullableClass : Dictionary, IEquatableobjectNullableProp. /// objectAndItemsNullableProp. /// objectItemsNullable. - public NullableClass(int? integerProp = default(int?), decimal? numberProp = default(decimal?), bool? booleanProp = default(bool?), string stringProp = default(string), DateTime? dateProp = default(DateTime?), DateTime? datetimeProp = default(DateTime?), List arrayNullableProp = default(List), List arrayAndItemsNullableProp = default(List), List arrayItemsNullable = default(List), Dictionary objectNullableProp = default(Dictionary), Dictionary objectAndItemsNullableProp = default(Dictionary), Dictionary objectItemsNullable = default(Dictionary)) : base() + public NullableClass(int? integerProp, decimal? numberProp, bool? booleanProp, string stringProp, DateTime? dateProp, DateTime? datetimeProp, List arrayNullableProp, List arrayAndItemsNullableProp, List arrayItemsNullable, Dictionary objectNullableProp, Dictionary objectAndItemsNullableProp, Dictionary objectItemsNullable) : base() { - this.IntegerProp = integerProp; - this.NumberProp = numberProp; - this.BooleanProp = booleanProp; - this.StringProp = stringProp; - this.DateProp = dateProp; - this.DatetimeProp = datetimeProp; - this.ArrayNullableProp = arrayNullableProp; - this.ArrayAndItemsNullableProp = arrayAndItemsNullableProp; - this.ArrayItemsNullable = arrayItemsNullable; - this.ObjectNullableProp = objectNullableProp; - this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; - this.ObjectItemsNullable = objectItemsNullable; + IntegerProp = integerProp; + NumberProp = numberProp; + BooleanProp = booleanProp; + StringProp = stringProp; + DateProp = dateProp; + DatetimeProp = datetimeProp; + ArrayNullableProp = arrayNullableProp; + ArrayAndItemsNullableProp = arrayAndItemsNullableProp; + ArrayItemsNullable = arrayItemsNullable; + ObjectNullableProp = objectNullableProp; + ObjectAndItemsNullableProp = objectAndItemsNullableProp; + ObjectItemsNullable = objectItemsNullable; } /// @@ -91,7 +88,7 @@ public partial class NullableClass : Dictionary, IEquatable [DataMember(Name = "date_prop", EmitDefaultValue = true)] - [JsonConverter(typeof(OpenAPIDateConverter))] + [Newtonsoft.Json.JsonConverter(typeof(OpenAPIDateConverter))] public DateTime? DateProp { get; set; } /// @@ -144,19 +141,19 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class NullableClass {\n"); - sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" IntegerProp: ").Append(IntegerProp).Append("\n"); - sb.Append(" NumberProp: ").Append(NumberProp).Append("\n"); - sb.Append(" BooleanProp: ").Append(BooleanProp).Append("\n"); - sb.Append(" StringProp: ").Append(StringProp).Append("\n"); - sb.Append(" DateProp: ").Append(DateProp).Append("\n"); - sb.Append(" DatetimeProp: ").Append(DatetimeProp).Append("\n"); - sb.Append(" ArrayNullableProp: ").Append(ArrayNullableProp).Append("\n"); - sb.Append(" ArrayAndItemsNullableProp: ").Append(ArrayAndItemsNullableProp).Append("\n"); - sb.Append(" ArrayItemsNullable: ").Append(ArrayItemsNullable).Append("\n"); - sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); - sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); - sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append('\n'); + sb.Append(" IntegerProp: ").Append(IntegerProp).Append('\n'); + sb.Append(" NumberProp: ").Append(NumberProp).Append('\n'); + sb.Append(" BooleanProp: ").Append(BooleanProp).Append('\n'); + sb.Append(" StringProp: ").Append(StringProp).Append('\n'); + sb.Append(" DateProp: ").Append(DateProp).Append('\n'); + sb.Append(" DatetimeProp: ").Append(DatetimeProp).Append('\n'); + sb.Append(" ArrayNullableProp: ").Append(ArrayNullableProp).Append('\n'); + sb.Append(" ArrayAndItemsNullableProp: ").Append(ArrayAndItemsNullableProp).Append('\n'); + sb.Append(" ArrayItemsNullable: ").Append(ArrayItemsNullable).Append('\n'); + sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append('\n'); + sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append('\n'); + sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -165,9 +162,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public string ToJson() + public string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -175,7 +172,7 @@ public string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as NullableClass).AreEqual; } @@ -185,48 +182,11 @@ public override bool Equals(object input) /// /// Instance of NullableClass to be compared /// Boolean - public bool Equals(NullableClass input) + public bool Equals(NullableClass? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = base.GetHashCode(); - if (this.IntegerProp != null) - hashCode = hashCode * 59 + this.IntegerProp.GetHashCode(); - if (this.NumberProp != null) - hashCode = hashCode * 59 + this.NumberProp.GetHashCode(); - if (this.BooleanProp != null) - hashCode = hashCode * 59 + this.BooleanProp.GetHashCode(); - if (this.StringProp != null) - hashCode = hashCode * 59 + this.StringProp.GetHashCode(); - if (this.DateProp != null) - hashCode = hashCode * 59 + this.DateProp.GetHashCode(); - if (this.DatetimeProp != null) - hashCode = hashCode * 59 + this.DatetimeProp.GetHashCode(); - if (this.ArrayNullableProp != null) - hashCode = hashCode * 59 + this.ArrayNullableProp.GetHashCode(); - if (this.ArrayAndItemsNullableProp != null) - hashCode = hashCode * 59 + this.ArrayAndItemsNullableProp.GetHashCode(); - if (this.ArrayItemsNullable != null) - hashCode = hashCode * 59 + this.ArrayItemsNullable.GetHashCode(); - if (this.ObjectNullableProp != null) - hashCode = hashCode * 59 + this.ObjectNullableProp.GetHashCode(); - if (this.ObjectAndItemsNullableProp != null) - hashCode = hashCode * 59 + this.ObjectAndItemsNullableProp.GetHashCode(); - if (this.ObjectItemsNullable != null) - hashCode = hashCode * 59 + this.ObjectItemsNullable.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableShape.cs index ae8ae903e98e..7990fd0dc479 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableShape.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NumberOnly.cs index e9b006094cf6..0318fbd87957 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class NumberOnly : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// /// justNumber. - public NumberOnly(decimal justNumber = default(decimal)) + public NumberOnly(decimal justNumber) { - this.JustNumber = justNumber; - this.AdditionalProperties = new Dictionary(); + JustNumber = justNumber; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class NumberOnly {\n"); - sb.Append(" JustNumber: ").Append(JustNumber).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" JustNumber: ").Append(JustNumber).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as NumberOnly).AreEqual; } @@ -92,27 +89,11 @@ public override bool Equals(object input) /// /// Instance of NumberOnly to be compared /// Boolean - public bool Equals(NumberOnly input) + public bool Equals(NumberOnly? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.JustNumber.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs index 975f3b711dd6..6c05036c3c03 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,7 +33,7 @@ public partial class Order : IEquatable, IValidatableObject /// Order Status /// /// Order Status - [JsonConverter(typeof(StringEnumConverter))] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public enum StatusEnum { /// @@ -65,6 +62,7 @@ public enum StatusEnum /// Order Status [DataMember(Name = "status", EmitDefaultValue = false)] public StatusEnum? Status { get; set; } + /// /// Initializes a new instance of the class. /// @@ -74,15 +72,15 @@ public enum StatusEnum /// shipDate. /// Order Status. /// complete (default to false). - public Order(long id = default(long), long petId = default(long), int quantity = default(int), DateTime shipDate = default(DateTime), StatusEnum? status = default(StatusEnum?), bool complete = false) + public Order(long id, long petId, int quantity, DateTime shipDate, StatusEnum? status, bool complete) { - this.Id = id; - this.PetId = petId; - this.Quantity = quantity; - this.ShipDate = shipDate; - this.Status = status; - this.Complete = complete; - this.AdditionalProperties = new Dictionary(); + Id = id; + PetId = petId; + Quantity = quantity; + ShipDate = shipDate; + Status = status; + Complete = complete; + AdditionalProperties = new Dictionary(); } /// @@ -129,13 +127,13 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Order {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" PetId: ").Append(PetId).Append("\n"); - sb.Append(" Quantity: ").Append(Quantity).Append("\n"); - sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); - sb.Append(" Status: ").Append(Status).Append("\n"); - sb.Append(" Complete: ").Append(Complete).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Id: ").Append(Id).Append('\n'); + sb.Append(" PetId: ").Append(PetId).Append('\n'); + sb.Append(" Quantity: ").Append(Quantity).Append('\n'); + sb.Append(" ShipDate: ").Append(ShipDate).Append('\n'); + sb.Append(" Status: ").Append(Status).Append('\n'); + sb.Append(" Complete: ").Append(Complete).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -144,9 +142,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -154,7 +152,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Order).AreEqual; } @@ -164,33 +162,11 @@ public override bool Equals(object input) /// /// Instance of Order to be compared /// Boolean - public bool Equals(Order input) + public bool Equals(Order? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - hashCode = hashCode * 59 + this.PetId.GetHashCode(); - hashCode = hashCode * 59 + this.Quantity.GetHashCode(); - if (this.ShipDate != null) - hashCode = hashCode * 59 + this.ShipDate.GetHashCode(); - hashCode = hashCode * 59 + this.Status.GetHashCode(); - hashCode = hashCode * 59 + this.Complete.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterComposite.cs index 61c4bca3e3c4..95ca33ecddb1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -38,12 +35,12 @@ public partial class OuterComposite : IEquatable, IValidatableOb /// myNumber. /// myString. /// myBoolean. - public OuterComposite(decimal myNumber = default(decimal), string myString = default(string), bool myBoolean = default(bool)) + public OuterComposite(decimal myNumber, string myString, bool myBoolean) { - this.MyNumber = myNumber; - this.MyString = myString; - this.MyBoolean = myBoolean; - this.AdditionalProperties = new Dictionary(); + MyNumber = myNumber; + MyString = myString; + MyBoolean = myBoolean; + AdditionalProperties = new Dictionary(); } /// @@ -78,10 +75,10 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class OuterComposite {\n"); - sb.Append(" MyNumber: ").Append(MyNumber).Append("\n"); - sb.Append(" MyString: ").Append(MyString).Append("\n"); - sb.Append(" MyBoolean: ").Append(MyBoolean).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" MyNumber: ").Append(MyNumber).Append('\n'); + sb.Append(" MyString: ").Append(MyString).Append('\n'); + sb.Append(" MyBoolean: ").Append(MyBoolean).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -90,9 +87,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -100,7 +97,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as OuterComposite).AreEqual; } @@ -110,30 +107,11 @@ public override bool Equals(object input) /// /// Instance of OuterComposite to be compared /// Boolean - public bool Equals(OuterComposite input) + public bool Equals(OuterComposite? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.MyNumber.GetHashCode(); - if (this.MyString != null) - hashCode = hashCode * 59 + this.MyString.GetHashCode(); - hashCode = hashCode * 59 + this.MyBoolean.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnum.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnum.cs index 3b2dc2a110af..38cbd25448bb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnum.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnum.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs index 04d88ac8fecf..85bbbf10b337 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnumInteger.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnumInteger.cs index da111ad9341d..f038c240def2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnumInteger.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnumInteger.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs index ff0d85056238..8507ea390c6d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ParentPet.cs index a205b59b6d09..732f3faca2f2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ParentPet.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; @@ -31,7 +28,7 @@ namespace Org.OpenAPITools.Model /// ParentPet /// [DataContract(Name = "ParentPet")] - [JsonConverter(typeof(JsonSubtypes), "PetType")] + [Newtonsoft.Json.JsonConverter(typeof(JsonSubtypes), "PetType")] [JsonSubtypes.KnownSubType(typeof(ChildCat), "ChildCat")] public partial class ParentPet : GrandparentAnimal, IEquatable, IValidatableObject { @@ -43,13 +40,14 @@ protected ParentPet() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// petType (required) (default to "ParentPet"). - public ParentPet(string petType = "ParentPet") : base(petType) + public ParentPet(string petType) : base(petType) { - this.AdditionalProperties = new Dictionary(); + AdditionalProperties = new Dictionary(); } /// @@ -66,8 +64,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ParentPet {\n"); - sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -76,9 +74,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public override string ToJson() + public override string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -86,7 +84,7 @@ public override string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ParentPet).AreEqual; } @@ -96,26 +94,11 @@ public override bool Equals(object input) /// /// Instance of ParentPet to be compared /// Boolean - public bool Equals(ParentPet input) + public bool Equals(ParentPet? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = base.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs index 4f7057df98dc..e98c4c34f17d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,7 +33,7 @@ public partial class Pet : IEquatable, IValidatableObject /// pet status in the store /// /// pet status in the store - [JsonConverter(typeof(StringEnumConverter))] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public enum StatusEnum { /// @@ -65,6 +62,7 @@ public enum StatusEnum /// pet status in the store [DataMember(Name = "status", EmitDefaultValue = false)] public StatusEnum? Status { get; set; } + /// /// Initializes a new instance of the class. /// @@ -73,6 +71,7 @@ protected Pet() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// @@ -82,17 +81,19 @@ protected Pet() /// photoUrls (required). /// tags. /// pet status in the store. - public Pet(long id = default(long), Category category = default(Category), string name = default(string), List photoUrls = default(List), List tags = default(List), StatusEnum? status = default(StatusEnum?)) + public Pet(long id, Category category, string name, List photoUrls, List tags, StatusEnum? status) { // to ensure "name" is required (not null) - this.Name = name ?? throw new ArgumentNullException("name is a required property for Pet and cannot be null"); + Name = name ?? throw new ArgumentNullException("name is a required property for Pet and cannot be null"); + // to ensure "photoUrls" is required (not null) - this.PhotoUrls = photoUrls ?? throw new ArgumentNullException("photoUrls is a required property for Pet and cannot be null"); - this.Id = id; - this.Category = category; - this.Tags = tags; - this.Status = status; - this.AdditionalProperties = new Dictionary(); + PhotoUrls = photoUrls ?? throw new ArgumentNullException("photoUrls is a required property for Pet and cannot be null"); + + Id = id; + Category = category; + Tags = tags; + Status = status; + AdditionalProperties = new Dictionary(); } /// @@ -139,13 +140,13 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Pet {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Category: ").Append(Category).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); - sb.Append(" Tags: ").Append(Tags).Append("\n"); - sb.Append(" Status: ").Append(Status).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Id: ").Append(Id).Append('\n'); + sb.Append(" Category: ").Append(Category).Append('\n'); + sb.Append(" Name: ").Append(Name).Append('\n'); + sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append('\n'); + sb.Append(" Tags: ").Append(Tags).Append('\n'); + sb.Append(" Status: ").Append(Status).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -154,9 +155,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -164,7 +165,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Pet).AreEqual; } @@ -174,36 +175,11 @@ public override bool Equals(object input) /// /// Instance of Pet to be compared /// Boolean - public bool Equals(Pet input) + public bool Equals(Pet? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - if (this.Category != null) - hashCode = hashCode * 59 + this.Category.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - if (this.PhotoUrls != null) - hashCode = hashCode * 59 + this.PhotoUrls.GetHashCode(); - if (this.Tags != null) - hashCode = hashCode * 59 + this.Tags.GetHashCode(); - hashCode = hashCode * 59 + this.Status.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pig.cs index ffdc73846d65..21b2e0a762b4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pig.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Quadrilateral.cs index 0a5cffe71db5..da86f463e0ea 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index e7727cf856c9..f2f9c3cd3ec4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,15 +37,17 @@ protected QuadrilateralInterface() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// quadrilateralType (required). - public QuadrilateralInterface(string quadrilateralType = default(string)) + public QuadrilateralInterface(string quadrilateralType) { // to ensure "quadrilateralType" is required (not null) - this.QuadrilateralType = quadrilateralType ?? throw new ArgumentNullException("quadrilateralType is a required property for QuadrilateralInterface and cannot be null"); - this.AdditionalProperties = new Dictionary(); + QuadrilateralType = quadrilateralType ?? throw new ArgumentNullException("quadrilateralType is a required property for QuadrilateralInterface and cannot be null"); + + AdditionalProperties = new Dictionary(); } /// @@ -71,8 +70,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class QuadrilateralInterface {\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -81,9 +80,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -91,7 +90,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as QuadrilateralInterface).AreEqual; } @@ -101,28 +100,11 @@ public override bool Equals(object input) /// /// Instance of QuadrilateralInterface to be compared /// Boolean - public bool Equals(QuadrilateralInterface input) + public bool Equals(QuadrilateralInterface? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.QuadrilateralType != null) - hashCode = hashCode * 59 + this.QuadrilateralType.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index 4ab8f7d5c6a8..7d091650a0c8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class ReadOnlyFirst : IEquatable, IValidatableObje /// Initializes a new instance of the class. /// /// baz. - public ReadOnlyFirst(string baz = default(string)) + public ReadOnlyFirst(string baz) { - this.Baz = baz; - this.AdditionalProperties = new Dictionary(); + Baz = baz; + AdditionalProperties = new Dictionary(); } /// @@ -77,9 +74,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ReadOnlyFirst {\n"); - sb.Append(" Bar: ").Append(Bar).Append("\n"); - sb.Append(" Baz: ").Append(Baz).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Bar: ").Append(Bar).Append('\n'); + sb.Append(" Baz: ").Append(Baz).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -88,9 +85,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -98,7 +95,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ReadOnlyFirst).AreEqual; } @@ -108,30 +105,11 @@ public override bool Equals(object input) /// /// Instance of ReadOnlyFirst to be compared /// Boolean - public bool Equals(ReadOnlyFirst input) + public bool Equals(ReadOnlyFirst? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Bar != null) - hashCode = hashCode * 59 + this.Bar.GetHashCode(); - if (this.Baz != null) - hashCode = hashCode * 59 + this.Baz.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Return.cs index 75e7f1f25305..6761ae446861 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Return.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class Return : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// /// _return. - public Return(int _return = default(int)) + public Return(int _return) { - this._Return = _return; - this.AdditionalProperties = new Dictionary(); + _Return = _return; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Return {\n"); - sb.Append(" _Return: ").Append(_Return).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" _Return: ").Append(_Return).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Return).AreEqual; } @@ -92,27 +89,11 @@ public override bool Equals(object input) /// /// Instance of Return to be compared /// Boolean - public bool Equals(Return input) + public bool Equals(Return? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this._Return.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index c539590907c7..6a6b5cc22ba1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,18 +37,21 @@ protected ScaleneTriangle() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// shapeType (required). /// triangleType (required). - public ScaleneTriangle(string shapeType = default(string), string triangleType = default(string)) + public ScaleneTriangle(string shapeType, string triangleType) { // to ensure "shapeType" is required (not null) - this.ShapeType = shapeType ?? throw new ArgumentNullException("shapeType is a required property for ScaleneTriangle and cannot be null"); + ShapeType = shapeType ?? throw new ArgumentNullException("shapeType is a required property for ScaleneTriangle and cannot be null"); + // to ensure "triangleType" is required (not null) - this.TriangleType = triangleType ?? throw new ArgumentNullException("triangleType is a required property for ScaleneTriangle and cannot be null"); - this.AdditionalProperties = new Dictionary(); + TriangleType = triangleType ?? throw new ArgumentNullException("triangleType is a required property for ScaleneTriangle and cannot be null"); + + AdditionalProperties = new Dictionary(); } /// @@ -80,9 +80,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ScaleneTriangle {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append('\n'); + sb.Append(" TriangleType: ").Append(TriangleType).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -91,9 +91,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -101,7 +101,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ScaleneTriangle).AreEqual; } @@ -111,30 +111,11 @@ public override bool Equals(object input) /// /// Instance of ScaleneTriangle to be compared /// Boolean - public bool Equals(ScaleneTriangle input) + public bool Equals(ScaleneTriangle? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.ShapeType != null) - hashCode = hashCode * 59 + this.ShapeType.GetHashCode(); - if (this.TriangleType != null) - hashCode = hashCode * 59 + this.TriangleType.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Shape.cs index 7db4ac390609..eb423409664a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Shape.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeInterface.cs index 051100b4e6c1..6fb5a6cfd587 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,15 +37,17 @@ protected ShapeInterface() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// shapeType (required). - public ShapeInterface(string shapeType = default(string)) + public ShapeInterface(string shapeType) { // to ensure "shapeType" is required (not null) - this.ShapeType = shapeType ?? throw new ArgumentNullException("shapeType is a required property for ShapeInterface and cannot be null"); - this.AdditionalProperties = new Dictionary(); + ShapeType = shapeType ?? throw new ArgumentNullException("shapeType is a required property for ShapeInterface and cannot be null"); + + AdditionalProperties = new Dictionary(); } /// @@ -71,8 +70,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class ShapeInterface {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -81,9 +80,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -91,7 +90,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ShapeInterface).AreEqual; } @@ -101,28 +100,11 @@ public override bool Equals(object input) /// /// Instance of ShapeInterface to be compared /// Boolean - public bool Equals(ShapeInterface input) + public bool Equals(ShapeInterface? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.ShapeType != null) - hashCode = hashCode * 59 + this.ShapeType.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 11456f9c653a..9f7b832d74a7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index 5280a0c308a7..df65c3f42a79 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,18 +37,21 @@ protected SimpleQuadrilateral() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// shapeType (required). /// quadrilateralType (required). - public SimpleQuadrilateral(string shapeType = default(string), string quadrilateralType = default(string)) + public SimpleQuadrilateral(string shapeType, string quadrilateralType) { // to ensure "shapeType" is required (not null) - this.ShapeType = shapeType ?? throw new ArgumentNullException("shapeType is a required property for SimpleQuadrilateral and cannot be null"); + ShapeType = shapeType ?? throw new ArgumentNullException("shapeType is a required property for SimpleQuadrilateral and cannot be null"); + // to ensure "quadrilateralType" is required (not null) - this.QuadrilateralType = quadrilateralType ?? throw new ArgumentNullException("quadrilateralType is a required property for SimpleQuadrilateral and cannot be null"); - this.AdditionalProperties = new Dictionary(); + QuadrilateralType = quadrilateralType ?? throw new ArgumentNullException("quadrilateralType is a required property for SimpleQuadrilateral and cannot be null"); + + AdditionalProperties = new Dictionary(); } /// @@ -80,9 +80,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class SimpleQuadrilateral {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append('\n'); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -91,9 +91,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -101,7 +101,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as SimpleQuadrilateral).AreEqual; } @@ -111,30 +111,11 @@ public override bool Equals(object input) /// /// Instance of SimpleQuadrilateral to be compared /// Boolean - public bool Equals(SimpleQuadrilateral input) + public bool Equals(SimpleQuadrilateral? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.ShapeType != null) - hashCode = hashCode * 59 + this.ShapeType.GetHashCode(); - if (this.QuadrilateralType != null) - hashCode = hashCode * 59 + this.QuadrilateralType.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SpecialModelName.cs index f7199da4c03c..b58a5a1b2261 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -36,10 +33,10 @@ public partial class SpecialModelName : IEquatable, IValidatab /// Initializes a new instance of the class. /// /// specialPropertyName. - public SpecialModelName(long specialPropertyName = default(long)) + public SpecialModelName(long specialPropertyName) { - this.SpecialPropertyName = specialPropertyName; - this.AdditionalProperties = new Dictionary(); + SpecialPropertyName = specialPropertyName; + AdditionalProperties = new Dictionary(); } /// @@ -62,8 +59,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class SpecialModelName {\n"); - sb.Append(" SpecialPropertyName: ").Append(SpecialPropertyName).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" SpecialPropertyName: ").Append(SpecialPropertyName).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -72,9 +69,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -82,7 +79,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as SpecialModelName).AreEqual; } @@ -92,27 +89,11 @@ public override bool Equals(object input) /// /// Instance of SpecialModelName to be compared /// Boolean - public bool Equals(SpecialModelName input) + public bool Equals(SpecialModelName? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.SpecialPropertyName.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Tag.cs index aba43e338beb..c37c15bbb877 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Tag.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -37,11 +34,11 @@ public partial class Tag : IEquatable, IValidatableObject /// /// id. /// name. - public Tag(long id = default(long), string name = default(string)) + public Tag(long id, string name) { - this.Id = id; - this.Name = name; - this.AdditionalProperties = new Dictionary(); + Id = id; + Name = name; + AdditionalProperties = new Dictionary(); } /// @@ -70,9 +67,9 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Tag {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Id: ").Append(Id).Append('\n'); + sb.Append(" Name: ").Append(Name).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -81,9 +78,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -91,7 +88,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Tag).AreEqual; } @@ -101,29 +98,11 @@ public override bool Equals(object input) /// /// Instance of Tag to be compared /// Boolean - public bool Equals(Tag input) + public bool Equals(Tag? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Triangle.cs index efe1b3483995..f29150228df5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Triangle.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using JsonSubTypes; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/TriangleInterface.cs index 4b7274465ce0..a63bba46a983 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,15 +37,17 @@ protected TriangleInterface() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// triangleType (required). - public TriangleInterface(string triangleType = default(string)) + public TriangleInterface(string triangleType) { // to ensure "triangleType" is required (not null) - this.TriangleType = triangleType ?? throw new ArgumentNullException("triangleType is a required property for TriangleInterface and cannot be null"); - this.AdditionalProperties = new Dictionary(); + TriangleType = triangleType ?? throw new ArgumentNullException("triangleType is a required property for TriangleInterface and cannot be null"); + + AdditionalProperties = new Dictionary(); } /// @@ -71,8 +70,8 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class TriangleInterface {\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" TriangleType: ").Append(TriangleType).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -81,9 +80,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -91,7 +90,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as TriangleInterface).AreEqual; } @@ -101,28 +100,11 @@ public override bool Equals(object input) /// /// Instance of TriangleInterface to be compared /// Boolean - public bool Equals(TriangleInterface input) + public bool Equals(TriangleInterface? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.TriangleType != null) - hashCode = hashCode * 59 + this.TriangleType.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/User.cs index ea24f093e147..acc36e28c7ca 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/User.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -47,21 +44,21 @@ public partial class User : IEquatable, IValidatableObject /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value.. /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389. /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values.. - public User(long id = default(long), string username = default(string), string firstName = default(string), string lastName = default(string), string email = default(string), string password = default(string), string phone = default(string), int userStatus = default(int), Object objectWithNoDeclaredProps = default(Object), Object objectWithNoDeclaredPropsNullable = default(Object), Object anyTypeProp = default(Object), Object anyTypePropNullable = default(Object)) + public User(long id, string username, string firstName, string lastName, string email, string password, string phone, int userStatus, Object objectWithNoDeclaredProps, Object objectWithNoDeclaredPropsNullable, Object anyTypeProp, Object anyTypePropNullable) { - this.Id = id; - this.Username = username; - this.FirstName = firstName; - this.LastName = lastName; - this.Email = email; - this.Password = password; - this.Phone = phone; - this.UserStatus = userStatus; - this.ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; - this.ObjectWithNoDeclaredPropsNullable = objectWithNoDeclaredPropsNullable; - this.AnyTypeProp = anyTypeProp; - this.AnyTypePropNullable = anyTypePropNullable; - this.AdditionalProperties = new Dictionary(); + Id = id; + Username = username; + FirstName = firstName; + LastName = lastName; + Email = email; + Password = password; + Phone = phone; + UserStatus = userStatus; + ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; + ObjectWithNoDeclaredPropsNullable = objectWithNoDeclaredPropsNullable; + AnyTypeProp = anyTypeProp; + AnyTypePropNullable = anyTypePropNullable; + AdditionalProperties = new Dictionary(); } /// @@ -155,19 +152,19 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class User {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Username: ").Append(Username).Append("\n"); - sb.Append(" FirstName: ").Append(FirstName).Append("\n"); - sb.Append(" LastName: ").Append(LastName).Append("\n"); - sb.Append(" Email: ").Append(Email).Append("\n"); - sb.Append(" Password: ").Append(Password).Append("\n"); - sb.Append(" Phone: ").Append(Phone).Append("\n"); - sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); - sb.Append(" ObjectWithNoDeclaredProps: ").Append(ObjectWithNoDeclaredProps).Append("\n"); - sb.Append(" ObjectWithNoDeclaredPropsNullable: ").Append(ObjectWithNoDeclaredPropsNullable).Append("\n"); - sb.Append(" AnyTypeProp: ").Append(AnyTypeProp).Append("\n"); - sb.Append(" AnyTypePropNullable: ").Append(AnyTypePropNullable).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" Id: ").Append(Id).Append('\n'); + sb.Append(" Username: ").Append(Username).Append('\n'); + sb.Append(" FirstName: ").Append(FirstName).Append('\n'); + sb.Append(" LastName: ").Append(LastName).Append('\n'); + sb.Append(" Email: ").Append(Email).Append('\n'); + sb.Append(" Password: ").Append(Password).Append('\n'); + sb.Append(" Phone: ").Append(Phone).Append('\n'); + sb.Append(" UserStatus: ").Append(UserStatus).Append('\n'); + sb.Append(" ObjectWithNoDeclaredProps: ").Append(ObjectWithNoDeclaredProps).Append('\n'); + sb.Append(" ObjectWithNoDeclaredPropsNullable: ").Append(ObjectWithNoDeclaredPropsNullable).Append('\n'); + sb.Append(" AnyTypeProp: ").Append(AnyTypeProp).Append('\n'); + sb.Append(" AnyTypePropNullable: ").Append(AnyTypePropNullable).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -176,9 +173,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -186,7 +183,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as User).AreEqual; } @@ -196,48 +193,11 @@ public override bool Equals(object input) /// /// Instance of User to be compared /// Boolean - public bool Equals(User input) + public bool Equals(User? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - if (this.Username != null) - hashCode = hashCode * 59 + this.Username.GetHashCode(); - if (this.FirstName != null) - hashCode = hashCode * 59 + this.FirstName.GetHashCode(); - if (this.LastName != null) - hashCode = hashCode * 59 + this.LastName.GetHashCode(); - if (this.Email != null) - hashCode = hashCode * 59 + this.Email.GetHashCode(); - if (this.Password != null) - hashCode = hashCode * 59 + this.Password.GetHashCode(); - if (this.Phone != null) - hashCode = hashCode * 59 + this.Phone.GetHashCode(); - hashCode = hashCode * 59 + this.UserStatus.GetHashCode(); - if (this.ObjectWithNoDeclaredProps != null) - hashCode = hashCode * 59 + this.ObjectWithNoDeclaredProps.GetHashCode(); - if (this.ObjectWithNoDeclaredPropsNullable != null) - hashCode = hashCode * 59 + this.ObjectWithNoDeclaredPropsNullable.GetHashCode(); - if (this.AnyTypeProp != null) - hashCode = hashCode * 59 + this.AnyTypeProp.GetHashCode(); - if (this.AnyTypePropNullable != null) - hashCode = hashCode * 59 + this.AnyTypePropNullable.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Whale.cs index fdecfefd6790..710cf59ce73e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Whale.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -40,19 +37,21 @@ protected Whale() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// hasBaleen. /// hasTeeth. /// className (required). - public Whale(bool hasBaleen = default(bool), bool hasTeeth = default(bool), string className = default(string)) + public Whale(bool hasBaleen, bool hasTeeth, string className) { // to ensure "className" is required (not null) - this.ClassName = className ?? throw new ArgumentNullException("className is a required property for Whale and cannot be null"); - this.HasBaleen = hasBaleen; - this.HasTeeth = hasTeeth; - this.AdditionalProperties = new Dictionary(); + ClassName = className ?? throw new ArgumentNullException("className is a required property for Whale and cannot be null"); + + HasBaleen = hasBaleen; + HasTeeth = hasTeeth; + AdditionalProperties = new Dictionary(); } /// @@ -87,10 +86,10 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Whale {\n"); - sb.Append(" HasBaleen: ").Append(HasBaleen).Append("\n"); - sb.Append(" HasTeeth: ").Append(HasTeeth).Append("\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" HasBaleen: ").Append(HasBaleen).Append('\n'); + sb.Append(" HasTeeth: ").Append(HasTeeth).Append('\n'); + sb.Append(" ClassName: ").Append(ClassName).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -99,9 +98,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -109,7 +108,7 @@ public virtual string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Whale).AreEqual; } @@ -119,30 +118,11 @@ public override bool Equals(object input) /// /// Instance of Whale to be compared /// Boolean - public bool Equals(Whale input) + public bool Equals(Whale? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.HasBaleen.GetHashCode(); - hashCode = hashCode * 59 + this.HasTeeth.GetHashCode(); - if (this.ClassName != null) - hashCode = hashCode * 59 + this.ClassName.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs index cd2f85fe1acd..5ad638bcee37 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs @@ -17,9 +17,6 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; @@ -35,7 +32,7 @@ public partial class Zebra : Dictionary, IEquatable, IVal /// /// Defines Type /// - [JsonConverter(typeof(StringEnumConverter))] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public enum TypeEnum { /// @@ -63,6 +60,7 @@ public enum TypeEnum /// [DataMember(Name = "type", EmitDefaultValue = false)] public TypeEnum? Type { get; set; } + /// /// Initializes a new instance of the class. /// @@ -71,17 +69,19 @@ protected Zebra() { this.AdditionalProperties = new Dictionary(); } + /// /// Initializes a new instance of the class. /// /// type. /// className (required). - public Zebra(TypeEnum? type = default(TypeEnum?), string className = default(string)) : base() + public Zebra(TypeEnum? type, string className) : base() { // to ensure "className" is required (not null) - this.ClassName = className ?? throw new ArgumentNullException("className is a required property for Zebra and cannot be null"); - this.Type = type; - this.AdditionalProperties = new Dictionary(); + ClassName = className ?? throw new ArgumentNullException("className is a required property for Zebra and cannot be null"); + + Type = type; + AdditionalProperties = new Dictionary(); } /// @@ -104,10 +104,10 @@ public override string ToString() { var sb = new StringBuilder(); sb.Append("class Zebra {\n"); - sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" Type: ").Append(Type).Append("\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append('\n'); + sb.Append(" Type: ").Append(Type).Append('\n'); + sb.Append(" ClassName: ").Append(ClassName).Append('\n'); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -116,9 +116,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public string ToJson() + public string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); } /// @@ -126,7 +126,7 @@ public string ToJson() /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Zebra).AreEqual; } @@ -136,29 +136,11 @@ public override bool Equals(object input) /// /// Instance of Zebra to be compared /// Boolean - public bool Equals(Zebra input) + public bool Equals(Zebra? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = base.GetHashCode(); - hashCode = hashCode * 59 + this.Type.GetHashCode(); - if (this.ClassName != null) - hashCode = hashCode * 59 + this.ClassName.GetHashCode(); - if (this.AdditionalProperties != null) - hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 071bebff46e6..ae0231709284 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -22,12 +22,12 @@ - + - - + - + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/GmFruit.cs index c168aa41d4ce..f03086f114ac 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/GmFruit.cs @@ -23,6 +23,7 @@ using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/GmFruit.cs index c168aa41d4ce..f03086f114ac 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/GmFruit.cs @@ -23,6 +23,7 @@ using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/GmFruit.cs index c168aa41d4ce..f03086f114ac 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/GmFruit.cs @@ -23,6 +23,7 @@ using System.ComponentModel.DataAnnotations; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; namespace Org.OpenAPITools.Model { diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES b/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES index 29f9ff544d92..4f2382c7e38d 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES @@ -1,7 +1,10 @@ .gitignore README.md +apis/PetApi.service.ts apis/PetApi.ts +apis/StoreApi.service.ts apis/StoreApi.ts +apis/UserApi.service.ts apis/UserApi.ts apis/baseapi.ts apis/exception.ts @@ -23,6 +26,12 @@ models/all.ts package.json rxjsStub.ts servers.ts +services/ObjectParamAPI.ts +services/ObservableAPI.ts +services/PromiseAPI.ts +services/configuration.ts +services/http.ts +services/index.ts tsconfig.json types/ObjectParamAPI.ts types/ObservableAPI.ts diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts index 7041341a7089..c97b44cf0893 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts @@ -6,6 +6,7 @@ import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; +import { injectable } from "inversify"; import { ApiResponse } from '../models/ApiResponse'; import { Pet } from '../models/Pet'; @@ -13,6 +14,7 @@ import { Pet } from '../models/Pet'; /** * no description */ +@injectable() export class PetApiRequestFactory extends BaseAPIRequestFactory { /** @@ -397,6 +399,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { +@injectable() export class PetApiResponseProcessor { /** diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts index 09400e99c083..ceef209c37db 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts @@ -6,12 +6,14 @@ import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; +import { injectable } from "inversify"; import { Order } from '../models/Order'; /** * no description */ +@injectable() export class StoreApiRequestFactory extends BaseAPIRequestFactory { /** @@ -166,6 +168,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { +@injectable() export class StoreApiResponseProcessor { /** diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts index 1d43ec7a72b4..353bae433c58 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts @@ -6,12 +6,14 @@ import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; +import { injectable } from "inversify"; import { User } from '../models/User'; /** * no description */ +@injectable() export class UserApiRequestFactory extends BaseAPIRequestFactory { /** @@ -375,6 +377,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { +@injectable() export class UserApiResponseProcessor { /** diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts index fe7ee3d15118..cf8fec079eb3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts @@ -1,4 +1,6 @@ import { Configuration } from '../configuration' +import { injectable, inject } from "inversify"; +import { AbstractConfiguration } from "../services/configuration"; /** * @@ -17,9 +19,10 @@ export const COLLECTION_FORMATS = { * @export * @class BaseAPI */ +@injectable() export class BaseAPIRequestFactory { - constructor(protected configuration: Configuration) { + constructor(@inject(AbstractConfiguration) protected configuration: Configuration) { } }; diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts index 9d59a0a25580..13e3b17fa825 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts @@ -2,6 +2,8 @@ //@ts-ignore import * as btoa from "btoa"; import { RequestContext } from "../http/http"; +import { injectable, inject, named } from "inversify"; +import { AbstractTokenProvider } from "../services/configuration"; /** * Interface authentication schemes. @@ -20,6 +22,10 @@ export interface SecurityAuthentication { applySecurityAuthentication(context: RequestContext): void | Promise; } +export const AuthApiKey = Symbol("auth.api_key"); +export const AuthUsername = Symbol("auth.username"); +export const AuthPassword = Symbol("auth.password"); + export interface TokenProvider { getToken(): Promise | string; } @@ -27,13 +33,14 @@ export interface TokenProvider { /** * Applies apiKey authentication to the request context. */ +@injectable() export class ApiKeyAuthentication implements SecurityAuthentication { /** * Configures this api key authentication with the necessary properties * * @param apiKey: The api key to be used for every request */ - public constructor(private apiKey: string) {} + public constructor(@inject(AuthApiKey) @named("api_key") private apiKey: string) {} public getName(): string { return "api_key"; @@ -47,6 +54,7 @@ export class ApiKeyAuthentication implements SecurityAuthentication { /** * Applies oauth2 authentication to the request context. */ +@injectable() export class PetstoreAuthAuthentication implements SecurityAuthentication { // TODO: How to handle oauth2 authentication! public constructor() {} @@ -66,6 +74,11 @@ export type AuthMethods = { "petstore_auth"?: SecurityAuthentication } +export const authMethodServices = { + "api_key": ApiKeyAuthentication, + "petstore_auth": PetstoreAuthAuthentication +} + export type ApiKeyConfiguration = string; export type HttpBasicConfiguration = { "username": string, "password": string }; export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts index de89bb05e702..4d48e5222adf 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts @@ -9,3 +9,5 @@ export * from "./servers"; export { PromiseMiddleware as Middleware } from './middleware'; export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI'; +export * from "./services/index"; +export { AbstractPromisePetApi as AbstractPetApi, AbstractPromiseStoreApi as AbstractStoreApi, AbstractPromiseUserApi as AbstractUserApi } from './services/PromiseAPI'; diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/package.json b/samples/openapi3/client/petstore/typescript/builds/inversify/package.json index f26767636102..71908ad48cae 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/package.json +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/package.json @@ -22,6 +22,7 @@ "@types/node": "*", "form-data": "^2.5.0", "btoa": "^1.2.1", + "inversify": "^5.0.1", "es6-promise": "^4.2.4", "url-parse": "^1.4.3" }, diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json b/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json index a542d795677c..b53dce7b41b3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json @@ -18,6 +18,7 @@ "outDir": "./dist", "noLib": false, "lib": [ "es6" ], + "experimentalDecorators": true, }, "exclude": [ "dist", diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts index 6154d267ed3a..31ced8bbdca3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts @@ -3,6 +3,8 @@ import * as models from '../models/all'; import { Configuration} from '../configuration' import { Observable, of, from } from '../rxjsStub'; import {mergeMap, map} from '../rxjsStub'; +import { injectable, inject, optional } from "inversify"; +import { AbstractConfiguration } from "../services/configuration"; import { ApiResponse } from '../models/ApiResponse'; import { Category } from '../models/Category'; @@ -12,15 +14,18 @@ import { Tag } from '../models/Tag'; import { User } from '../models/User'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; +import { AbstractPetApiRequestFactory, AbstractPetApiResponseProcessor } from "../apis/PetApi.service"; + +@injectable() export class ObservablePetApi { - private requestFactory: PetApiRequestFactory; - private responseProcessor: PetApiResponseProcessor; + private requestFactory: AbstractPetApiRequestFactory; + private responseProcessor: AbstractPetApiResponseProcessor; private configuration: Configuration; public constructor( - configuration: Configuration, - requestFactory?: PetApiRequestFactory, - responseProcessor?: PetApiResponseProcessor + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractPetApiRequestFactory) @optional() requestFactory?: AbstractPetApiRequestFactory, + @inject(AbstractPetApiResponseProcessor) @optional() responseProcessor?: AbstractPetApiResponseProcessor ) { this.configuration = configuration; this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); @@ -226,15 +231,18 @@ export class ObservablePetApi { import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; +import { AbstractStoreApiRequestFactory, AbstractStoreApiResponseProcessor } from "../apis/StoreApi.service"; + +@injectable() export class ObservableStoreApi { - private requestFactory: StoreApiRequestFactory; - private responseProcessor: StoreApiResponseProcessor; + private requestFactory: AbstractStoreApiRequestFactory; + private responseProcessor: AbstractStoreApiResponseProcessor; private configuration: Configuration; public constructor( - configuration: Configuration, - requestFactory?: StoreApiRequestFactory, - responseProcessor?: StoreApiResponseProcessor + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractStoreApiRequestFactory) @optional() requestFactory?: AbstractStoreApiRequestFactory, + @inject(AbstractStoreApiResponseProcessor) @optional() responseProcessor?: AbstractStoreApiResponseProcessor ) { this.configuration = configuration; this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); @@ -342,15 +350,18 @@ export class ObservableStoreApi { import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; +import { AbstractUserApiRequestFactory, AbstractUserApiResponseProcessor } from "../apis/UserApi.service"; + +@injectable() export class ObservableUserApi { - private requestFactory: UserApiRequestFactory; - private responseProcessor: UserApiResponseProcessor; + private requestFactory: AbstractUserApiRequestFactory; + private responseProcessor: AbstractUserApiResponseProcessor; private configuration: Configuration; public constructor( - configuration: Configuration, - requestFactory?: UserApiRequestFactory, - responseProcessor?: UserApiResponseProcessor + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractUserApiRequestFactory) @optional() requestFactory?: AbstractUserApiRequestFactory, + @inject(AbstractUserApiResponseProcessor) @optional() responseProcessor?: AbstractUserApiResponseProcessor ) { this.configuration = configuration; this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts index 533095a405d6..6077fdac2d59 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts @@ -1,6 +1,8 @@ import { ResponseContext, RequestContext, HttpFile } from '../http/http'; import * as models from '../models/all'; import { Configuration} from '../configuration' +import { injectable, inject, optional } from "inversify"; +import { AbstractConfiguration } from "../services/configuration"; import { ApiResponse } from '../models/ApiResponse'; import { Category } from '../models/Category'; @@ -12,13 +14,16 @@ import { ObservablePetApi } from './ObservableAPI'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; +import { AbstractPetApiRequestFactory, AbstractPetApiResponseProcessor } from "../apis/PetApi.service"; + +@injectable() export class PromisePetApi { private api: ObservablePetApi public constructor( - configuration: Configuration, - requestFactory?: PetApiRequestFactory, - responseProcessor?: PetApiResponseProcessor + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractPetApiRequestFactory) @optional() requestFactory?: AbstractPetApiRequestFactory, + @inject(AbstractPetApiResponseProcessor) @optional() responseProcessor?: AbstractPetApiResponseProcessor ) { this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); } @@ -112,13 +117,16 @@ import { ObservableStoreApi } from './ObservableAPI'; import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; +import { AbstractStoreApiRequestFactory, AbstractStoreApiResponseProcessor } from "../apis/StoreApi.service"; + +@injectable() export class PromiseStoreApi { private api: ObservableStoreApi public constructor( - configuration: Configuration, - requestFactory?: StoreApiRequestFactory, - responseProcessor?: StoreApiResponseProcessor + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractStoreApiRequestFactory) @optional() requestFactory?: AbstractStoreApiRequestFactory, + @inject(AbstractStoreApiResponseProcessor) @optional() responseProcessor?: AbstractStoreApiResponseProcessor ) { this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); } @@ -170,13 +178,16 @@ import { ObservableUserApi } from './ObservableAPI'; import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; +import { AbstractUserApiRequestFactory, AbstractUserApiResponseProcessor } from "../apis/UserApi.service"; + +@injectable() export class PromiseUserApi { private api: ObservableUserApi public constructor( - configuration: Configuration, - requestFactory?: UserApiRequestFactory, - responseProcessor?: UserApiResponseProcessor + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractUserApiRequestFactory) @optional() requestFactory?: AbstractUserApiRequestFactory, + @inject(AbstractUserApiResponseProcessor) @optional() responseProcessor?: AbstractUserApiResponseProcessor ) { this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); } diff --git a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/PetApi.kt b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/PetApi.kt index 3ac3578638d5..1c2b5967d0f1 100644 --- a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/PetApi.kt +++ b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/PetApi.kt @@ -1,80 +1,80 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* The version of the OpenAPI document: 1.0.0 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ -package org.openapitools.server.apis - -import com.google.gson.Gson -import io.ktor.application.call -import io.ktor.auth.UserIdPrincipal -import io.ktor.auth.authentication -import io.ktor.auth.authenticate -import io.ktor.auth.OAuthAccessTokenResponse -import io.ktor.auth.OAuthServerSettings -import io.ktor.http.ContentType -import io.ktor.http.HttpStatusCode -import io.ktor.locations.KtorExperimentalLocationsAPI -import io.ktor.locations.delete -import io.ktor.locations.get -import io.ktor.response.respond -import io.ktor.response.respondText -import io.ktor.routing.Route -import io.ktor.routing.post -import io.ktor.routing.put -import io.ktor.routing.route - -import org.openapitools.server.Paths -import org.openapitools.server.infrastructure.ApiPrincipal - - -import org.openapitools.server.models.ApiResponse -import org.openapitools.server.models.Pet - -@KtorExperimentalLocationsAPI -fun Route.PetApi() { - val gson = Gson() - val empty = mutableMapOf() - - route("/pet") { - authenticate("petstore_auth") { - post { - val principal = call.authentication.principal() - - if (principal == null) { - call.respond(HttpStatusCode.Unauthorized) - } else { - call.respond(HttpStatusCode.NotImplemented) - } - } - } - } - - - delete { _: Paths.deletePet -> - val principal = call.authentication.principal() - - if (principal == null) { - call.respond(HttpStatusCode.Unauthorized) - } else { - call.respond(HttpStatusCode.NotImplemented) - } - } - - - get { _: Paths.findPetsByStatus -> - val principal = call.authentication.principal() - - if (principal == null) { - call.respond(HttpStatusCode.Unauthorized) - } else { - val exampleContentType = "application/json" +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.server.apis + +import com.google.gson.Gson +import io.ktor.application.call +import io.ktor.auth.UserIdPrincipal +import io.ktor.auth.authentication +import io.ktor.auth.authenticate +import io.ktor.auth.OAuthAccessTokenResponse +import io.ktor.auth.OAuthServerSettings +import io.ktor.http.ContentType +import io.ktor.http.HttpStatusCode +import io.ktor.locations.KtorExperimentalLocationsAPI +import io.ktor.locations.delete +import io.ktor.locations.get +import io.ktor.response.respond +import io.ktor.response.respondText +import io.ktor.routing.Route +import io.ktor.routing.post +import io.ktor.routing.put +import io.ktor.routing.route + +import org.openapitools.server.Paths +import org.openapitools.server.infrastructure.ApiPrincipal + + +import org.openapitools.server.models.ApiResponse +import org.openapitools.server.models.Pet + +@KtorExperimentalLocationsAPI +fun Route.PetApi() { + val gson = Gson() + val empty = mutableMapOf() + + route("/pet") { + authenticate("petstore_auth") { + post { + val principal = call.authentication.principal() + + if (principal == null) { + call.respond(HttpStatusCode.Unauthorized) + } else { + call.respond(HttpStatusCode.NotImplemented) + } + } + } + } + + + delete { _: Paths.deletePet -> + val principal = call.authentication.principal() + + if (principal == null) { + call.respond(HttpStatusCode.Unauthorized) + } else { + call.respond(HttpStatusCode.NotImplemented) + } + } + + + get { _: Paths.findPetsByStatus -> + val principal = call.authentication.principal() + + if (principal == null) { + call.respond(HttpStatusCode.Unauthorized) + } else { + val exampleContentType = "application/json" val exampleContentString = """{ "photoUrls" : [ "photoUrls", "photoUrls" ], "name" : "doggie", @@ -91,24 +91,24 @@ fun Route.PetApi() { "id" : 1 } ], "status" : "available" - }""" - - when(exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - - - get { _: Paths.findPetsByTags -> - val principal = call.authentication.principal() - - if (principal == null) { - call.respond(HttpStatusCode.Unauthorized) - } else { - val exampleContentType = "application/json" + }""" + + when(exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + + + get { _: Paths.findPetsByTags -> + val principal = call.authentication.principal() + + if (principal == null) { + call.respond(HttpStatusCode.Unauthorized) + } else { + val exampleContentType = "application/json" val exampleContentString = """{ "photoUrls" : [ "photoUrls", "photoUrls" ], "name" : "doggie", @@ -125,24 +125,24 @@ fun Route.PetApi() { "id" : 1 } ], "status" : "available" - }""" - - when(exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - - - get { _: Paths.getPetById -> - val principal = call.authentication.principal() - - if (principal == null) { - call.respond(HttpStatusCode.Unauthorized) - } else { - val exampleContentType = "application/json" + }""" + + when(exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + + + get { _: Paths.getPetById -> + val principal = call.authentication.principal() + + if (principal == null) { + call.respond(HttpStatusCode.Unauthorized) + } else { + val exampleContentType = "application/json" val exampleContentString = """{ "photoUrls" : [ "photoUrls", "photoUrls" ], "name" : "doggie", @@ -159,70 +159,70 @@ fun Route.PetApi() { "id" : 1 } ], "status" : "available" - }""" - - when(exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - - - route("/pet") { - authenticate("petstore_auth") { - put { - val principal = call.authentication.principal() - - if (principal == null) { - call.respond(HttpStatusCode.Unauthorized) - } else { - call.respond(HttpStatusCode.NotImplemented) - } - } - } - } - - - route("/pet/{petId}") { - authenticate("petstore_auth") { - post { - val principal = call.authentication.principal() - - if (principal == null) { - call.respond(HttpStatusCode.Unauthorized) - } else { - call.respond(HttpStatusCode.NotImplemented) - } - } - } - } - - - route("/pet/{petId}/uploadImage") { - authenticate("petstore_auth") { - post { - val principal = call.authentication.principal() - - if (principal == null) { - call.respond(HttpStatusCode.Unauthorized) - } else { - val exampleContentType = "application/json" + }""" + + when(exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + + + route("/pet") { + authenticate("petstore_auth") { + put { + val principal = call.authentication.principal() + + if (principal == null) { + call.respond(HttpStatusCode.Unauthorized) + } else { + call.respond(HttpStatusCode.NotImplemented) + } + } + } + } + + + route("/pet/{petId}") { + authenticate("petstore_auth") { + post { + val principal = call.authentication.principal() + + if (principal == null) { + call.respond(HttpStatusCode.Unauthorized) + } else { + call.respond(HttpStatusCode.NotImplemented) + } + } + } + } + + + route("/pet/{petId}/uploadImage") { + authenticate("petstore_auth") { + post { + val principal = call.authentication.principal() + + if (principal == null) { + call.respond(HttpStatusCode.Unauthorized) + } else { + val exampleContentType = "application/json" val exampleContentString = """{ "code" : 0, "type" : "type", "message" : "message" - }""" - - when(exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - } - } - -} + }""" + + when(exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + } + } + +} diff --git a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt index 17b2c526bd9c..121bf3357879 100644 --- a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt +++ b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt @@ -1,64 +1,64 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* The version of the OpenAPI document: 1.0.0 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ -package org.openapitools.server.apis - -import com.google.gson.Gson -import io.ktor.application.call -import io.ktor.auth.UserIdPrincipal -import io.ktor.auth.authentication -import io.ktor.auth.authenticate -import io.ktor.auth.OAuthAccessTokenResponse -import io.ktor.auth.OAuthServerSettings -import io.ktor.http.ContentType -import io.ktor.http.HttpStatusCode -import io.ktor.locations.KtorExperimentalLocationsAPI -import io.ktor.locations.delete -import io.ktor.locations.get -import io.ktor.response.respond -import io.ktor.response.respondText -import io.ktor.routing.Route -import io.ktor.routing.post -import io.ktor.routing.put -import io.ktor.routing.route - -import org.openapitools.server.Paths -import org.openapitools.server.infrastructure.ApiPrincipal - - -import org.openapitools.server.models.Order - -@KtorExperimentalLocationsAPI -fun Route.StoreApi() { - val gson = Gson() - val empty = mutableMapOf() - - delete { _: Paths.deleteOrder -> - call.respond(HttpStatusCode.NotImplemented) - } - - - get { _: Paths.getInventory -> - val principal = call.authentication.principal() - - if (principal == null) { - call.respond(HttpStatusCode.Unauthorized) - } else { - call.respond(HttpStatusCode.NotImplemented) - } - } - - - get { _: Paths.getOrderById -> - val exampleContentType = "application/json" +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.server.apis + +import com.google.gson.Gson +import io.ktor.application.call +import io.ktor.auth.UserIdPrincipal +import io.ktor.auth.authentication +import io.ktor.auth.authenticate +import io.ktor.auth.OAuthAccessTokenResponse +import io.ktor.auth.OAuthServerSettings +import io.ktor.http.ContentType +import io.ktor.http.HttpStatusCode +import io.ktor.locations.KtorExperimentalLocationsAPI +import io.ktor.locations.delete +import io.ktor.locations.get +import io.ktor.response.respond +import io.ktor.response.respondText +import io.ktor.routing.Route +import io.ktor.routing.post +import io.ktor.routing.put +import io.ktor.routing.route + +import org.openapitools.server.Paths +import org.openapitools.server.infrastructure.ApiPrincipal + + +import org.openapitools.server.models.Order + +@KtorExperimentalLocationsAPI +fun Route.StoreApi() { + val gson = Gson() + val empty = mutableMapOf() + + delete { _: Paths.deleteOrder -> + call.respond(HttpStatusCode.NotImplemented) + } + + + get { _: Paths.getInventory -> + val principal = call.authentication.principal() + + if (principal == null) { + call.respond(HttpStatusCode.Unauthorized) + } else { + call.respond(HttpStatusCode.NotImplemented) + } + } + + + get { _: Paths.getOrderById -> + val exampleContentType = "application/json" val exampleContentString = """{ "petId" : 6, "quantity" : 1, @@ -66,19 +66,19 @@ fun Route.StoreApi() { "shipDate" : "2000-01-23T04:56:07.000+00:00", "complete" : false, "status" : "placed" - }""" - - when(exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - - - route("/store/order") { - post { - val exampleContentType = "application/json" + }""" + + when(exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + + + route("/store/order") { + post { + val exampleContentType = "application/json" val exampleContentString = """{ "petId" : 6, "quantity" : 1, @@ -86,14 +86,14 @@ fun Route.StoreApi() { "shipDate" : "2000-01-23T04:56:07.000+00:00", "complete" : false, "status" : "placed" - }""" - - when(exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - -} + }""" + + when(exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + +} diff --git a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt index 7fc0b78fa995..91ef11638903 100644 --- a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt +++ b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt @@ -1,74 +1,74 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* The version of the OpenAPI document: 1.0.0 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ -package org.openapitools.server.apis - -import com.google.gson.Gson -import io.ktor.application.call -import io.ktor.auth.UserIdPrincipal -import io.ktor.auth.authentication -import io.ktor.auth.authenticate -import io.ktor.auth.OAuthAccessTokenResponse -import io.ktor.auth.OAuthServerSettings -import io.ktor.http.ContentType -import io.ktor.http.HttpStatusCode -import io.ktor.locations.KtorExperimentalLocationsAPI -import io.ktor.locations.delete -import io.ktor.locations.get -import io.ktor.response.respond -import io.ktor.response.respondText -import io.ktor.routing.Route -import io.ktor.routing.post -import io.ktor.routing.put -import io.ktor.routing.route - -import org.openapitools.server.Paths -import org.openapitools.server.infrastructure.ApiPrincipal - - -import org.openapitools.server.models.User - -@KtorExperimentalLocationsAPI -fun Route.UserApi() { - val gson = Gson() - val empty = mutableMapOf() - - route("/user") { - post { - call.respond(HttpStatusCode.NotImplemented) - } - } - - - route("/user/createWithArray") { - post { - call.respond(HttpStatusCode.NotImplemented) - } - } - - - route("/user/createWithList") { - post { - call.respond(HttpStatusCode.NotImplemented) - } - } - - - delete { _: Paths.deleteUser -> - call.respond(HttpStatusCode.NotImplemented) - } - - - get { _: Paths.getUserByName -> - val exampleContentType = "application/json" +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.server.apis + +import com.google.gson.Gson +import io.ktor.application.call +import io.ktor.auth.UserIdPrincipal +import io.ktor.auth.authentication +import io.ktor.auth.authenticate +import io.ktor.auth.OAuthAccessTokenResponse +import io.ktor.auth.OAuthServerSettings +import io.ktor.http.ContentType +import io.ktor.http.HttpStatusCode +import io.ktor.locations.KtorExperimentalLocationsAPI +import io.ktor.locations.delete +import io.ktor.locations.get +import io.ktor.response.respond +import io.ktor.response.respondText +import io.ktor.routing.Route +import io.ktor.routing.post +import io.ktor.routing.put +import io.ktor.routing.route + +import org.openapitools.server.Paths +import org.openapitools.server.infrastructure.ApiPrincipal + + +import org.openapitools.server.models.User + +@KtorExperimentalLocationsAPI +fun Route.UserApi() { + val gson = Gson() + val empty = mutableMapOf() + + route("/user") { + post { + call.respond(HttpStatusCode.NotImplemented) + } + } + + + route("/user/createWithArray") { + post { + call.respond(HttpStatusCode.NotImplemented) + } + } + + + route("/user/createWithList") { + post { + call.respond(HttpStatusCode.NotImplemented) + } + } + + + delete { _: Paths.deleteUser -> + call.respond(HttpStatusCode.NotImplemented) + } + + + get { _: Paths.getUserByName -> + val exampleContentType = "application/json" val exampleContentString = """{ "firstName" : "firstName", "lastName" : "lastName", @@ -78,30 +78,30 @@ fun Route.UserApi() { "id" : 0, "email" : "email", "username" : "username" - }""" - - when(exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - - - get { _: Paths.loginUser -> - call.respond(HttpStatusCode.NotImplemented) - } - - - get { _: Paths.logoutUser -> - call.respond(HttpStatusCode.NotImplemented) - } - - - route("/user/{username}") { - put { - call.respond(HttpStatusCode.NotImplemented) - } - } - -} + }""" + + when(exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + + + get { _: Paths.loginUser -> + call.respond(HttpStatusCode.NotImplemented) + } + + + get { _: Paths.logoutUser -> + call.respond(HttpStatusCode.NotImplemented) + } + + + route("/user/{username}") { + put { + call.respond(HttpStatusCode.NotImplemented) + } + } + +} From 3ff1172df3c2f4192d4a265bfb6e5acfa0bbe80e Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sun, 17 Jan 2021 21:51:36 -0500 Subject: [PATCH 03/20] refactored models --- .../libraries/httpclient/model.mustache | 44 +++ .../httpclient/modelGeneric.mustache | 322 ++++++++++++++++++ .../httpclient/modelInnerEnum.mustache | 26 ++ .../builds/inversify/.openapi-generator/FILES | 9 + .../builds/inversify/apis/PetApi.ts | 3 + .../builds/inversify/apis/StoreApi.ts | 3 + .../builds/inversify/apis/UserApi.ts | 3 + .../builds/inversify/apis/baseapi.ts | 5 +- .../typescript/builds/inversify/auth/auth.ts | 15 +- .../typescript/builds/inversify/index.ts | 2 + .../typescript/builds/inversify/package.json | 1 + .../typescript/builds/inversify/tsconfig.json | 1 + .../builds/inversify/types/ObservableAPI.ts | 41 ++- .../builds/inversify/types/PromiseAPI.ts | 29 +- 14 files changed, 478 insertions(+), 26 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/model.mustache create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelInnerEnum.mustache diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/model.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/model.mustache new file mode 100644 index 000000000000..93af226b3102 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/model.mustache @@ -0,0 +1,44 @@ +{{>partial_header}} + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +{{#models}} +{{#model}} +{{#discriminator}} +using JsonSubTypes; +{{/discriminator}} +{{/model}} +{{/models}} +{{#validatable}} +using System.ComponentModel.DataAnnotations; +{{/validatable}} +using OpenAPIDateConverter = {{packageName}}.Client.OpenAPIDateConverter; +{{#useCompareNetObjects}} +using OpenAPIClientUtils = {{packageName}}.Client.ClientUtils; +{{/useCompareNetObjects}} +{{#models}} +{{#model}} +{{#oneOf}} +{{#-first}} +using System.Reflection; +{{/-first}} +{{/oneOf}} +{{#anyOf}} +{{#-first}} +using System.Reflection; +{{/-first}} +{{/anyOf}} + +namespace {{packageName}}.{{modelPackage}} +{ +{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{#oneOf}}{{#-first}}{{>modelOneOf}}{{/-first}}{{/oneOf}}{{#anyOf}}{{#-first}}{{>modelAnyOf}}{{/-first}}{{/anyOf}}{{^oneOf}}{{^anyOf}}{{>modelGeneric}}{{/anyOf}}{{/oneOf}}{{/isEnum}} +{{/model}} +{{/models}} +} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache new file mode 100644 index 000000000000..404badbfeb01 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache @@ -0,0 +1,322 @@ + /// + /// {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} + /// + [DataContract(Name = "{{{name}}}")] + {{#discriminator}} + [Newtonsoft.Json.JsonConverter(typeof(JsonSubtypes), "{{{discriminatorName}}}")] + {{#mappedModels}} + [JsonSubtypes.KnownSubType(typeof({{{modelName}}}), "{{^vendorExtensions.x-discriminator-value}}{{{mappingName}}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{.}}}{{/vendorExtensions.x-discriminator-value}}")] + {{/mappedModels}} + {{/discriminator}} + {{>visibility}} partial class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}}IEquatable<{{classname}}>{{#validatable}}, IValidatableObject{{/validatable}} + { + {{#vars}} + {{#items.isEnum}} + {{#items}} + {{^complexType}} +{{>modelInnerEnum}} + {{/complexType}} + {{/items}} + {{/items.isEnum}} + {{#isEnum}} + {{^complexType}} +{{>modelInnerEnum}} + {{/complexType}} + {{/isEnum}} + {{#isEnum}} + /// + /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}} + /// + {{#description}} + /// {{description}} + {{/description}} + [DataMember(Name = "{{baseName}}"{{#required}}, IsRequired = true{{/required}}, EmitDefaultValue = {{#vendorExtensions.x-emit-default-value}}true{{/vendorExtensions.x-emit-default-value}}{{^vendorExtensions.x-emit-default-value}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{/vendorExtensions.x-emit-default-value}})] + public {{#complexType}}{{{complexType}}}{{/complexType}}{{^complexType}}{{{datatypeWithEnum}}}{{/complexType}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}} {{name}} { get; set; } + + {{#isReadOnly}} + /// + /// Returns false as {{name}} should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerialize{{name}}() + { + return false; + } + + {{/isReadOnly}} + {{/isEnum}} + {{/vars}} + {{#hasRequired}} + {{^hasOnlyReadOnly}} + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + {{^isAdditionalPropertiesTrue}} + protected {{classname}}() { } + {{/isAdditionalPropertiesTrue}} + {{#isAdditionalPropertiesTrue}} + protected {{classname}}() + { + this.AdditionalProperties = new Dictionary(); + } + + {{/isAdditionalPropertiesTrue}} + {{/hasOnlyReadOnly}} + {{/hasRequired}} + /// + /// Initializes a new instance of the class. + /// + {{#readWriteVars}} + /// {{#description}}{{description}}{{/description}}{{^description}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{defaultValue}}){{/defaultValue}}. + {{/readWriteVars}} + {{#hasOnlyReadOnly}} + [JsonConstructorAttribute] + {{/hasOnlyReadOnly}} + public {{classname}}({{#readWriteVars}}{{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}}{{/isEnum}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{^-last}}, {{/-last}}{{/readWriteVars}}){{#parent}} : base({{#parentVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{^-last}}, {{/-last}}{{/parentVars}}){{/parent}} + { + {{#vars}} + {{^isInherited}} + {{^isReadOnly}} + {{#required}} + {{^vendorExtensions.x-csharp-value-type}} + // to ensure "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" is required (not null) + {{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} ?? throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null"); + {{/vendorExtensions.x-csharp-value-type}} + {{#vendorExtensions.x-csharp-value-type}} + {{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; + {{/vendorExtensions.x-csharp-value-type}} + + {{/required}} + {{/isReadOnly}} + {{/isInherited}} + {{/vars}} + {{#vars}} + {{^isInherited}} + {{^isReadOnly}} + {{^required}} + {{#defaultValue}} + {{^vendorExtensions.x-csharp-value-type}} + // use default value if no "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" provided + {{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} ?? {{{defaultValue}}}; + {{/vendorExtensions.x-csharp-value-type}} + {{#vendorExtensions.x-csharp-value-type}} + {{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; + {{/vendorExtensions.x-csharp-value-type}} + {{/defaultValue}} + {{^defaultValue}} + {{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; + {{/defaultValue}} + {{/required}} + {{/isReadOnly}} + {{/isInherited}} + {{/vars}} + {{#isAdditionalPropertiesTrue}} + AdditionalProperties = new Dictionary(); + {{/isAdditionalPropertiesTrue}} + } + + {{#vars}} + {{^isInherited}} + {{^isEnum}} + /// + /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}} + /// {{#description}} + /// {{description}}{{/description}} + [DataMember(Name = "{{baseName}}"{{#required}}, IsRequired = true{{/required}}, EmitDefaultValue = {{#vendorExtensions.x-emit-default-value}}true{{/vendorExtensions.x-emit-default-value}}{{^vendorExtensions.x-emit-default-value}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{/vendorExtensions.x-emit-default-value}})] + {{#isDate}} + [Newtonsoft.Json.JsonConverter(typeof(OpenAPIDateConverter))] + {{/isDate}} + public {{{dataType}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; } + + {{#isReadOnly}} + /// + /// Returns false as {{name}} should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerialize{{name}}() + { + return false; + } + + {{/isReadOnly}} + {{/isEnum}} + {{/isInherited}} + {{/vars}} + {{#isAdditionalPropertiesTrue}} + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + {{/isAdditionalPropertiesTrue}} + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class {{classname}} {\n"); + {{#parent}} + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append('\n'); + {{/parent}} + {{#vars}} + sb.Append(" {{name}}: ").Append({{name}}).Append('\n'); + {{/vars}} + {{#isAdditionalPropertiesTrue}} + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append('\n'); + {{/isAdditionalPropertiesTrue}} + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public {{#parent}}{{^isArray}}{{^isMap}}override {{/isMap}}{{/isArray}}{{/parent}}{{^parent}}virtual {{/parent}}string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSettings = null) + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, jsonSerializerSettings ?? {{packageName}}.Client.ClientUtils.JsonSerializerSettings); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object? input) + { + {{#useCompareNetObjects}} + return OpenAPIClientUtils.compareLogic.Compare(this, input as {{classname}}).AreEqual; + {{/useCompareNetObjects}} + {{^useCompareNetObjects}} + return Equals(input as {{classname}}); + {{/useCompareNetObjects}} + } + + /// + /// Returns true if {{classname}} instances are equal + /// + /// Instance of {{classname}} to be compared + /// Boolean + public bool Equals({{classname}}? input) + { + {{#useCompareNetObjects}} + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + {{/useCompareNetObjects}} + {{^useCompareNetObjects}} + if (input == null) + return false; + + return {{#vars}}{{#parent}}base.Equals(input) && {{/parent}}{{^isContainer}} + ( + {{name}} == input.{{name}} || + {{^vendorExtensions.x-is-value-type}} + ({{name}} != null && + {{name}}.Equals(input.{{name}})) + {{/vendorExtensions.x-is-value-type}} + {{#vendorExtensions.x-is-value-type}} + {{name}}.Equals(input.{{name}}) + {{/vendorExtensions.x-is-value-type}} + ){{^-last}} && {{/-last}}{{/isContainer}}{{#isContainer}} + ( + {{name}} == input.{{name}} || + {{^vendorExtensions.x-is-value-type}}{{name}} != null && + input.{{name}} != null && + {{/vendorExtensions.x-is-value-type}}{{name}}.SequenceEqual(input.{{name}}) + ){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}}{{^isAdditionalPropertiesTrue}};{{/isAdditionalPropertiesTrue}} + {{#isAdditionalPropertiesTrue}} + && (AdditionalProperties.Count == input.AdditionalProperties.Count && !AdditionalProperties.Except(input.AdditionalProperties).Any()); + {{/isAdditionalPropertiesTrue}} + {{/useCompareNetObjects}} + } + +{{#validatable}} +{{#discriminator}} + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { +{{/discriminator}} +{{^discriminator}} + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { +{{/discriminator}} + {{#parent}} + {{^isArray}} + {{^isMap}} + foreach(var x in BaseValidate(validationContext)) yield return x; + {{/isMap}} + {{/isArray}} + {{/parent}} + {{#vars}} + {{#hasValidation}} + {{#maxLength}} + // {{{name}}} ({{{dataType}}}) maxLength + if(this.{{{name}}} != null && this.{{{name}}}.Length > {{maxLength}}) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, length must be less than {{maxLength}}.", new [] { "{{{name}}}" }); + } + + {{/maxLength}} + {{#minLength}} + // {{{name}}} ({{{dataType}}}) minLength + if(this.{{{name}}} != null && this.{{{name}}}.Length < {{minLength}}) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, length must be greater than {{minLength}}.", new [] { "{{{name}}}" }); + } + + {{/minLength}} + {{#maximum}} + // {{{name}}} ({{{dataType}}}) maximum + if(this.{{{name}}} > ({{{dataType}}}){{maximum}}) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value less than or equal to {{maximum}}.", new [] { "{{{name}}}" }); + } + + {{/maximum}} + {{#minimum}} + // {{{name}}} ({{{dataType}}}) minimum + if(this.{{{name}}} < ({{{dataType}}}){{minimum}}) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value greater than or equal to {{minimum}}.", new [] { "{{{name}}}" }); + } + + {{/minimum}} + {{#pattern}} + {{^isByteArray}} + // {{{name}}} ({{{dataType}}}) pattern + Regex regex{{{name}}} = new Regex(@"{{{vendorExtensions.x-regex}}}"{{#vendorExtensions.x-modifiers}}{{#-first}}, {{/-first}}RegexOptions.{{{.}}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}); + if (false == regex{{{name}}}.Match(this.{{{name}}}).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must match a pattern of " + regex{{{name}}}, new [] { "{{{name}}}" }); + } + + {{/isByteArray}} + {{/pattern}} + {{/hasValidation}} + {{/vars}} + yield break; + } +{{/validatable}} + } diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelInnerEnum.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelInnerEnum.mustache new file mode 100644 index 000000000000..8c17023f38a0 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelInnerEnum.mustache @@ -0,0 +1,26 @@ + {{^isContainer}} + /// + /// {{^description}}Defines {{{name}}}{{/description}}{{#description}}{{description}}{{/description}} + /// + {{#description}} + /// {{description}} + {{/description}} + {{#isString}} + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + {{/isString}} + {{>visibility}} enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{#vendorExtensions.x-enum-byte}}: byte{{/vendorExtensions.x-enum-byte}} + { + {{#allowableValues}} + {{#enumVars}} + /// + /// Enum {{name}} for value: {{{value}}} + /// + {{#isString}} + [EnumMember(Value = "{{{value}}}")] + {{/isString}} + {{name}}{{^isString}} = {{{value}}}{{/isString}}{{#isString}} = {{-index}}{{/isString}}{{^-last}},{{/-last}} + + {{/enumVars}} + {{/allowableValues}} + } + {{/isContainer}} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES b/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES index 29f9ff544d92..4f2382c7e38d 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES @@ -1,7 +1,10 @@ .gitignore README.md +apis/PetApi.service.ts apis/PetApi.ts +apis/StoreApi.service.ts apis/StoreApi.ts +apis/UserApi.service.ts apis/UserApi.ts apis/baseapi.ts apis/exception.ts @@ -23,6 +26,12 @@ models/all.ts package.json rxjsStub.ts servers.ts +services/ObjectParamAPI.ts +services/ObservableAPI.ts +services/PromiseAPI.ts +services/configuration.ts +services/http.ts +services/index.ts tsconfig.json types/ObjectParamAPI.ts types/ObservableAPI.ts diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts index 7041341a7089..c97b44cf0893 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts @@ -6,6 +6,7 @@ import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; +import { injectable } from "inversify"; import { ApiResponse } from '../models/ApiResponse'; import { Pet } from '../models/Pet'; @@ -13,6 +14,7 @@ import { Pet } from '../models/Pet'; /** * no description */ +@injectable() export class PetApiRequestFactory extends BaseAPIRequestFactory { /** @@ -397,6 +399,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { +@injectable() export class PetApiResponseProcessor { /** diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts index 09400e99c083..ceef209c37db 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts @@ -6,12 +6,14 @@ import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; +import { injectable } from "inversify"; import { Order } from '../models/Order'; /** * no description */ +@injectable() export class StoreApiRequestFactory extends BaseAPIRequestFactory { /** @@ -166,6 +168,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { +@injectable() export class StoreApiResponseProcessor { /** diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts index 1d43ec7a72b4..353bae433c58 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts @@ -6,12 +6,14 @@ import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; +import { injectable } from "inversify"; import { User } from '../models/User'; /** * no description */ +@injectable() export class UserApiRequestFactory extends BaseAPIRequestFactory { /** @@ -375,6 +377,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { +@injectable() export class UserApiResponseProcessor { /** diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts index fe7ee3d15118..cf8fec079eb3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts @@ -1,4 +1,6 @@ import { Configuration } from '../configuration' +import { injectable, inject } from "inversify"; +import { AbstractConfiguration } from "../services/configuration"; /** * @@ -17,9 +19,10 @@ export const COLLECTION_FORMATS = { * @export * @class BaseAPI */ +@injectable() export class BaseAPIRequestFactory { - constructor(protected configuration: Configuration) { + constructor(@inject(AbstractConfiguration) protected configuration: Configuration) { } }; diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts index 9d59a0a25580..13e3b17fa825 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts @@ -2,6 +2,8 @@ //@ts-ignore import * as btoa from "btoa"; import { RequestContext } from "../http/http"; +import { injectable, inject, named } from "inversify"; +import { AbstractTokenProvider } from "../services/configuration"; /** * Interface authentication schemes. @@ -20,6 +22,10 @@ export interface SecurityAuthentication { applySecurityAuthentication(context: RequestContext): void | Promise; } +export const AuthApiKey = Symbol("auth.api_key"); +export const AuthUsername = Symbol("auth.username"); +export const AuthPassword = Symbol("auth.password"); + export interface TokenProvider { getToken(): Promise | string; } @@ -27,13 +33,14 @@ export interface TokenProvider { /** * Applies apiKey authentication to the request context. */ +@injectable() export class ApiKeyAuthentication implements SecurityAuthentication { /** * Configures this api key authentication with the necessary properties * * @param apiKey: The api key to be used for every request */ - public constructor(private apiKey: string) {} + public constructor(@inject(AuthApiKey) @named("api_key") private apiKey: string) {} public getName(): string { return "api_key"; @@ -47,6 +54,7 @@ export class ApiKeyAuthentication implements SecurityAuthentication { /** * Applies oauth2 authentication to the request context. */ +@injectable() export class PetstoreAuthAuthentication implements SecurityAuthentication { // TODO: How to handle oauth2 authentication! public constructor() {} @@ -66,6 +74,11 @@ export type AuthMethods = { "petstore_auth"?: SecurityAuthentication } +export const authMethodServices = { + "api_key": ApiKeyAuthentication, + "petstore_auth": PetstoreAuthAuthentication +} + export type ApiKeyConfiguration = string; export type HttpBasicConfiguration = { "username": string, "password": string }; export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts index de89bb05e702..4d48e5222adf 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts @@ -9,3 +9,5 @@ export * from "./servers"; export { PromiseMiddleware as Middleware } from './middleware'; export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI'; +export * from "./services/index"; +export { AbstractPromisePetApi as AbstractPetApi, AbstractPromiseStoreApi as AbstractStoreApi, AbstractPromiseUserApi as AbstractUserApi } from './services/PromiseAPI'; diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/package.json b/samples/openapi3/client/petstore/typescript/builds/inversify/package.json index f26767636102..71908ad48cae 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/package.json +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/package.json @@ -22,6 +22,7 @@ "@types/node": "*", "form-data": "^2.5.0", "btoa": "^1.2.1", + "inversify": "^5.0.1", "es6-promise": "^4.2.4", "url-parse": "^1.4.3" }, diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json b/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json index a542d795677c..b53dce7b41b3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json @@ -18,6 +18,7 @@ "outDir": "./dist", "noLib": false, "lib": [ "es6" ], + "experimentalDecorators": true, }, "exclude": [ "dist", diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts index 6154d267ed3a..31ced8bbdca3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts @@ -3,6 +3,8 @@ import * as models from '../models/all'; import { Configuration} from '../configuration' import { Observable, of, from } from '../rxjsStub'; import {mergeMap, map} from '../rxjsStub'; +import { injectable, inject, optional } from "inversify"; +import { AbstractConfiguration } from "../services/configuration"; import { ApiResponse } from '../models/ApiResponse'; import { Category } from '../models/Category'; @@ -12,15 +14,18 @@ import { Tag } from '../models/Tag'; import { User } from '../models/User'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; +import { AbstractPetApiRequestFactory, AbstractPetApiResponseProcessor } from "../apis/PetApi.service"; + +@injectable() export class ObservablePetApi { - private requestFactory: PetApiRequestFactory; - private responseProcessor: PetApiResponseProcessor; + private requestFactory: AbstractPetApiRequestFactory; + private responseProcessor: AbstractPetApiResponseProcessor; private configuration: Configuration; public constructor( - configuration: Configuration, - requestFactory?: PetApiRequestFactory, - responseProcessor?: PetApiResponseProcessor + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractPetApiRequestFactory) @optional() requestFactory?: AbstractPetApiRequestFactory, + @inject(AbstractPetApiResponseProcessor) @optional() responseProcessor?: AbstractPetApiResponseProcessor ) { this.configuration = configuration; this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); @@ -226,15 +231,18 @@ export class ObservablePetApi { import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; +import { AbstractStoreApiRequestFactory, AbstractStoreApiResponseProcessor } from "../apis/StoreApi.service"; + +@injectable() export class ObservableStoreApi { - private requestFactory: StoreApiRequestFactory; - private responseProcessor: StoreApiResponseProcessor; + private requestFactory: AbstractStoreApiRequestFactory; + private responseProcessor: AbstractStoreApiResponseProcessor; private configuration: Configuration; public constructor( - configuration: Configuration, - requestFactory?: StoreApiRequestFactory, - responseProcessor?: StoreApiResponseProcessor + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractStoreApiRequestFactory) @optional() requestFactory?: AbstractStoreApiRequestFactory, + @inject(AbstractStoreApiResponseProcessor) @optional() responseProcessor?: AbstractStoreApiResponseProcessor ) { this.configuration = configuration; this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); @@ -342,15 +350,18 @@ export class ObservableStoreApi { import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; +import { AbstractUserApiRequestFactory, AbstractUserApiResponseProcessor } from "../apis/UserApi.service"; + +@injectable() export class ObservableUserApi { - private requestFactory: UserApiRequestFactory; - private responseProcessor: UserApiResponseProcessor; + private requestFactory: AbstractUserApiRequestFactory; + private responseProcessor: AbstractUserApiResponseProcessor; private configuration: Configuration; public constructor( - configuration: Configuration, - requestFactory?: UserApiRequestFactory, - responseProcessor?: UserApiResponseProcessor + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractUserApiRequestFactory) @optional() requestFactory?: AbstractUserApiRequestFactory, + @inject(AbstractUserApiResponseProcessor) @optional() responseProcessor?: AbstractUserApiResponseProcessor ) { this.configuration = configuration; this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts index 533095a405d6..6077fdac2d59 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts @@ -1,6 +1,8 @@ import { ResponseContext, RequestContext, HttpFile } from '../http/http'; import * as models from '../models/all'; import { Configuration} from '../configuration' +import { injectable, inject, optional } from "inversify"; +import { AbstractConfiguration } from "../services/configuration"; import { ApiResponse } from '../models/ApiResponse'; import { Category } from '../models/Category'; @@ -12,13 +14,16 @@ import { ObservablePetApi } from './ObservableAPI'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; +import { AbstractPetApiRequestFactory, AbstractPetApiResponseProcessor } from "../apis/PetApi.service"; + +@injectable() export class PromisePetApi { private api: ObservablePetApi public constructor( - configuration: Configuration, - requestFactory?: PetApiRequestFactory, - responseProcessor?: PetApiResponseProcessor + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractPetApiRequestFactory) @optional() requestFactory?: AbstractPetApiRequestFactory, + @inject(AbstractPetApiResponseProcessor) @optional() responseProcessor?: AbstractPetApiResponseProcessor ) { this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); } @@ -112,13 +117,16 @@ import { ObservableStoreApi } from './ObservableAPI'; import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; +import { AbstractStoreApiRequestFactory, AbstractStoreApiResponseProcessor } from "../apis/StoreApi.service"; + +@injectable() export class PromiseStoreApi { private api: ObservableStoreApi public constructor( - configuration: Configuration, - requestFactory?: StoreApiRequestFactory, - responseProcessor?: StoreApiResponseProcessor + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractStoreApiRequestFactory) @optional() requestFactory?: AbstractStoreApiRequestFactory, + @inject(AbstractStoreApiResponseProcessor) @optional() responseProcessor?: AbstractStoreApiResponseProcessor ) { this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); } @@ -170,13 +178,16 @@ import { ObservableUserApi } from './ObservableAPI'; import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; +import { AbstractUserApiRequestFactory, AbstractUserApiResponseProcessor } from "../apis/UserApi.service"; + +@injectable() export class PromiseUserApi { private api: ObservableUserApi public constructor( - configuration: Configuration, - requestFactory?: UserApiRequestFactory, - responseProcessor?: UserApiResponseProcessor + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractUserApiRequestFactory) @optional() requestFactory?: AbstractUserApiRequestFactory, + @inject(AbstractUserApiResponseProcessor) @optional() responseProcessor?: AbstractUserApiResponseProcessor ) { this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); } From f97b05cdaff4ab8dec748c98619ed1e25525a017 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Mon, 18 Jan 2021 13:50:34 -0500 Subject: [PATCH 04/20] updated readme --- .../httpclient/netcore_project.mustache | 7 ++--- .../OpenAPIClient-httpclient/README.md | 28 +++++++++++++++++++ .../Org.OpenAPITools/Org.OpenAPITools.csproj | 7 ++--- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/netcore_project.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/netcore_project.mustache index 650dcb9247c7..518562446cbd 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/netcore_project.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/netcore_project.mustache @@ -1,8 +1,9 @@ - false - net5.0 + + + net5.0 {{packageName}} {{packageName}} Library @@ -28,8 +29,6 @@ {{/useCompareNetObjects}} - {{#validatable}} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md index 1cca61e28718..e3967a7cfa5f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md @@ -1,3 +1,31 @@ +This library requires some post processing. + +``` +cmd /c start /wait java -jar openapi-generator-cli.jar generate ` + -g csharp-netcore ` + -i swagger.yml ` + -o output ` + --library httpclient | Out-Null + # optional parameters you probably want + # -t templates + # -c generator-config.json + # other csharp properties: https://openapi-generator.tech/docs/generators/csharp-netcore + # other global properties: https://openapi-generator.tech/docs/globals + +$files = Get-ChildItem ..\..\src\CocApi -Recurse +foreach ($file in $files) +{ + if ($file.PSIsContainer){ + continue + } + + $content=Get-Content $file.PSPath + $content=$content -replace "\?\?\?\?", "?" + $content=$content -replace "\?\?\?", "?" + Set-Content $file.PSPath $content +} +``` + # Org.OpenAPITools - the C# library for the OpenAPI Petstore This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Org.OpenAPITools.csproj index ae0231709284..3acb9f77d18c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -1,8 +1,9 @@ - false - net5.0 + + + net5.0 Org.OpenAPITools Org.OpenAPITools Library @@ -24,8 +25,6 @@ - From 71dc8302d839051c820bc8d972031e622eedea2d Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Mon, 18 Jan 2021 13:53:10 -0500 Subject: [PATCH 05/20] updated readme again --- .../libraries/httpclient/README.mustache | 251 ++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache new file mode 100644 index 000000000000..1db9a029224c --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache @@ -0,0 +1,251 @@ +This library requires some post processing. + +``` +cmd /c start /wait java -jar openapi-generator-cli.jar generate ` + -g csharp-netcore ` + -i swagger.yml ` + -o output ` + --library httpclient | Out-Null + # optional parameters you probably want + # -t templates + # -c generator-config.json + # other csharp properties: https://openapi-generator.tech/docs/generators/csharp-netcore + # other global properties: https://openapi-generator.tech/docs/globals + +$files = Get-ChildItem output -Recurse +foreach ($file in $files) +{ + if ($file.PSIsContainer){ + continue + } + + $content=Get-Content $file.PSPath + $content=$content -replace "\?\?\?\?", "?" + $content=$content -replace "\?\?\?", "?" + Set-Content $file.PSPath $content +} +``` + +# {{packageName}} - the C# library for the {{appName}} + +{{#appDescriptionWithNewLines}} +{{{appDescriptionWithNewLines}}} +{{/appDescriptionWithNewLines}} + +This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: {{appVersion}} +- SDK version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} + For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + + +## Frameworks supported +{{#netStandard}} +- .NET Core >=1.0 +- .NET Framework >=4.6 +- Mono/Xamarin >=vNext +{{/netStandard}} + + +## Dependencies + +- [RestSharp](https://www.nuget.org/packages/RestSharp) - 106.11.4 or later +- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 12.0.3 or later +- [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/) - 1.7.0 or later +{{#useCompareNetObjects}} +- [CompareNETObjects](https://www.nuget.org/packages/CompareNETObjects) - 4.61.0 or later +{{/useCompareNetObjects}} +{{#validatable}} +- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 4.7.0 or later +{{/validatable}} + +The DLLs included in the package may not be the latest version. We recommend using [NuGet](https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages: +``` +Install-Package RestSharp +Install-Package Newtonsoft.Json +Install-Package JsonSubTypes +{{#validatable}} +Install-Package System.ComponentModel.Annotations +{{/validatable}} +{{#useCompareNetObjects}} +Install-Package CompareNETObjects +{{/useCompareNetObjects}} +``` + +NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742) + + +## Installation +{{#netStandard}} +Generate the DLL using your preferred tool (e.g. `dotnet build`) +{{/netStandard}} +{{^netStandard}} +Run the following command to generate the DLL +- [Mac/Linux] `/bin/sh build.sh` +- [Windows] `build.bat` +{{/netStandard}} + +Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces: +```csharp +using {{packageName}}.{{apiPackage}}; +using {{packageName}}.Client; +using {{packageName}}.{{modelPackage}}; +``` +{{^netStandard}} + +## Packaging + +A `.nuspec` is included with the project. You can follow the Nuget quickstart to [create](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#create-the-package) and [publish](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#publish-the-package) packages. + +This `.nuspec` uses placeholders from the `.csproj`, so build the `.csproj` directly: + +``` +nuget pack -Build -OutputDirectory out {{packageName}}.csproj +``` + +Then, publish to a [local feed](https://docs.microsoft.com/en-us/nuget/hosting-packages/local-feeds) or [other host](https://docs.microsoft.com/en-us/nuget/hosting-packages/overview) and consume the new package via Nuget as usual. + +{{/netStandard}} + +## Usage + +To use the API client with a HTTP proxy, setup a `System.Net.WebProxy` +```csharp +Configuration c = new Configuration(); +System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/"); +webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials; +c.Proxy = webProxy; +``` + + +## Getting Started + +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using {{packageName}}.{{apiPackage}}; +using {{packageName}}.Client; +using {{packageName}}.{{modelPackage}}; + +namespace Example +{ + public class {{operationId}}Example + { + public static void Main() + { +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} + Configuration config = new Configuration(); + config.BasePath = "{{{basePath}}}"; + {{#hasAuthMethods}} + {{#authMethods}} + {{#isBasicBasic}} + // Configure HTTP basic authorization: {{{name}}} + config.Username = "YOUR_USERNAME"; + config.Password = "YOUR_PASSWORD"; + {{/isBasicBasic}} + {{#isBasicBearer}} + // Configure Bearer token for authorization: {{{name}}} + config.AccessToken = "YOUR_BEARER_TOKEN"; + {{/isBasicBearer}} + {{#isApiKey}} + // Configure API key authorization: {{{name}}} + config.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // config.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer"); + {{/isApiKey}} + {{#isOAuth}} + // Configure OAuth2 access token for authorization: {{{name}}} + config.AccessToken = "YOUR_ACCESS_TOKEN"; + {{/isOAuth}} + {{/authMethods}} + + {{/hasAuthMethods}} + var apiInstance = new {{classname}}(config); + {{#allParams}} + {{#isPrimitiveType}} + var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/isPrimitiveType}} + {{^isPrimitiveType}} + var {{paramName}} = new {{{dataType}}}(); // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/isPrimitiveType}} + {{/allParams}} + + try + { + {{#summary}} + // {{{.}}} + {{/summary}} + {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}} + Debug.WriteLine(result);{{/returnType}} + } + catch (ApiException e) + { + Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message ); + Debug.Print("Status Code: "+ e.ErrorCode); + Debug.Print(e.StackTrace); + } +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} + } + } +} +``` + + +## Documentation for API Endpoints + +All URIs are relative to *{{{basePath}}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{{summary}}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + + +## Documentation for Models + +{{#modelPackage}} +{{#models}}{{#model}} - [{{{modelPackage}}}.{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} +{{/modelPackage}} +{{^modelPackage}} +No model defined in this package +{{/modelPackage}} + + +## Documentation for Authorization + +{{^authMethods}} +All endpoints do not require authorization. +{{/authMethods}} +{{#authMethods}} +{{#last}} +Authentication schemes defined for the API: +{{/last}} +{{/authMethods}} +{{#authMethods}} + +### {{name}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{keyParamName}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasicBasic}}- **Type**: HTTP basic authentication +{{/isBasicBasic}} +{{#isBasicBearer}}- **Type**: Bearer Authentication +{{/isBasicBearer}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{flow}} +- **Authorization URL**: {{authorizationUrl}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - {{scope}}: {{description}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} From 5c770ba6fa182311229bce0d84b696f7d7f0606b Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Mon, 18 Jan 2021 14:01:59 -0500 Subject: [PATCH 06/20] build samples --- .../petstore/csharp-netcore/OpenAPIClient-httpclient/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md index e3967a7cfa5f..e5c2de30f5e4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md @@ -12,7 +12,7 @@ cmd /c start /wait java -jar openapi-generator-cli.jar generate ` # other csharp properties: https://openapi-generator.tech/docs/generators/csharp-netcore # other global properties: https://openapi-generator.tech/docs/globals -$files = Get-ChildItem ..\..\src\CocApi -Recurse +$files = Get-ChildItem output -Recurse foreach ($file in $files) { if ($file.PSIsContainer){ From 18d6529178995a1f783ff824c2312e516c1907d5 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 23 Jan 2021 20:45:15 -0500 Subject: [PATCH 07/20] let users do this in templates --- .../libraries/httpclient/api.mustache | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache index ce8e721df46a..1a06d90abe4e 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache @@ -85,17 +85,7 @@ namespace {{packageName}}.{{apiPackage}} /// public Func>? GetTokenAsync { get; set; } - {{#operation}} - - /// - /// Validate the input before sending the request - /// - {{#allParams}} - /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} - {{/allParams}} - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask Validate{{operationId}}RequestAsync({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); + {{#operation}} {{#returnType}} /// @@ -153,9 +143,7 @@ namespace {{packageName}}.{{apiPackage}} {{/vendorExtensions.x-csharp-value-type}} {{/required}} {{/allParams}} - - await Validate{{operationId}}RequestAsync({{#allParams}}{{#required}}{{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken).ConfigureAwait(false); - + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "{{path}}"; From b9fb9769f245b5c04849f1eb0f0e3015cbd467bf Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 23 Jan 2021 20:47:02 -0500 Subject: [PATCH 08/20] this didnt work --- .../csharp-netcore/libraries/httpclient/api.mustache | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache index 1a06d90abe4e..5bac9cc82b41 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache @@ -143,7 +143,7 @@ namespace {{packageName}}.{{apiPackage}} {{/vendorExtensions.x-csharp-value-type}} {{/required}} {{/allParams}} - + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "{{path}}"; @@ -283,15 +283,6 @@ namespace {{packageName}}.{{apiPackage}} request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("{{{mediaType}}}")); {{/consumes}} - string[] contentTypes = new string[] { - {{#consumes}} - "{{{mediaType}}}"{{^-last}}, {{/-last}} - {{/consumes}} - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - {{#produces}} request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("{{{mediaType}}}")); {{/produces}} From 07abe97ac55243fa6c3802e2094956987d47d2b7 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 23 Jan 2021 20:47:36 -0500 Subject: [PATCH 09/20] add POST support --- .../resources/csharp-netcore/libraries/httpclient/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache index 5bac9cc82b41..e0f52c78ca2c 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache @@ -216,7 +216,7 @@ namespace {{packageName}}.{{apiPackage}} {{/formParams}} {{#bodyParam}} - // todo localVarRequestOptions.Data = {{paramName}}; + request.Content = new System.Net.Http.StringContent({{paramName}}.ToJson(), System.Text.Encoding.UTF8, "application/json"); {{/bodyParam}} {{#authMethods}} From 140a31f041d94083aa8e752a253645e371db5116 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 23 Jan 2021 20:49:24 -0500 Subject: [PATCH 10/20] update readme --- .../csharp-netcore/libraries/httpclient/README.mustache | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache index 1db9a029224c..e1986bde2bfe 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache @@ -19,9 +19,8 @@ foreach ($file in $files) continue } - $content=Get-Content $file.PSPath - $content=$content -replace "\?\?\?\?", "?" - $content=$content -replace "\?\?\?", "?" + $content=Get-Content $file.PSPath -raw + $content=$content -replace '\?{3,4}', '?' # replace every three to four consecutive occurrences of '?' with a single one Set-Content $file.PSPath $content } ``` From 8186728783a216ed6b61599e3949abb1dc57b5ca Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 23 Jan 2021 20:52:28 -0500 Subject: [PATCH 11/20] update readme --- .../csharp-netcore/libraries/httpclient/README.mustache | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache index e1986bde2bfe..8b2155858847 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache @@ -20,6 +20,11 @@ foreach ($file in $files) } $content=Get-Content $file.PSPath -raw + + if (-Not($content)){ + continue; + } + $content=$content -replace '\?{3,4}', '?' # replace every three to four consecutive occurrences of '?' with a single one Set-Content $file.PSPath $content } From 9f81964b369ce7bf094e8bdda62b750cc1d6d439 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 23 Jan 2021 21:04:57 -0500 Subject: [PATCH 12/20] build samples --- .../OpenAPIClient-httpclient/README.md | 10 +- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 19 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 296 +----------------- .../Api/FakeClassnameTags123Api.cs | 19 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 162 +--------- .../src/Org.OpenAPITools/Api/StoreApi.cs | 66 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 141 +-------- 8 files changed, 24 insertions(+), 704 deletions(-) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md index e5c2de30f5e4..4fade86ef479 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md @@ -19,9 +19,13 @@ foreach ($file in $files) continue } - $content=Get-Content $file.PSPath - $content=$content -replace "\?\?\?\?", "?" - $content=$content -replace "\?\?\?", "?" + $content=Get-Content $file.PSPath -raw + + if (-Not($content)){ + continue; + } + + $content=$content -replace '\?{3,4}', '?' # replace every three to four consecutive occurrences of '?' with a single one Set-Content $file.PSPath $content } ``` diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 0d6ff9ad905b..c6b61416bec6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -82,14 +82,6 @@ public AnotherFakeApi(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } - /// - /// Validate the input before sending the request - /// - /// client model - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateCall123TestSpecialTagsRequestAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// To test special tags To test special tags and operation ID starting with number /// @@ -131,8 +123,6 @@ public async System.Threading.Tasks.Task Call123TestSpecialTagsAsyn if (modelClient == null) throw new ArgumentNullException(nameof(modelClient)); - await ValidateCall123TestSpecialTagsRequestAsync(modelClient, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/another-fake/dummy"; @@ -151,18 +141,11 @@ public async System.Threading.Tasks.Task Call123TestSpecialTagsAsyn - // todo localVarRequestOptions.Data = modelClient; + request.Content = new System.Net.Http.StringContent(modelClient.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs index 5ee6e54c869a..8e25748e7c03 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -79,13 +79,6 @@ public DefaultApi(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } - /// - /// Validate the input before sending the request - /// - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateFooGetRequestAsync(System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// /// @@ -122,8 +115,6 @@ public async System.Threading.Tasks.Task FooGetAsync(Syst public async System.Threading.Tasks.Task> FooGetWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { - await ValidateFooGetRequestAsync(cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/foo"; @@ -145,12 +136,6 @@ public async System.Threading.Tasks.Task FooGetAsync(Syst - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs index f4aee0c37628..6b40e3dca277 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs @@ -534,13 +534,6 @@ public FakeApi(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } - /// - /// Validate the input before sending the request - /// - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateFakeHealthGetRequestAsync(System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Health check endpoint /// @@ -577,8 +570,6 @@ public async System.Threading.Tasks.Task FakeHealthGetAsync(S public async System.Threading.Tasks.Task> FakeHealthGetWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { - await ValidateFakeHealthGetRequestAsync(cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/health"; @@ -600,12 +591,6 @@ public async System.Threading.Tasks.Task FakeHealthGetAsync(S - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -620,14 +605,6 @@ public async System.Threading.Tasks.Task FakeHealthGetAsync(S return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// Input boolean as post body (optional) - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterBooleanSerializeRequestAsync(bool???? body, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Test serialization of outer boolean types /// @@ -667,8 +644,6 @@ public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bo public async System.Threading.Tasks.Task> FakeOuterBooleanSerializeWithHttpInfoAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateFakeOuterBooleanSerializeRequestAsync(body, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/outer/boolean"; @@ -687,18 +662,11 @@ public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bo - // todo localVarRequestOptions.Data = body; + request.Content = new System.Net.Http.StringContent(body.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -713,14 +681,6 @@ public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bo return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// Input composite as post body (optional) - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterCompositeSerializeRequestAsync(OuterComposite??? outerComposite, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Test serialization of object with outer number type /// @@ -760,8 +720,6 @@ public async System.Threading.Tasks.Task FakeOuterCompositeSeria public async System.Threading.Tasks.Task> FakeOuterCompositeSerializeWithHttpInfoAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateFakeOuterCompositeSerializeRequestAsync(outerComposite, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/outer/composite"; @@ -780,18 +738,11 @@ public async System.Threading.Tasks.Task FakeOuterCompositeSeria - // todo localVarRequestOptions.Data = outerComposite; + request.Content = new System.Net.Http.StringContent(outerComposite.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -806,14 +757,6 @@ public async System.Threading.Tasks.Task FakeOuterCompositeSeria return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// Input number as post body (optional) - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterNumberSerializeRequestAsync(decimal???? body, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Test serialization of outer number types /// @@ -853,8 +796,6 @@ public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync( public async System.Threading.Tasks.Task> FakeOuterNumberSerializeWithHttpInfoAsync(decimal???? body = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateFakeOuterNumberSerializeRequestAsync(body, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/outer/number"; @@ -873,18 +814,11 @@ public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync( - // todo localVarRequestOptions.Data = body; + request.Content = new System.Net.Http.StringContent(body.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -899,14 +833,6 @@ public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync( return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// Input string as post body (optional) - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterStringSerializeRequestAsync(string??? body, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Test serialization of outer string types /// @@ -946,8 +872,6 @@ public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(s public async System.Threading.Tasks.Task> FakeOuterStringSerializeWithHttpInfoAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateFakeOuterStringSerializeRequestAsync(body, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/outer/string"; @@ -966,18 +890,11 @@ public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(s - // todo localVarRequestOptions.Data = body; + request.Content = new System.Net.Http.StringContent(body.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -992,13 +909,6 @@ public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(s return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateGetArrayOfEnumsRequestAsync(System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Array of Enums /// @@ -1035,8 +945,6 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S public async System.Threading.Tasks.Task>> GetArrayOfEnumsWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { - await ValidateGetArrayOfEnumsRequestAsync(cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/array-of-enums"; @@ -1058,12 +966,6 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1078,14 +980,6 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithFileSchemaRequestAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -1100,8 +994,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithFileSchem if (fileSchemaTestClass == null) throw new ArgumentNullException(nameof(fileSchemaTestClass)); - await ValidateTestBodyWithFileSchemaRequestAsync(fileSchemaTestClass, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/body-with-file-schema"; @@ -1120,18 +1012,11 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithFileSchem - // todo localVarRequestOptions.Data = fileSchemaTestClass; + request.Content = new System.Net.Http.StringContent(fileSchemaTestClass.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1145,15 +1030,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithFileSchem return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// - /// - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithQueryParamsRequestAsync(string query, User user, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -1171,8 +1047,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithQueryPara if (user == null) throw new ArgumentNullException(nameof(user)); - await ValidateTestBodyWithQueryParamsRequestAsync(query, user, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/body-with-query-params"; @@ -1193,18 +1067,11 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithQueryPara - // todo localVarRequestOptions.Data = user; + request.Content = new System.Net.Http.StringContent(user.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1218,14 +1085,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithQueryPara return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// client model - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateTestClientModelRequestAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// To test \"client\" model To test \"client\" model /// @@ -1267,8 +1126,6 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model if (modelClient == null) throw new ArgumentNullException(nameof(modelClient)); - await ValidateTestClientModelRequestAsync(modelClient, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake"; @@ -1287,18 +1144,11 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model - // todo localVarRequestOptions.Data = modelClient; + request.Content = new System.Net.Http.StringContent(modelClient.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1313,27 +1163,6 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// None - /// None - /// None - /// None - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional) - /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") - /// None (optional) - /// None (optional) - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateTestEndpointParametersRequestAsync(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int???? integer, int???? int32, long???? int64, float???? _float, string??? _string, System.IO.Stream??? binary, DateTime???? date, DateTime???? dateTime, string??? password, string??? callback, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -1363,8 +1192,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestEndpointParameter if (_byte == null) throw new ArgumentNullException(nameof(_byte)); - await ValidateTestEndpointParametersRequestAsync(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, _string, binary, date, dateTime, password, callback, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake"; @@ -1435,13 +1262,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestEndpointParameter request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); - string[] contentTypes = new string[] { - "application/x-www-form-urlencoded" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1455,21 +1275,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestEndpointParameter return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// Header parameter enum test (string array) (optional) - /// Header parameter enum test (string) (optional, default to -efg) - /// Query parameter enum test (string array) (optional) - /// Query parameter enum test (string) (optional, default to -efg) - /// Query parameter enum test (double) (optional) - /// Query parameter enum test (double) (optional) - /// Form parameter enum test (string array) (optional, default to $) - /// Form parameter enum test (string) (optional, default to -efg) - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateTestEnumParametersRequestAsync(List??? enumHeaderStringArray, string??? enumHeaderString, List??? enumQueryStringArray, string??? enumQueryString, int???? enumQueryInteger, double???? enumQueryDouble, List??? enumFormStringArray, string??? enumFormString, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -1489,8 +1294,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestEnumParametersReq public async System.Threading.Tasks.Task> TestEnumParametersWithHttpInfoAsync(List??? enumHeaderStringArray = null, string??? enumHeaderString = null, List??? enumQueryStringArray = null, string??? enumQueryString = null, int???? enumQueryInteger = null, double???? enumQueryDouble = null, List??? enumFormStringArray = null, string??? enumFormString = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateTestEnumParametersRequestAsync(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake"; @@ -1537,13 +1340,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestEnumParametersReq request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); - string[] contentTypes = new string[] { - "application/x-www-form-urlencoded" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1557,19 +1353,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestEnumParametersReq return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// Required String in group parameters - /// Required Boolean in group parameters - /// Required Integer in group parameters - /// String in group parameters (optional) - /// Boolean in group parameters (optional) - /// Integer in group parameters (optional) - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateTestGroupParametersRequestAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup, bool???? booleanGroup, long???? int64Group, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -1587,8 +1370,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestGroupParametersRe public async System.Threading.Tasks.Task> TestGroupParametersWithHttpInfoAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup = null, bool???? booleanGroup = null, long???? int64Group = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateTestGroupParametersRequestAsync(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake"; @@ -1628,12 +1409,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestGroupParametersRe //todo request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1647,14 +1422,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestGroupParametersRe return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// request body - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateTestInlineAdditionalPropertiesRequestAsync(Dictionary requestBody, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -1669,8 +1436,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestInlineAdditionalP if (requestBody == null) throw new ArgumentNullException(nameof(requestBody)); - await ValidateTestInlineAdditionalPropertiesRequestAsync(requestBody, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/inline-additionalProperties"; @@ -1689,18 +1454,11 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestInlineAdditionalP - // todo localVarRequestOptions.Data = requestBody; + request.Content = new System.Net.Http.StringContent(requestBody.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1714,15 +1472,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestInlineAdditionalP return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// field1 - /// field2 - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateTestJsonFormDataRequestAsync(string param, string param2, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -1740,8 +1489,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestJsonFormDataReque if (param2 == null) throw new ArgumentNullException(nameof(param2)); - await ValidateTestJsonFormDataRequestAsync(param, param2, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/jsonFormData"; @@ -1766,13 +1513,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestJsonFormDataReque request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); - string[] contentTypes = new string[] { - "application/x-www-form-urlencoded" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1786,18 +1526,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestJsonFormDataReque return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// - /// - /// - /// - /// - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateTestQueryParameterCollectionFormatRequestAsync(List pipe, List ioutil, List http, List url, List context, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -1824,8 +1552,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestQueryParameterCol if (context == null) throw new ArgumentNullException(nameof(context)); - await ValidateTestQueryParameterCollectionFormatRequestAsync(pipe, ioutil, http, url, context, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/test-query-paramters"; @@ -1857,12 +1583,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestQueryParameterCol - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 4ce310c787d1..03f6af734912 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -82,14 +82,6 @@ public FakeClassnameTags123Api(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } - /// - /// Validate the input before sending the request - /// - /// client model - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateTestClassnameRequestAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// To test class name in snake case To test class name in snake case /// @@ -131,8 +123,6 @@ public async System.Threading.Tasks.Task TestClassnameAsync(ModelCl if (modelClient == null) throw new ArgumentNullException(nameof(modelClient)); - await ValidateTestClassnameRequestAsync(modelClient, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake_classname_test"; @@ -151,7 +141,7 @@ public async System.Threading.Tasks.Task TestClassnameAsync(ModelCl - // todo localVarRequestOptions.Data = modelClient; + request.Content = new System.Net.Http.StringContent(modelClient.ToJson(), System.Text.Encoding.UTF8, "application/json"); // authentication (api_key_query) required //todo if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key_query"))) @@ -159,13 +149,6 @@ public async System.Threading.Tasks.Task TestClassnameAsync(ModelCl request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs index 69f4202763cc..af2d43fd4bbc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs @@ -332,14 +332,6 @@ public PetApi(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } - /// - /// Validate the input before sending the request - /// - /// Pet object that needs to be added to the store - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateAddPetRequestAsync(Pet pet, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -354,8 +346,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateAddPetRequestAsync(Pe if (pet == null) throw new ArgumentNullException(nameof(pet)); - await ValidateAddPetRequestAsync(pet, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/pet"; @@ -374,7 +364,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateAddPetRequestAsync(Pe - // todo localVarRequestOptions.Data = pet; + request.Content = new System.Net.Http.StringContent(pet.ToJson(), System.Text.Encoding.UTF8, "application/json"); // authentication (http_signature_test) required //todo @@ -403,14 +393,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateAddPetRequestAsync(Pe request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); - string[] contentTypes = new string[] { - "application/json", - "application/xml" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -424,15 +406,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateAddPetRequestAsync(Pe return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// Pet id to delete - /// (optional) - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateDeletePetRequestAsync(long petId, string??? apiKey, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -446,8 +419,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeletePetRequestAsync public async System.Threading.Tasks.Task> DeletePetWithHttpInfoAsync(long petId, string??? apiKey = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateDeletePetRequestAsync(petId, apiKey, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/pet/{petId}"; @@ -477,12 +448,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeletePetRequestAsync //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -496,14 +461,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeletePetRequestAsync return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// Status values that need to be considered for filter - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateFindPetsByStatusRequestAsync(List status, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Finds Pets by status Multiple status values can be provided with comma separated strings /// @@ -545,8 +502,6 @@ public async System.Threading.Tasks.Task> FindPetsByStatusAsync(List> FindPetsByStatusAsync(List 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -614,14 +563,6 @@ public async System.Threading.Tasks.Task> FindPetsByStatusAsync(List - /// Validate the input before sending the request - /// - /// Tags to filter by - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateFindPetsByTagsRequestAsync(List tags, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// @@ -663,8 +604,6 @@ public async System.Threading.Tasks.Task> FindPetsByTagsAsync(List> FindPetsByTagsAsync(List 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -732,14 +665,6 @@ public async System.Threading.Tasks.Task> FindPetsByTagsAsync(List - /// Validate the input before sending the request - /// - /// ID of pet to return - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateGetPetByIdRequestAsync(long petId, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Find pet by ID Returns a single pet /// @@ -779,8 +704,6 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System public async System.Threading.Tasks.Task> GetPetByIdWithHttpInfoAsync(long petId, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateGetPetByIdRequestAsync(petId, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/pet/{petId}"; @@ -812,12 +735,6 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System request.Headers.Add("authorization", $"Bearer {token}"); - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -833,14 +750,6 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// Pet object that needs to be added to the store - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetRequestAsync(Pet pet, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -855,8 +764,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetRequestAsync if (pet == null) throw new ArgumentNullException(nameof(pet)); - await ValidateUpdatePetRequestAsync(pet, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/pet"; @@ -875,7 +782,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetRequestAsync - // todo localVarRequestOptions.Data = pet; + request.Content = new System.Net.Http.StringContent(pet.ToJson(), System.Text.Encoding.UTF8, "application/json"); // authentication (http_signature_test) required //todo @@ -904,14 +811,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetRequestAsync request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); - string[] contentTypes = new string[] { - "application/json", - "application/xml" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -925,16 +824,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetRequestAsync return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// ID of pet that needs to be updated - /// Updated name of the pet (optional) - /// Updated status of the pet (optional) - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetWithFormRequestAsync(long petId, string??? name, string??? status, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -949,8 +838,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetWithFormRequ public async System.Threading.Tasks.Task> UpdatePetWithFormWithHttpInfoAsync(long petId, string??? name = null, string??? status = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateUpdatePetWithFormRequestAsync(petId, name, status, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/pet/{petId}"; @@ -987,13 +874,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetWithFormRequ request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); - string[] contentTypes = new string[] { - "application/x-www-form-urlencoded" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1007,16 +887,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetWithFormRequ return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// ID of pet to update - /// Additional data to pass to server (optional) - /// file to upload (optional) - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateUploadFileRequestAsync(long petId, string??? additionalMetadata, System.IO.Stream??? file, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// uploads an image /// @@ -1062,8 +932,6 @@ public async System.Threading.Tasks.Task UploadFileAsync(long petId public async System.Threading.Tasks.Task> UploadFileWithHttpInfoAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateUploadFileRequestAsync(petId, additionalMetadata, file, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/pet/{petId}/uploadImage"; @@ -1100,13 +968,6 @@ public async System.Threading.Tasks.Task UploadFileAsync(long petId request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("multipart/form-data")); - string[] contentTypes = new string[] { - "multipart/form-data" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1121,16 +982,6 @@ public async System.Threading.Tasks.Task UploadFileAsync(long petId return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// ID of pet to update - /// file to upload - /// Additional data to pass to server (optional) - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateUploadFileWithRequiredFileRequestAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// uploads an image (required) /// @@ -1178,8 +1029,6 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); - await ValidateUploadFileWithRequiredFileRequestAsync(petId, requiredFile, additionalMetadata, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/{petId}/uploadImageWithRequiredFile"; @@ -1213,13 +1062,6 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("multipart/form-data")); - string[] contentTypes = new string[] { - "multipart/form-data" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs index a182683c6885..61d39ba2a183 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs @@ -171,14 +171,6 @@ public StoreApi(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } - /// - /// Validate the input before sending the request - /// - /// ID of the order that needs to be deleted - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateDeleteOrderRequestAsync(string orderId, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -193,8 +185,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeleteOrderRequestAsy if (orderId == null) throw new ArgumentNullException(nameof(orderId)); - await ValidateDeleteOrderRequestAsync(orderId, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/store/order/{order_id}"; @@ -218,12 +208,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeleteOrderRequestAsy - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -237,13 +221,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeleteOrderRequestAsy return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateGetInventoryRequestAsync(System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Returns pet inventories by status Returns a map of status codes to quantities /// @@ -280,8 +257,6 @@ public async System.Threading.Tasks.Task> GetInventoryAs public async System.Threading.Tasks.Task>> GetInventoryWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { - await ValidateGetInventoryRequestAsync(cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/store/inventory"; @@ -311,12 +286,6 @@ public async System.Threading.Tasks.Task> GetInventoryAs request.Headers.Add("authorization", $"Bearer {token}"); - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -331,14 +300,6 @@ public async System.Threading.Tasks.Task> GetInventoryAs return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// ID of pet that needs to be fetched - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateGetOrderByIdRequestAsync(long orderId, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions /// @@ -378,8 +339,6 @@ public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, public async System.Threading.Tasks.Task> GetOrderByIdWithHttpInfoAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null) { - await ValidateGetOrderByIdRequestAsync(orderId, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/store/order/{order_id}"; @@ -403,12 +362,6 @@ public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -424,14 +377,6 @@ public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// order placed for purchasing the pet - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidatePlaceOrderRequestAsync(Order order, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Place an order for a pet /// @@ -473,8 +418,6 @@ public async System.Threading.Tasks.Task PlaceOrderAsync(Order order, Sys if (order == null) throw new ArgumentNullException(nameof(order)); - await ValidatePlaceOrderRequestAsync(order, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/store/order"; @@ -493,18 +436,11 @@ public async System.Threading.Tasks.Task PlaceOrderAsync(Order order, Sys - // todo localVarRequestOptions.Data = order; + request.Content = new System.Net.Http.StringContent(order.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs index ba76f373a2e2..a2ebef731459 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs @@ -263,14 +263,6 @@ public UserApi(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } - /// - /// Validate the input before sending the request - /// - /// Created user object - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateCreateUserRequestAsync(User user, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -285,8 +277,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUserRequestAsyn if (user == null) throw new ArgumentNullException(nameof(user)); - await ValidateCreateUserRequestAsync(user, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user"; @@ -305,18 +295,11 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUserRequestAsyn - // todo localVarRequestOptions.Data = user; + request.Content = new System.Net.Http.StringContent(user.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -330,14 +313,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUserRequestAsyn return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// List of user object - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithArrayInputRequestAsync(List user, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -352,8 +327,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithArrayI if (user == null) throw new ArgumentNullException(nameof(user)); - await ValidateCreateUsersWithArrayInputRequestAsync(user, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/createWithArray"; @@ -372,18 +345,11 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithArrayI - // todo localVarRequestOptions.Data = user; + request.Content = new System.Net.Http.StringContent(user.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -397,14 +363,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithArrayI return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// List of user object - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithListInputRequestAsync(List user, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -419,8 +377,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithListIn if (user == null) throw new ArgumentNullException(nameof(user)); - await ValidateCreateUsersWithListInputRequestAsync(user, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/createWithList"; @@ -439,18 +395,11 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithListIn - // todo localVarRequestOptions.Data = user; + request.Content = new System.Net.Http.StringContent(user.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -464,14 +413,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithListIn return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// The name that needs to be deleted - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateDeleteUserRequestAsync(string username, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -486,8 +427,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeleteUserRequestAsyn if (username == null) throw new ArgumentNullException(nameof(username)); - await ValidateDeleteUserRequestAsync(username, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/{username}"; @@ -511,12 +450,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeleteUserRequestAsyn - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -530,14 +463,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeleteUserRequestAsyn return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// The name that needs to be fetched. Use user1 for testing. - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateGetUserByNameRequestAsync(string username, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Get user by user name /// @@ -579,8 +504,6 @@ public async System.Threading.Tasks.Task GetUserByNameAsync(string usernam if (username == null) throw new ArgumentNullException(nameof(username)); - await ValidateGetUserByNameRequestAsync(username, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/{username}"; @@ -604,12 +527,6 @@ public async System.Threading.Tasks.Task GetUserByNameAsync(string usernam - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -625,15 +542,6 @@ public async System.Threading.Tasks.Task GetUserByNameAsync(string usernam return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// The user name for login - /// The password for login in clear text - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateLoginUserRequestAsync(string username, string password, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// /// Logs user into the system /// @@ -680,8 +588,6 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, if (password == null) throw new ArgumentNullException(nameof(password)); - await ValidateLoginUserRequestAsync(username, password, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/login"; @@ -707,12 +613,6 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -728,13 +628,6 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateLogoutUserRequestAsync(System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -746,8 +639,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateLogoutUserRequestAsyn public async System.Threading.Tasks.Task> LogoutUserWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { - await ValidateLogoutUserRequestAsync(cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/logout"; @@ -769,12 +660,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateLogoutUserRequestAsyn - string[] contentTypes = new string[] { - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -788,15 +673,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateLogoutUserRequestAsyn return apiResponse; } - /// - /// Validate the input before sending the request - /// - /// name that need to be deleted - /// Updated user object - /// Cancellation Token to cancel the request. - protected virtual System.Threading.Tasks.ValueTask ValidateUpdateUserRequestAsync(string username, User user, System.Threading.CancellationToken? cancellationToken) - => new System.Threading.Tasks.ValueTask(); - /// @@ -814,8 +690,6 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdateUserRequestAsyn if (user == null) throw new ArgumentNullException(nameof(user)); - await ValidateUpdateUserRequestAsync(username, user, cancellationToken).ConfigureAwait(false); - using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/{username}"; @@ -836,18 +710,11 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdateUserRequestAsyn - // todo localVarRequestOptions.Data = user; + request.Content = new System.Net.Http.StringContent(user.ToJson(), System.Text.Encoding.UTF8, "application/json"); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - string[] contentTypes = new string[] { - "application/json" - }; - - if (request.Content != null && contentTypes.Length > 0) - request.Content.Headers.Add("CONTENT-TYPE", contentTypes); - using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); From 685ed600d6d868da16363aa5b614c02ffb38744c Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Mon, 15 Feb 2021 11:26:32 -0500 Subject: [PATCH 13/20] renamed response data to content --- .../httpclient/ApiException.mustache | 8 ++--- .../libraries/httpclient/ApiResponse.mustache | 14 ++++----- .../libraries/httpclient/api.mustache | 31 ++++++++++++++++--- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiException.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiException.mustache index 03ad75ce5a09..6c9d4e986000 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiException.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiException.mustache @@ -22,21 +22,21 @@ namespace {{packageName}}.Client /// /// The raw data returned by the api /// - public string RawData { get; } + public string RawContent { get; } /// /// Construct the ApiException from parts of the reponse /// /// /// - /// - public ApiException(string? reasonPhrase, System.Net.HttpStatusCode statusCode, string rawData) : base(reasonPhrase ?? rawData) + /// + public ApiException(string? reasonPhrase, System.Net.HttpStatusCode statusCode, string rawContent) : base(reasonPhrase ?? rawContent) { ReasonPhrase = reasonPhrase; StatusCode = statusCode; - RawData = rawData; + RawContent = rawContent; } } } diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache index 29675f21fa2d..5d6259381501 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache @@ -31,7 +31,7 @@ namespace {{packageName}}.Client /// /// The raw content of this response /// - string RawData { get; } + string RawContent { get; } } /// @@ -42,9 +42,9 @@ namespace {{packageName}}.Client #region Properties /// - /// The deserialized data + /// The deserialized content /// - public T? Data { get; set; } + public T? Content { get; set; } /// /// Gets or sets the status code (HTTP status code) @@ -68,7 +68,7 @@ namespace {{packageName}}.Client /// /// The raw data /// - public string RawData { get; } + public string RawContent { get; } /// /// The IsSuccessStatusCode from the api response @@ -91,14 +91,14 @@ namespace {{packageName}}.Client /// Construct the reponse using an HttpResponseMessage /// /// - /// - public ApiResponse(System.Net.Http.HttpResponseMessage response, string rawData) + /// + public ApiResponse(System.Net.Http.HttpResponseMessage response, string rawContent) { StatusCode = response.StatusCode; Headers = response.Headers; IsSuccessStatusCode = response.IsSuccessStatusCode; ReasonPhrase = response.ReasonPhrase; - RawData = rawData; + RawContent = rawContent; } } } diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache index e0f52c78ca2c..89f88d695c1b 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache @@ -85,7 +85,17 @@ namespace {{packageName}}.{{apiPackage}} /// public Func>? GetTokenAsync { get; set; } - {{#operation}} + {{#operation}} + + /// + /// Validate the input before sending the request + /// + {{#allParams}} + /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} + {{/allParams}} + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask Validate{{operationId}}RequestAsync({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); {{#returnType}} /// @@ -100,7 +110,7 @@ namespace {{packageName}}.{{apiPackage}} public async System.Threading.Tasks.Task<{{{returnType}}}> {{operationId}}Async({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{{dataType}}}??? {{paramName}} = null{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken? cancellationToken = null) { {{packageName}}.Client.ApiResponse<{{{returnType}}}> result = await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } {{/returnType}} @@ -119,7 +129,7 @@ namespace {{packageName}}.{{apiPackage}} {{packageName}}.Client.ApiResponse<{{{returnType}}}> result = await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } {{/returnType}} @@ -144,6 +154,8 @@ namespace {{packageName}}.{{apiPackage}} {{/required}} {{/allParams}} + await Validate{{operationId}}RequestAsync({{#allParams}}{{#required}}{{paramName}}{{^-last}}, {{/-last}}{{/required}}{{^required}}{{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "{{path}}"; @@ -216,7 +228,7 @@ namespace {{packageName}}.{{apiPackage}} {{/formParams}} {{#bodyParam}} - request.Content = new System.Net.Http.StringContent({{paramName}}.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = {{paramName}}; {{/bodyParam}} {{#authMethods}} @@ -283,6 +295,15 @@ namespace {{packageName}}.{{apiPackage}} request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("{{{mediaType}}}")); {{/consumes}} + string[] contentTypes = new string[] { + {{#consumes}} + "{{{mediaType}}}"{{^-last}}, {{/-last}} + {{/consumes}} + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + {{#produces}} request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("{{{mediaType}}}")); {{/produces}} @@ -294,7 +315,7 @@ namespace {{packageName}}.{{apiPackage}} ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } From 3e92edf34b2e3150dca2a835465f8c7a69a23bed Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Mon, 15 Feb 2021 13:47:47 -0500 Subject: [PATCH 14/20] added GetHashCode to match Equals override --- .../httpclient/modelGeneric.mustache | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache index 404badbfeb01..d941d2e10d7e 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache @@ -233,6 +233,37 @@ {{/useCompareNetObjects}} } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + {{#parent}} + int hashCode = base.GetHashCode(); + {{/parent}} + {{^parent}} + int hashCode = 41; + {{/parent}} + {{#vars}} + {{^vendorExtensions.x-is-value-type}} + if (this.{{name}} != null) + hashCode = hashCode * 59 + this.{{name}}.GetHashCode(); + {{/vendorExtensions.x-is-value-type}} + {{#vendorExtensions.x-is-value-type}} + hashCode = hashCode * 59 + this.{{name}}.GetHashCode(); + {{/vendorExtensions.x-is-value-type}} + {{/vars}} + {{#isAdditionalPropertiesTrue}} + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + {{/isAdditionalPropertiesTrue}} + return hashCode; + } + } + {{#validatable}} {{#discriminator}} /// From 3b2509c63729dedc9cb068a46705222d1b7563e0 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Mon, 15 Feb 2021 13:56:42 -0500 Subject: [PATCH 15/20] build samples --- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 25 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 21 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 354 ++++++++++++++++-- .../Api/FakeClassnameTags123Api.cs | 25 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 200 ++++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 86 ++++- .../src/Org.OpenAPITools/Api/UserApi.cs | 165 +++++++- .../Org.OpenAPITools/Client/ApiException.cs | 8 +- .../Org.OpenAPITools/Client/ApiResponse.cs | 14 +- .../Model/AdditionalPropertiesClass.cs | 31 ++ .../src/Org.OpenAPITools/Model/Animal.cs | 19 + .../src/Org.OpenAPITools/Model/ApiResponse.cs | 20 + .../src/Org.OpenAPITools/Model/Apple.cs | 19 + .../src/Org.OpenAPITools/Model/AppleReq.cs | 16 + .../Model/ArrayOfArrayOfNumberOnly.cs | 17 + .../Model/ArrayOfNumberOnly.cs | 17 + .../src/Org.OpenAPITools/Model/ArrayTest.cs | 21 ++ .../src/Org.OpenAPITools/Model/Banana.cs | 16 + .../src/Org.OpenAPITools/Model/BananaReq.cs | 15 + .../src/Org.OpenAPITools/Model/BasquePig.cs | 17 + .../Org.OpenAPITools/Model/Capitalization.cs | 27 ++ .../src/Org.OpenAPITools/Model/Cat.cs | 16 + .../src/Org.OpenAPITools/Model/CatAllOf.cs | 16 + .../src/Org.OpenAPITools/Model/Category.cs | 18 + .../src/Org.OpenAPITools/Model/ChildCat.cs | 18 + .../Org.OpenAPITools/Model/ChildCatAllOf.cs | 18 + .../src/Org.OpenAPITools/Model/ClassModel.cs | 17 + .../Model/ComplexQuadrilateral.cs | 19 + .../src/Org.OpenAPITools/Model/DanishPig.cs | 17 + .../src/Org.OpenAPITools/Model/Dog.cs | 17 + .../src/Org.OpenAPITools/Model/DogAllOf.cs | 17 + .../src/Org.OpenAPITools/Model/Drawing.cs | 21 ++ .../src/Org.OpenAPITools/Model/EnumArrays.cs | 17 + .../src/Org.OpenAPITools/Model/EnumTest.cs | 23 ++ .../Model/EquilateralTriangle.cs | 19 + .../src/Org.OpenAPITools/Model/File.cs | 17 + .../Model/FileSchemaTestClass.cs | 19 + .../src/Org.OpenAPITools/Model/Foo.cs | 17 + .../src/Org.OpenAPITools/Model/FormatTest.cs | 40 ++ .../Model/GrandparentAnimal.cs | 17 + .../Org.OpenAPITools/Model/HasOnlyReadOnly.cs | 19 + .../Model/HealthCheckResult.cs | 17 + .../Model/InlineResponseDefault.cs | 17 + .../Model/IsoscelesTriangle.cs | 17 + .../src/Org.OpenAPITools/Model/List.cs | 17 + .../src/Org.OpenAPITools/Model/MapTest.cs | 22 ++ ...dPropertiesAndAdditionalPropertiesClass.cs | 21 ++ .../Model/Model200Response.cs | 18 + .../src/Org.OpenAPITools/Model/ModelClient.cs | 17 + .../src/Org.OpenAPITools/Model/Name.cs | 20 + .../Org.OpenAPITools/Model/NullableClass.cs | 37 ++ .../src/Org.OpenAPITools/Model/NumberOnly.cs | 16 + .../src/Org.OpenAPITools/Model/Order.cs | 22 ++ .../Org.OpenAPITools/Model/OuterComposite.cs | 19 + .../src/Org.OpenAPITools/Model/ParentPet.cs | 15 + .../src/Org.OpenAPITools/Model/Pet.cs | 25 ++ .../Model/QuadrilateralInterface.cs | 17 + .../Org.OpenAPITools/Model/ReadOnlyFirst.cs | 19 + .../src/Org.OpenAPITools/Model/Return.cs | 16 + .../Org.OpenAPITools/Model/ScaleneTriangle.cs | 19 + .../Org.OpenAPITools/Model/ShapeInterface.cs | 17 + .../Model/SimpleQuadrilateral.cs | 19 + .../Model/SpecialModelName.cs | 16 + .../src/Org.OpenAPITools/Model/Tag.cs | 18 + .../Model/TriangleInterface.cs | 17 + .../src/Org.OpenAPITools/Model/User.cs | 37 ++ .../src/Org.OpenAPITools/Model/Whale.cs | 19 + .../src/Org.OpenAPITools/Model/Zebra.cs | 18 + 68 files changed, 1940 insertions(+), 107 deletions(-) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index c6b61416bec6..e7d3fa99b39f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -82,6 +82,14 @@ public AnotherFakeApi(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } + /// + /// Validate the input before sending the request + /// + /// client model + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateCall123TestSpecialTagsRequestAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// To test special tags To test special tags and operation ID starting with number /// @@ -92,7 +100,7 @@ public AnotherFakeApi(System.Net.Http.HttpClient httpClient) public async System.Threading.Tasks.Task Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await Call123TestSpecialTagsWithHttpInfoAsync(modelClient, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -107,7 +115,7 @@ public async System.Threading.Tasks.Task Call123TestSpecialTagsAsyn Org.OpenAPITools.Client.ApiResponse result = await Call123TestSpecialTagsWithHttpInfoAsync(modelClient, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -123,6 +131,8 @@ public async System.Threading.Tasks.Task Call123TestSpecialTagsAsyn if (modelClient == null) throw new ArgumentNullException(nameof(modelClient)); + await ValidateCall123TestSpecialTagsRequestAsync(modelClient, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/another-fake/dummy"; @@ -141,11 +151,18 @@ public async System.Threading.Tasks.Task Call123TestSpecialTagsAsyn - request.Content = new System.Net.Http.StringContent(modelClient.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = modelClient; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -155,7 +172,7 @@ public async System.Threading.Tasks.Task Call123TestSpecialTagsAsyn ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs index 8e25748e7c03..eb42e5d528c8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -79,6 +79,13 @@ public DefaultApi(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } + /// + /// Validate the input before sending the request + /// + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFooGetRequestAsync(System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// /// @@ -88,7 +95,7 @@ public DefaultApi(System.Net.Http.HttpClient httpClient) public async System.Threading.Tasks.Task FooGetAsync(System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await FooGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -102,7 +109,7 @@ public async System.Threading.Tasks.Task FooGetAsync(Syst Org.OpenAPITools.Client.ApiResponse result = await FooGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -115,6 +122,8 @@ public async System.Threading.Tasks.Task FooGetAsync(Syst public async System.Threading.Tasks.Task> FooGetWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { + await ValidateFooGetRequestAsync(cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/foo"; @@ -136,6 +145,12 @@ public async System.Threading.Tasks.Task FooGetAsync(Syst + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -145,7 +160,7 @@ public async System.Threading.Tasks.Task FooGetAsync(Syst ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs index 6b40e3dca277..eea3c1c4294f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs @@ -534,6 +534,13 @@ public FakeApi(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } + /// + /// Validate the input before sending the request + /// + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFakeHealthGetRequestAsync(System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Health check endpoint /// @@ -543,7 +550,7 @@ public FakeApi(System.Net.Http.HttpClient httpClient) public async System.Threading.Tasks.Task FakeHealthGetAsync(System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await FakeHealthGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -557,7 +564,7 @@ public async System.Threading.Tasks.Task FakeHealthGetAsync(S Org.OpenAPITools.Client.ApiResponse result = await FakeHealthGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -570,6 +577,8 @@ public async System.Threading.Tasks.Task FakeHealthGetAsync(S public async System.Threading.Tasks.Task> FakeHealthGetWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { + await ValidateFakeHealthGetRequestAsync(cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/health"; @@ -591,6 +600,12 @@ public async System.Threading.Tasks.Task FakeHealthGetAsync(S + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -600,11 +615,19 @@ public async System.Threading.Tasks.Task FakeHealthGetAsync(S ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Input boolean as post body (optional) + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterBooleanSerializeRequestAsync(bool???? body, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Test serialization of outer boolean types /// @@ -615,7 +638,7 @@ public async System.Threading.Tasks.Task FakeHealthGetAsync(S public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await FakeOuterBooleanSerializeWithHttpInfoAsync(body, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -630,7 +653,7 @@ public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bo Org.OpenAPITools.Client.ApiResponse result = await FakeOuterBooleanSerializeWithHttpInfoAsync(body, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -644,6 +667,8 @@ public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bo public async System.Threading.Tasks.Task> FakeOuterBooleanSerializeWithHttpInfoAsync(bool???? body = null, System.Threading.CancellationToken? cancellationToken = null) { + await ValidateFakeOuterBooleanSerializeRequestAsync(body, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/outer/boolean"; @@ -662,11 +687,18 @@ public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bo - request.Content = new System.Net.Http.StringContent(body.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = body; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -676,11 +708,19 @@ public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bo ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Input composite as post body (optional) + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterCompositeSerializeRequestAsync(OuterComposite??? outerComposite, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Test serialization of object with outer number type /// @@ -691,7 +731,7 @@ public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bo public async System.Threading.Tasks.Task FakeOuterCompositeSerializeAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await FakeOuterCompositeSerializeWithHttpInfoAsync(outerComposite, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -706,7 +746,7 @@ public async System.Threading.Tasks.Task FakeOuterCompositeSeria Org.OpenAPITools.Client.ApiResponse result = await FakeOuterCompositeSerializeWithHttpInfoAsync(outerComposite, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -720,6 +760,8 @@ public async System.Threading.Tasks.Task FakeOuterCompositeSeria public async System.Threading.Tasks.Task> FakeOuterCompositeSerializeWithHttpInfoAsync(OuterComposite??? outerComposite = null, System.Threading.CancellationToken? cancellationToken = null) { + await ValidateFakeOuterCompositeSerializeRequestAsync(outerComposite, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/outer/composite"; @@ -738,11 +780,18 @@ public async System.Threading.Tasks.Task FakeOuterCompositeSeria - request.Content = new System.Net.Http.StringContent(outerComposite.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = outerComposite; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -752,11 +801,19 @@ public async System.Threading.Tasks.Task FakeOuterCompositeSeria ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Input number as post body (optional) + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterNumberSerializeRequestAsync(decimal???? body, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Test serialization of outer number types /// @@ -767,7 +824,7 @@ public async System.Threading.Tasks.Task FakeOuterCompositeSeria public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync(decimal???? body = null, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await FakeOuterNumberSerializeWithHttpInfoAsync(body, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -782,7 +839,7 @@ public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync( Org.OpenAPITools.Client.ApiResponse result = await FakeOuterNumberSerializeWithHttpInfoAsync(body, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -796,6 +853,8 @@ public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync( public async System.Threading.Tasks.Task> FakeOuterNumberSerializeWithHttpInfoAsync(decimal???? body = null, System.Threading.CancellationToken? cancellationToken = null) { + await ValidateFakeOuterNumberSerializeRequestAsync(body, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/outer/number"; @@ -814,11 +873,18 @@ public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync( - request.Content = new System.Net.Http.StringContent(body.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = body; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -828,11 +894,19 @@ public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync( ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Input string as post body (optional) + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterStringSerializeRequestAsync(string??? body, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Test serialization of outer string types /// @@ -843,7 +917,7 @@ public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync( public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await FakeOuterStringSerializeWithHttpInfoAsync(body, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -858,7 +932,7 @@ public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(s Org.OpenAPITools.Client.ApiResponse result = await FakeOuterStringSerializeWithHttpInfoAsync(body, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -872,6 +946,8 @@ public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(s public async System.Threading.Tasks.Task> FakeOuterStringSerializeWithHttpInfoAsync(string??? body = null, System.Threading.CancellationToken? cancellationToken = null) { + await ValidateFakeOuterStringSerializeRequestAsync(body, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/outer/string"; @@ -890,11 +966,18 @@ public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(s - request.Content = new System.Net.Http.StringContent(body.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = body; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -904,11 +987,18 @@ public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(s ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateGetArrayOfEnumsRequestAsync(System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Array of Enums /// @@ -918,7 +1008,7 @@ public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(s public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse> result = await GetArrayOfEnumsWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -932,7 +1022,7 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S Org.OpenAPITools.Client.ApiResponse> result = await GetArrayOfEnumsWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -945,6 +1035,8 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S public async System.Threading.Tasks.Task>> GetArrayOfEnumsWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { + await ValidateGetArrayOfEnumsRequestAsync(cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/array-of-enums"; @@ -966,6 +1058,12 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -975,11 +1073,19 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S ApiResponse> apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithFileSchemaRequestAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -994,6 +1100,8 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S if (fileSchemaTestClass == null) throw new ArgumentNullException(nameof(fileSchemaTestClass)); + await ValidateTestBodyWithFileSchemaRequestAsync(fileSchemaTestClass, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/body-with-file-schema"; @@ -1012,11 +1120,18 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S - request.Content = new System.Net.Http.StringContent(fileSchemaTestClass.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = fileSchemaTestClass; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1025,11 +1140,20 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// + /// + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithQueryParamsRequestAsync(string query, User user, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -1047,6 +1171,8 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S if (user == null) throw new ArgumentNullException(nameof(user)); + await ValidateTestBodyWithQueryParamsRequestAsync(query, user, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/body-with-query-params"; @@ -1067,11 +1193,18 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S - request.Content = new System.Net.Http.StringContent(user.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = user; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1080,11 +1213,19 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// client model + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestClientModelRequestAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// To test \"client\" model To test \"client\" model /// @@ -1095,7 +1236,7 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S public async System.Threading.Tasks.Task TestClientModelAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await TestClientModelWithHttpInfoAsync(modelClient, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -1110,7 +1251,7 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model Org.OpenAPITools.Client.ApiResponse result = await TestClientModelWithHttpInfoAsync(modelClient, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -1126,6 +1267,8 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model if (modelClient == null) throw new ArgumentNullException(nameof(modelClient)); + await ValidateTestClientModelRequestAsync(modelClient, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake"; @@ -1144,11 +1287,18 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model - request.Content = new System.Net.Http.StringContent(modelClient.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = modelClient; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1158,11 +1308,32 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") + /// None (optional) + /// None (optional) + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestEndpointParametersRequestAsync(decimal number, double _double, string patternWithoutDelimiter, byte[] _byte, int???? integer, int???? int32, long???? int64, float???? _float, string??? _string, System.IO.Stream??? binary, DateTime???? date, DateTime???? dateTime, string??? password, string??? callback, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -1192,6 +1363,8 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model if (_byte == null) throw new ArgumentNullException(nameof(_byte)); + await ValidateTestEndpointParametersRequestAsync(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, _string, binary, date, dateTime, password, callback, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake"; @@ -1262,6 +1435,13 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1270,11 +1450,26 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Header parameter enum test (string array) (optional) + /// Header parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (string array) (optional) + /// Query parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// Form parameter enum test (string array) (optional, default to $) + /// Form parameter enum test (string) (optional, default to -efg) + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestEnumParametersRequestAsync(List??? enumHeaderStringArray, string??? enumHeaderString, List??? enumQueryStringArray, string??? enumQueryString, int???? enumQueryInteger, double???? enumQueryDouble, List??? enumFormStringArray, string??? enumFormString, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -1294,6 +1489,8 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model public async System.Threading.Tasks.Task> TestEnumParametersWithHttpInfoAsync(List??? enumHeaderStringArray = null, string??? enumHeaderString = null, List??? enumQueryStringArray = null, string??? enumQueryString = null, int???? enumQueryInteger = null, double???? enumQueryDouble = null, List??? enumFormStringArray = null, string??? enumFormString = null, System.Threading.CancellationToken? cancellationToken = null) { + await ValidateTestEnumParametersRequestAsync(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake"; @@ -1340,6 +1537,13 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1348,11 +1552,24 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Required String in group parameters + /// Required Boolean in group parameters + /// Required Integer in group parameters + /// String in group parameters (optional) + /// Boolean in group parameters (optional) + /// Integer in group parameters (optional) + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestGroupParametersRequestAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup, bool???? booleanGroup, long???? int64Group, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -1370,6 +1587,8 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model public async System.Threading.Tasks.Task> TestGroupParametersWithHttpInfoAsync(int requiredStringGroup, bool requiredBooleanGroup, long requiredInt64Group, int???? stringGroup = null, bool???? booleanGroup = null, long???? int64Group = null, System.Threading.CancellationToken? cancellationToken = null) { + await ValidateTestGroupParametersRequestAsync(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake"; @@ -1409,6 +1628,12 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model //todo request.Headers.Add("authorization", $"Bearer {Environment.GetEnvironmentVariable("TOKEN_0", EnvironmentVariableTarget.Machine)}"); + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1417,11 +1642,19 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// request body + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestInlineAdditionalPropertiesRequestAsync(Dictionary requestBody, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -1436,6 +1669,8 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model if (requestBody == null) throw new ArgumentNullException(nameof(requestBody)); + await ValidateTestInlineAdditionalPropertiesRequestAsync(requestBody, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/inline-additionalProperties"; @@ -1454,11 +1689,18 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model - request.Content = new System.Net.Http.StringContent(requestBody.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = requestBody; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1467,11 +1709,20 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// field1 + /// field2 + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestJsonFormDataRequestAsync(string param, string param2, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -1489,6 +1740,8 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model if (param2 == null) throw new ArgumentNullException(nameof(param2)); + await ValidateTestJsonFormDataRequestAsync(param, param2, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/jsonFormData"; @@ -1513,6 +1766,13 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1521,11 +1781,23 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestQueryParameterCollectionFormatRequestAsync(List pipe, List ioutil, List http, List url, List context, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -1552,6 +1824,8 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model if (context == null) throw new ArgumentNullException(nameof(context)); + await ValidateTestQueryParameterCollectionFormatRequestAsync(pipe, ioutil, http, url, context, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/test-query-paramters"; @@ -1583,6 +1857,12 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1591,7 +1871,7 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 03f6af734912..a245d7c6ab11 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -82,6 +82,14 @@ public FakeClassnameTags123Api(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } + /// + /// Validate the input before sending the request + /// + /// client model + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateTestClassnameRequestAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// To test class name in snake case To test class name in snake case /// @@ -92,7 +100,7 @@ public FakeClassnameTags123Api(System.Net.Http.HttpClient httpClient) public async System.Threading.Tasks.Task TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await TestClassnameWithHttpInfoAsync(modelClient, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -107,7 +115,7 @@ public async System.Threading.Tasks.Task TestClassnameAsync(ModelCl Org.OpenAPITools.Client.ApiResponse result = await TestClassnameWithHttpInfoAsync(modelClient, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -123,6 +131,8 @@ public async System.Threading.Tasks.Task TestClassnameAsync(ModelCl if (modelClient == null) throw new ArgumentNullException(nameof(modelClient)); + await ValidateTestClassnameRequestAsync(modelClient, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake_classname_test"; @@ -141,7 +151,7 @@ public async System.Threading.Tasks.Task TestClassnameAsync(ModelCl - request.Content = new System.Net.Http.StringContent(modelClient.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = modelClient; // authentication (api_key_query) required //todo if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key_query"))) @@ -149,6 +159,13 @@ public async System.Threading.Tasks.Task TestClassnameAsync(ModelCl request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -158,7 +175,7 @@ public async System.Threading.Tasks.Task TestClassnameAsync(ModelCl ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs index af2d43fd4bbc..81921fd798c0 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs @@ -332,6 +332,14 @@ public PetApi(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } + /// + /// Validate the input before sending the request + /// + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateAddPetRequestAsync(Pet pet, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -346,6 +354,8 @@ public PetApi(System.Net.Http.HttpClient httpClient) if (pet == null) throw new ArgumentNullException(nameof(pet)); + await ValidateAddPetRequestAsync(pet, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/pet"; @@ -364,7 +374,7 @@ public PetApi(System.Net.Http.HttpClient httpClient) - request.Content = new System.Net.Http.StringContent(pet.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = pet; // authentication (http_signature_test) required //todo @@ -393,6 +403,14 @@ public PetApi(System.Net.Http.HttpClient httpClient) request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); + string[] contentTypes = new string[] { + "application/json", + "application/xml" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -401,11 +419,20 @@ public PetApi(System.Net.Http.HttpClient httpClient) ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Pet id to delete + /// (optional) + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateDeletePetRequestAsync(long petId, string??? apiKey, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -419,6 +446,8 @@ public PetApi(System.Net.Http.HttpClient httpClient) public async System.Threading.Tasks.Task> DeletePetWithHttpInfoAsync(long petId, string??? apiKey = null, System.Threading.CancellationToken? cancellationToken = null) { + await ValidateDeletePetRequestAsync(petId, apiKey, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/pet/{petId}"; @@ -448,6 +477,12 @@ public PetApi(System.Net.Http.HttpClient httpClient) //todo localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -456,11 +491,19 @@ public PetApi(System.Net.Http.HttpClient httpClient) ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Status values that need to be considered for filter + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFindPetsByStatusRequestAsync(List status, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Finds Pets by status Multiple status values can be provided with comma separated strings /// @@ -471,7 +514,7 @@ public PetApi(System.Net.Http.HttpClient httpClient) public async System.Threading.Tasks.Task> FindPetsByStatusAsync(List status, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse> result = await FindPetsByStatusWithHttpInfoAsync(status, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -486,7 +529,7 @@ public async System.Threading.Tasks.Task> FindPetsByStatusAsync(List> result = await FindPetsByStatusWithHttpInfoAsync(status, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -502,6 +545,8 @@ public async System.Threading.Tasks.Task> FindPetsByStatusAsync(List> FindPetsByStatusAsync(List 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -558,11 +609,19 @@ public async System.Threading.Tasks.Task> FindPetsByStatusAsync(List> apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Tags to filter by + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateFindPetsByTagsRequestAsync(List tags, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// @@ -573,7 +632,7 @@ public async System.Threading.Tasks.Task> FindPetsByStatusAsync(List> FindPetsByTagsAsync(List tags, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse> result = await FindPetsByTagsWithHttpInfoAsync(tags, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -588,7 +647,7 @@ public async System.Threading.Tasks.Task> FindPetsByTagsAsync(List> result = await FindPetsByTagsWithHttpInfoAsync(tags, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -604,6 +663,8 @@ public async System.Threading.Tasks.Task> FindPetsByTagsAsync(List> FindPetsByTagsAsync(List 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -660,11 +727,19 @@ public async System.Threading.Tasks.Task> FindPetsByTagsAsync(List> apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// ID of pet to return + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateGetPetByIdRequestAsync(long petId, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Find pet by ID Returns a single pet /// @@ -675,7 +750,7 @@ public async System.Threading.Tasks.Task> FindPetsByTagsAsync(List GetPetByIdAsync(long petId, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await GetPetByIdWithHttpInfoAsync(petId, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -690,7 +765,7 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System Org.OpenAPITools.Client.ApiResponse result = await GetPetByIdWithHttpInfoAsync(petId, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -704,6 +779,8 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System public async System.Threading.Tasks.Task> GetPetByIdWithHttpInfoAsync(long petId, System.Threading.CancellationToken? cancellationToken = null) { + await ValidateGetPetByIdRequestAsync(petId, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/pet/{petId}"; @@ -735,6 +812,12 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System request.Headers.Add("authorization", $"Bearer {token}"); + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -745,11 +828,19 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetRequestAsync(Pet pet, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -764,6 +855,8 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System if (pet == null) throw new ArgumentNullException(nameof(pet)); + await ValidateUpdatePetRequestAsync(pet, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/pet"; @@ -782,7 +875,7 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System - request.Content = new System.Net.Http.StringContent(pet.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = pet; // authentication (http_signature_test) required //todo @@ -811,6 +904,14 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); + string[] contentTypes = new string[] { + "application/json", + "application/xml" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -819,11 +920,21 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetWithFormRequestAsync(long petId, string??? name, string??? status, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -838,6 +949,8 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System public async System.Threading.Tasks.Task> UpdatePetWithFormWithHttpInfoAsync(long petId, string??? name = null, string??? status = null, System.Threading.CancellationToken? cancellationToken = null) { + await ValidateUpdatePetWithFormRequestAsync(petId, name, status, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/pet/{petId}"; @@ -874,6 +987,13 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -882,11 +1002,21 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// ID of pet to update + /// Additional data to pass to server (optional) + /// file to upload (optional) + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateUploadFileRequestAsync(long petId, string??? additionalMetadata, System.IO.Stream??? file, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// uploads an image /// @@ -899,7 +1029,7 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System public async System.Threading.Tasks.Task UploadFileAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await UploadFileWithHttpInfoAsync(petId, additionalMetadata, file, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -916,7 +1046,7 @@ public async System.Threading.Tasks.Task UploadFileAsync(long petId Org.OpenAPITools.Client.ApiResponse result = await UploadFileWithHttpInfoAsync(petId, additionalMetadata, file, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -932,6 +1062,8 @@ public async System.Threading.Tasks.Task UploadFileAsync(long petId public async System.Threading.Tasks.Task> UploadFileWithHttpInfoAsync(long petId, string??? additionalMetadata = null, System.IO.Stream??? file = null, System.Threading.CancellationToken? cancellationToken = null) { + await ValidateUploadFileRequestAsync(petId, additionalMetadata, file, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/pet/{petId}/uploadImage"; @@ -968,6 +1100,13 @@ public async System.Threading.Tasks.Task UploadFileAsync(long petId request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("multipart/form-data")); + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -977,11 +1116,21 @@ public async System.Threading.Tasks.Task UploadFileAsync(long petId ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// ID of pet to update + /// file to upload + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateUploadFileWithRequiredFileRequestAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// uploads an image (required) /// @@ -994,7 +1143,7 @@ public async System.Threading.Tasks.Task UploadFileAsync(long petId public async System.Threading.Tasks.Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, string??? additionalMetadata = null, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await UploadFileWithRequiredFileWithHttpInfoAsync(petId, requiredFile, additionalMetadata, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -1011,7 +1160,7 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile Org.OpenAPITools.Client.ApiResponse result = await UploadFileWithRequiredFileWithHttpInfoAsync(petId, requiredFile, additionalMetadata, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -1029,6 +1178,8 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); + await ValidateUploadFileWithRequiredFileRequestAsync(petId, requiredFile, additionalMetadata, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/fake/{petId}/uploadImageWithRequiredFile"; @@ -1062,6 +1213,13 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("multipart/form-data")); + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -1071,7 +1229,7 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs index 61d39ba2a183..d357d07c6497 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs @@ -171,6 +171,14 @@ public StoreApi(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } + /// + /// Validate the input before sending the request + /// + /// ID of the order that needs to be deleted + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateDeleteOrderRequestAsync(string orderId, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -185,6 +193,8 @@ public StoreApi(System.Net.Http.HttpClient httpClient) if (orderId == null) throw new ArgumentNullException(nameof(orderId)); + await ValidateDeleteOrderRequestAsync(orderId, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/store/order/{order_id}"; @@ -208,6 +218,12 @@ public StoreApi(System.Net.Http.HttpClient httpClient) + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -216,11 +232,18 @@ public StoreApi(System.Net.Http.HttpClient httpClient) ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateGetInventoryRequestAsync(System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Returns pet inventories by status Returns a map of status codes to quantities /// @@ -230,7 +253,7 @@ public StoreApi(System.Net.Http.HttpClient httpClient) public async System.Threading.Tasks.Task> GetInventoryAsync(System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse> result = await GetInventoryWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -244,7 +267,7 @@ public async System.Threading.Tasks.Task> GetInventoryAs Org.OpenAPITools.Client.ApiResponse> result = await GetInventoryWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -257,6 +280,8 @@ public async System.Threading.Tasks.Task> GetInventoryAs public async System.Threading.Tasks.Task>> GetInventoryWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { + await ValidateGetInventoryRequestAsync(cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/store/inventory"; @@ -286,6 +311,12 @@ public async System.Threading.Tasks.Task> GetInventoryAs request.Headers.Add("authorization", $"Bearer {token}"); + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -295,11 +326,19 @@ public async System.Threading.Tasks.Task> GetInventoryAs ApiResponse> apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// ID of pet that needs to be fetched + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateGetOrderByIdRequestAsync(long orderId, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions /// @@ -310,7 +349,7 @@ public async System.Threading.Tasks.Task> GetInventoryAs public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await GetOrderByIdWithHttpInfoAsync(orderId, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -325,7 +364,7 @@ public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, Org.OpenAPITools.Client.ApiResponse result = await GetOrderByIdWithHttpInfoAsync(orderId, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -339,6 +378,8 @@ public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, public async System.Threading.Tasks.Task> GetOrderByIdWithHttpInfoAsync(long orderId, System.Threading.CancellationToken? cancellationToken = null) { + await ValidateGetOrderByIdRequestAsync(orderId, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/store/order/{order_id}"; @@ -362,6 +403,12 @@ public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -372,11 +419,19 @@ public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// order placed for purchasing the pet + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidatePlaceOrderRequestAsync(Order order, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Place an order for a pet /// @@ -387,7 +442,7 @@ public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, public async System.Threading.Tasks.Task PlaceOrderAsync(Order order, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await PlaceOrderWithHttpInfoAsync(order, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -402,7 +457,7 @@ public async System.Threading.Tasks.Task PlaceOrderAsync(Order order, Sys Org.OpenAPITools.Client.ApiResponse result = await PlaceOrderWithHttpInfoAsync(order, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -418,6 +473,8 @@ public async System.Threading.Tasks.Task PlaceOrderAsync(Order order, Sys if (order == null) throw new ArgumentNullException(nameof(order)); + await ValidatePlaceOrderRequestAsync(order, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/store/order"; @@ -436,11 +493,18 @@ public async System.Threading.Tasks.Task PlaceOrderAsync(Order order, Sys - request.Content = new System.Net.Http.StringContent(order.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = order; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -451,7 +515,7 @@ public async System.Threading.Tasks.Task PlaceOrderAsync(Order order, Sys ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs index a2ebef731459..030f219ba48f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs @@ -263,6 +263,14 @@ public UserApi(System.Net.Http.HttpClient httpClient) public Func>? GetTokenAsync { get; set; } + /// + /// Validate the input before sending the request + /// + /// Created user object + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateCreateUserRequestAsync(User user, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -277,6 +285,8 @@ public UserApi(System.Net.Http.HttpClient httpClient) if (user == null) throw new ArgumentNullException(nameof(user)); + await ValidateCreateUserRequestAsync(user, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user"; @@ -295,11 +305,18 @@ public UserApi(System.Net.Http.HttpClient httpClient) - request.Content = new System.Net.Http.StringContent(user.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = user; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -308,11 +325,19 @@ public UserApi(System.Net.Http.HttpClient httpClient) ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// List of user object + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithArrayInputRequestAsync(List user, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -327,6 +352,8 @@ public UserApi(System.Net.Http.HttpClient httpClient) if (user == null) throw new ArgumentNullException(nameof(user)); + await ValidateCreateUsersWithArrayInputRequestAsync(user, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/createWithArray"; @@ -345,11 +372,18 @@ public UserApi(System.Net.Http.HttpClient httpClient) - request.Content = new System.Net.Http.StringContent(user.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = user; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -358,11 +392,19 @@ public UserApi(System.Net.Http.HttpClient httpClient) ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// List of user object + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithListInputRequestAsync(List user, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -377,6 +419,8 @@ public UserApi(System.Net.Http.HttpClient httpClient) if (user == null) throw new ArgumentNullException(nameof(user)); + await ValidateCreateUsersWithListInputRequestAsync(user, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/createWithList"; @@ -395,11 +439,18 @@ public UserApi(System.Net.Http.HttpClient httpClient) - request.Content = new System.Net.Http.StringContent(user.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = user; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -408,11 +459,19 @@ public UserApi(System.Net.Http.HttpClient httpClient) ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// The name that needs to be deleted + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateDeleteUserRequestAsync(string username, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -427,6 +486,8 @@ public UserApi(System.Net.Http.HttpClient httpClient) if (username == null) throw new ArgumentNullException(nameof(username)); + await ValidateDeleteUserRequestAsync(username, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/{username}"; @@ -450,6 +511,12 @@ public UserApi(System.Net.Http.HttpClient httpClient) + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -458,11 +525,19 @@ public UserApi(System.Net.Http.HttpClient httpClient) ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// The name that needs to be fetched. Use user1 for testing. + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateGetUserByNameRequestAsync(string username, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Get user by user name /// @@ -473,7 +548,7 @@ public UserApi(System.Net.Http.HttpClient httpClient) public async System.Threading.Tasks.Task GetUserByNameAsync(string username, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await GetUserByNameWithHttpInfoAsync(username, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -488,7 +563,7 @@ public async System.Threading.Tasks.Task GetUserByNameAsync(string usernam Org.OpenAPITools.Client.ApiResponse result = await GetUserByNameWithHttpInfoAsync(username, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -504,6 +579,8 @@ public async System.Threading.Tasks.Task GetUserByNameAsync(string usernam if (username == null) throw new ArgumentNullException(nameof(username)); + await ValidateGetUserByNameRequestAsync(username, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/{username}"; @@ -527,6 +604,12 @@ public async System.Threading.Tasks.Task GetUserByNameAsync(string usernam + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -537,11 +620,20 @@ public async System.Threading.Tasks.Task GetUserByNameAsync(string usernam ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// The user name for login + /// The password for login in clear text + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateLoginUserRequestAsync(string username, string password, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// /// Logs user into the system /// @@ -553,7 +645,7 @@ public async System.Threading.Tasks.Task GetUserByNameAsync(string usernam public async System.Threading.Tasks.Task LoginUserAsync(string username, string password, System.Threading.CancellationToken? cancellationToken = null) { Org.OpenAPITools.Client.ApiResponse result = await LoginUserWithHttpInfoAsync(username, password, cancellationToken).ConfigureAwait(false); - return result.Data ?? throw new NullReferenceException(); + return result.Content ?? throw new NullReferenceException(); } /// @@ -569,7 +661,7 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, Org.OpenAPITools.Client.ApiResponse result = await LoginUserWithHttpInfoAsync(username, password, cancellationToken).ConfigureAwait(false); return result.IsSuccessStatusCode - ? result.Data + ? result.Content : null; } @@ -588,6 +680,8 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, if (password == null) throw new ArgumentNullException(nameof(password)); + await ValidateLoginUserRequestAsync(username, password, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/login"; @@ -613,6 +707,12 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); @@ -623,11 +723,18 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateLogoutUserRequestAsync(System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -639,6 +746,8 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, public async System.Threading.Tasks.Task> LogoutUserWithHttpInfoAsync(System.Threading.CancellationToken? cancellationToken = null) { + await ValidateLogoutUserRequestAsync(cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/logout"; @@ -660,6 +769,12 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, + string[] contentTypes = new string[] { + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -668,11 +783,20 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } + /// + /// Validate the input before sending the request + /// + /// name that need to be deleted + /// Updated user object + /// Cancellation Token to cancel the request. + protected virtual System.Threading.Tasks.ValueTask ValidateUpdateUserRequestAsync(string username, User user, System.Threading.CancellationToken? cancellationToken) + => new System.Threading.Tasks.ValueTask(); + /// @@ -690,6 +814,8 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, if (user == null) throw new ArgumentNullException(nameof(user)); + await ValidateUpdateUserRequestAsync(username, user, cancellationToken).ConfigureAwait(false); + using System.Net.Http.HttpRequestMessage request = new System.Net.Http.HttpRequestMessage(); string path = "/user/{username}"; @@ -710,11 +836,18 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, - request.Content = new System.Net.Http.StringContent(user.ToJson(), System.Text.Encoding.UTF8, "application/json"); + // todo localVarRequestOptions.Content = user; request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string[] contentTypes = new string[] { + "application/json" + }; + + if (request.Content != null && contentTypes.Length > 0) + request.Content.Headers.Add("CONTENT-TYPE", contentTypes); + using System.Net.Http.HttpResponseMessage responseMessage = await _httpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false); @@ -723,7 +856,7 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, ApiResponse apiResponse = new(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiException.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiException.cs index b804a84b7ea4..4a44193cd046 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiException.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiException.cs @@ -30,21 +30,21 @@ public class ApiException : Exception /// /// The raw data returned by the api /// - public string RawData { get; } + public string RawContent { get; } /// /// Construct the ApiException from parts of the reponse /// /// /// - /// - public ApiException(string? reasonPhrase, System.Net.HttpStatusCode statusCode, string rawData) : base(reasonPhrase ?? rawData) + /// + public ApiException(string? reasonPhrase, System.Net.HttpStatusCode statusCode, string rawContent) : base(reasonPhrase ?? rawContent) { ReasonPhrase = reasonPhrase; StatusCode = statusCode; - RawData = rawData; + RawContent = rawContent; } } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiResponse.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiResponse.cs index 865a0a77c8d3..ea3645fe4ca8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiResponse.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiResponse.cs @@ -39,7 +39,7 @@ public interface IApiResponse /// /// The raw content of this response /// - string RawData { get; } + string RawContent { get; } } /// @@ -50,9 +50,9 @@ public partial class ApiResponse : IApiResponse #region Properties /// - /// The deserialized data + /// The deserialized content /// - public T? Data { get; set; } + public T? Content { get; set; } /// /// Gets or sets the status code (HTTP status code) @@ -76,7 +76,7 @@ public Type ResponseType /// /// The raw data /// - public string RawData { get; } + public string RawContent { get; } /// /// The IsSuccessStatusCode from the api response @@ -99,14 +99,14 @@ public Type ResponseType /// Construct the reponse using an HttpResponseMessage /// /// - /// - public ApiResponse(System.Net.Http.HttpResponseMessage response, string rawData) + /// + public ApiResponse(System.Net.Http.HttpResponseMessage response, string rawContent) { StatusCode = response.StatusCode; Headers = response.Headers; IsSuccessStatusCode = response.IsSuccessStatusCode; ReasonPhrase = response.ReasonPhrase; - RawData = rawData; + RawContent = rawContent; } } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index 6b0d8561ef24..ec2fb4606642 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -158,6 +158,37 @@ public bool Equals(AdditionalPropertiesClass? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.MapProperty != null) + hashCode = hashCode * 59 + this.MapProperty.GetHashCode(); + if (this.MapOfMapProperty != null) + hashCode = hashCode * 59 + this.MapOfMapProperty.GetHashCode(); + if (this.Anytype1 != null) + hashCode = hashCode * 59 + this.Anytype1.GetHashCode(); + if (this.MapWithUndeclaredPropertiesAnytype1 != null) + hashCode = hashCode * 59 + this.MapWithUndeclaredPropertiesAnytype1.GetHashCode(); + if (this.MapWithUndeclaredPropertiesAnytype2 != null) + hashCode = hashCode * 59 + this.MapWithUndeclaredPropertiesAnytype2.GetHashCode(); + if (this.MapWithUndeclaredPropertiesAnytype3 != null) + hashCode = hashCode * 59 + this.MapWithUndeclaredPropertiesAnytype3.GetHashCode(); + if (this.EmptyMap != null) + hashCode = hashCode * 59 + this.EmptyMap.GetHashCode(); + if (this.MapWithUndeclaredPropertiesString != null) + hashCode = hashCode * 59 + this.MapWithUndeclaredPropertiesString.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Animal.cs index f1f0d480c74a..44325625b09b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Animal.cs @@ -119,6 +119,25 @@ public bool Equals(Animal? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ClassName != null) + hashCode = hashCode * 59 + this.ClassName.GetHashCode(); + if (this.Color != null) + hashCode = hashCode * 59 + this.Color.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ApiResponse.cs index 6db3dd805658..7862124b432b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -112,6 +112,26 @@ public bool Equals(ApiResponse? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.Code.GetHashCode(); + if (this.Type != null) + hashCode = hashCode * 59 + this.Type.GetHashCode(); + if (this.Message != null) + hashCode = hashCode * 59 + this.Message.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Apple.cs index d31a6896b523..ecec44f78db9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Apple.cs @@ -103,6 +103,25 @@ public bool Equals(Apple? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Cultivar != null) + hashCode = hashCode * 59 + this.Cultivar.GetHashCode(); + if (this.Origin != null) + hashCode = hashCode * 59 + this.Origin.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AppleReq.cs index 450159efe5f2..018d42100633 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AppleReq.cs @@ -102,6 +102,22 @@ public bool Equals(AppleReq? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Cultivar != null) + hashCode = hashCode * 59 + this.Cultivar.GetHashCode(); + hashCode = hashCode * 59 + this.Mealy.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index 7158c0fb9ea8..96669b6f2df3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -94,6 +94,23 @@ public bool Equals(ArrayOfArrayOfNumberOnly? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ArrayArrayNumber != null) + hashCode = hashCode * 59 + this.ArrayArrayNumber.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index 954241248cd7..ca077be2fd00 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -94,6 +94,23 @@ public bool Equals(ArrayOfNumberOnly? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ArrayNumber != null) + hashCode = hashCode * 59 + this.ArrayNumber.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayTest.cs index a8aaae06b3dd..589b38db3ea6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -112,6 +112,27 @@ public bool Equals(ArrayTest? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ArrayOfString != null) + hashCode = hashCode * 59 + this.ArrayOfString.GetHashCode(); + if (this.ArrayArrayOfInteger != null) + hashCode = hashCode * 59 + this.ArrayArrayOfInteger.GetHashCode(); + if (this.ArrayArrayOfModel != null) + hashCode = hashCode * 59 + this.ArrayArrayOfModel.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Banana.cs index 659de37a23cd..e42f4522500a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Banana.cs @@ -94,6 +94,22 @@ public bool Equals(Banana? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.LengthCm.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BananaReq.cs index 15fa5f0861f2..2a2bcb13c1a6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BananaReq.cs @@ -101,6 +101,21 @@ public bool Equals(BananaReq? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.LengthCm.GetHashCode(); + hashCode = hashCode * 59 + this.Sweet.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BasquePig.cs index 0abea7b796fe..4007742f83ab 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BasquePig.cs @@ -105,6 +105,23 @@ public bool Equals(BasquePig? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ClassName != null) + hashCode = hashCode * 59 + this.ClassName.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Capitalization.cs index 0151b64a90a4..f6dee4c7f111 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Capitalization.cs @@ -140,6 +140,33 @@ public bool Equals(Capitalization? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.SmallCamel != null) + hashCode = hashCode * 59 + this.SmallCamel.GetHashCode(); + if (this.CapitalCamel != null) + hashCode = hashCode * 59 + this.CapitalCamel.GetHashCode(); + if (this.SmallSnake != null) + hashCode = hashCode * 59 + this.SmallSnake.GetHashCode(); + if (this.CapitalSnake != null) + hashCode = hashCode * 59 + this.CapitalSnake.GetHashCode(); + if (this.SCAETHFlowPoints != null) + hashCode = hashCode * 59 + this.SCAETHFlowPoints.GetHashCode(); + if (this.ATT_NAME != null) + hashCode = hashCode * 59 + this.ATT_NAME.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Cat.cs index a515ed0423d7..4d0eafcf00d3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Cat.cs @@ -108,6 +108,22 @@ public bool Equals(Cat? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + hashCode = hashCode * 59 + this.Declawed.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/CatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/CatAllOf.cs index 4fcfa372ce05..a3bdea1c2ca0 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/CatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/CatAllOf.cs @@ -94,6 +94,22 @@ public bool Equals(CatAllOf? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.Declawed.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Category.cs index 4dbf9b46f2a7..bf227cfd9697 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Category.cs @@ -114,6 +114,24 @@ public bool Equals(Category? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.Id.GetHashCode(); + if (this.Name != null) + hashCode = hashCode * 59 + this.Name.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs index c2f313b71dfd..e9f157abc28d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs @@ -130,6 +130,24 @@ public bool Equals(ChildCat? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + if (this.Name != null) + hashCode = hashCode * 59 + this.Name.GetHashCode(); + hashCode = hashCode * 59 + this.PetType.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs index 84dd1d83b5de..2e8ef815b8cf 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs @@ -117,6 +117,24 @@ public bool Equals(ChildCatAllOf? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Name != null) + hashCode = hashCode * 59 + this.Name.GetHashCode(); + hashCode = hashCode * 59 + this.PetType.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ClassModel.cs index 27a976b9f85d..28e0d851aa74 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ClassModel.cs @@ -94,6 +94,23 @@ public bool Equals(ClassModel? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Class != null) + hashCode = hashCode * 59 + this.Class.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index cf08aa6da742..c7f39e5c49b5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -116,6 +116,25 @@ public bool Equals(ComplexQuadrilateral? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ShapeType != null) + hashCode = hashCode * 59 + this.ShapeType.GetHashCode(); + if (this.QuadrilateralType != null) + hashCode = hashCode * 59 + this.QuadrilateralType.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DanishPig.cs index db3304315360..5f124294caa9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DanishPig.cs @@ -105,6 +105,23 @@ public bool Equals(DanishPig? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ClassName != null) + hashCode = hashCode * 59 + this.ClassName.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Dog.cs index 524fb65920ca..c14d555066cf 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Dog.cs @@ -108,6 +108,23 @@ public bool Equals(Dog? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + if (this.Breed != null) + hashCode = hashCode * 59 + this.Breed.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DogAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DogAllOf.cs index 07a08559f4e8..6c2f57709cc4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DogAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DogAllOf.cs @@ -94,6 +94,23 @@ public bool Equals(DogAllOf? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Breed != null) + hashCode = hashCode * 59 + this.Breed.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs index 32e37eaeb8fa..ff23371e230d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs @@ -114,6 +114,27 @@ public bool Equals(Drawing? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + if (this.MainShape != null) + hashCode = hashCode * 59 + this.MainShape.GetHashCode(); + if (this.ShapeOrNull != null) + hashCode = hashCode * 59 + this.ShapeOrNull.GetHashCode(); + if (this.NullableShape != null) + hashCode = hashCode * 59 + this.NullableShape.GetHashCode(); + if (this.Shapes != null) + hashCode = hashCode * 59 + this.Shapes.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs index ad8a2c787f48..fb6e61bc833e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -144,6 +144,23 @@ public bool Equals(EnumArrays? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.JustSymbol.GetHashCode(); + hashCode = hashCode * 59 + this.ArrayEnum.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs index 9f9248a9b220..76d41388f9a9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs @@ -256,6 +256,29 @@ public bool Equals(EnumTest? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.EnumString.GetHashCode(); + hashCode = hashCode * 59 + this.EnumStringRequired.GetHashCode(); + hashCode = hashCode * 59 + this.EnumInteger.GetHashCode(); + hashCode = hashCode * 59 + this.EnumNumber.GetHashCode(); + hashCode = hashCode * 59 + this.OuterEnum.GetHashCode(); + hashCode = hashCode * 59 + this.OuterEnumInteger.GetHashCode(); + hashCode = hashCode * 59 + this.OuterEnumDefaultValue.GetHashCode(); + hashCode = hashCode * 59 + this.OuterEnumIntegerDefaultValue.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index bc53813e9b4c..f38a802284b4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -116,6 +116,25 @@ public bool Equals(EquilateralTriangle? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ShapeType != null) + hashCode = hashCode * 59 + this.ShapeType.GetHashCode(); + if (this.TriangleType != null) + hashCode = hashCode * 59 + this.TriangleType.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/File.cs index 544530620237..608945fa77d4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/File.cs @@ -95,6 +95,23 @@ public bool Equals(File? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.SourceURI != null) + hashCode = hashCode * 59 + this.SourceURI.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index e9bb2ac40231..23e9027ea040 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -103,6 +103,25 @@ public bool Equals(FileSchemaTestClass? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.File != null) + hashCode = hashCode * 59 + this.File.GetHashCode(); + if (this.Files != null) + hashCode = hashCode * 59 + this.Files.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Foo.cs index eb2a8133a628..b4535593db98 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Foo.cs @@ -95,6 +95,23 @@ public bool Equals(Foo? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Bar != null) + hashCode = hashCode * 59 + this.Bar.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FormatTest.cs index 57abeb11ed28..e3f491a3a055 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FormatTest.cs @@ -247,6 +247,46 @@ public bool Equals(FormatTest? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.Integer.GetHashCode(); + hashCode = hashCode * 59 + this.Int32.GetHashCode(); + hashCode = hashCode * 59 + this.Int64.GetHashCode(); + hashCode = hashCode * 59 + this.Number.GetHashCode(); + hashCode = hashCode * 59 + this.Float.GetHashCode(); + hashCode = hashCode * 59 + this.Double.GetHashCode(); + hashCode = hashCode * 59 + this.Decimal.GetHashCode(); + if (this.String != null) + hashCode = hashCode * 59 + this.String.GetHashCode(); + if (this.Byte != null) + hashCode = hashCode * 59 + this.Byte.GetHashCode(); + if (this.Binary != null) + hashCode = hashCode * 59 + this.Binary.GetHashCode(); + if (this.Date != null) + hashCode = hashCode * 59 + this.Date.GetHashCode(); + if (this.DateTime != null) + hashCode = hashCode * 59 + this.DateTime.GetHashCode(); + if (this.Uuid != null) + hashCode = hashCode * 59 + this.Uuid.GetHashCode(); + if (this.Password != null) + hashCode = hashCode * 59 + this.Password.GetHashCode(); + if (this.PatternWithDigits != null) + hashCode = hashCode * 59 + this.PatternWithDigits.GetHashCode(); + if (this.PatternWithDigitsAndDelimiter != null) + hashCode = hashCode * 59 + this.PatternWithDigitsAndDelimiter.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index ba8878068efe..a23780d39479 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -109,6 +109,23 @@ public bool Equals(GrandparentAnimal? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.PetType != null) + hashCode = hashCode * 59 + this.PetType.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index e72e090775e3..91e824dd9218 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -118,6 +118,25 @@ public bool Equals(HasOnlyReadOnly? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Bar != null) + hashCode = hashCode * 59 + this.Bar.GetHashCode(); + if (this.Foo != null) + hashCode = hashCode * 59 + this.Foo.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HealthCheckResult.cs index 35c7bbd12da4..af7e7bf1bb6c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -94,6 +94,23 @@ public bool Equals(HealthCheckResult? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.NullableMessage != null) + hashCode = hashCode * 59 + this.NullableMessage.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/InlineResponseDefault.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/InlineResponseDefault.cs index 3517725b1edc..431988c45624 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/InlineResponseDefault.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/InlineResponseDefault.cs @@ -94,6 +94,23 @@ public bool Equals(InlineResponseDefault? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.String != null) + hashCode = hashCode * 59 + this.String.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index d93709692b9e..23bb2fad4c4a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -104,6 +104,23 @@ public bool Equals(IsoscelesTriangle? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ShapeType != null) + hashCode = hashCode * 59 + this.ShapeType.GetHashCode(); + if (this.TriangleType != null) + hashCode = hashCode * 59 + this.TriangleType.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/List.cs index 555797a2747d..5d913b5711e1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/List.cs @@ -94,6 +94,23 @@ public bool Equals(List? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this._123List != null) + hashCode = hashCode * 59 + this._123List.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs index 4730b465418c..cd23fdec0976 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs @@ -142,6 +142,28 @@ public bool Equals(MapTest? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.MapMapOfString != null) + hashCode = hashCode * 59 + this.MapMapOfString.GetHashCode(); + hashCode = hashCode * 59 + this.MapOfEnumString.GetHashCode(); + if (this.DirectMap != null) + hashCode = hashCode * 59 + this.DirectMap.GetHashCode(); + if (this.IndirectMap != null) + hashCode = hashCode * 59 + this.IndirectMap.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 2300639e2580..56945b09cf94 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -112,6 +112,27 @@ public bool Equals(MixedPropertiesAndAdditionalPropertiesClass? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Uuid != null) + hashCode = hashCode * 59 + this.Uuid.GetHashCode(); + if (this.DateTime != null) + hashCode = hashCode * 59 + this.DateTime.GetHashCode(); + if (this.Map != null) + hashCode = hashCode * 59 + this.Map.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Model200Response.cs index 7d739192998f..728f392bf833 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Model200Response.cs @@ -103,6 +103,24 @@ public bool Equals(Model200Response? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.Name.GetHashCode(); + if (this.Class != null) + hashCode = hashCode * 59 + this.Class.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ModelClient.cs index bf54a452415d..7ab780a3db1f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ModelClient.cs @@ -94,6 +94,23 @@ public bool Equals(ModelClient? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.__Client != null) + hashCode = hashCode * 59 + this.__Client.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Name.cs index d50019f78f7b..e4866d8ca928 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Name.cs @@ -145,6 +145,26 @@ public bool Equals(Name? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this._Name.GetHashCode(); + hashCode = hashCode * 59 + this.SnakeCase.GetHashCode(); + if (this.Property != null) + hashCode = hashCode * 59 + this.Property.GetHashCode(); + hashCode = hashCode * 59 + this._123Number.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs index 76d2cefbc045..bbfdf373d65d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs @@ -187,6 +187,43 @@ public bool Equals(NullableClass? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + if (this.IntegerProp != null) + hashCode = hashCode * 59 + this.IntegerProp.GetHashCode(); + if (this.NumberProp != null) + hashCode = hashCode * 59 + this.NumberProp.GetHashCode(); + if (this.BooleanProp != null) + hashCode = hashCode * 59 + this.BooleanProp.GetHashCode(); + if (this.StringProp != null) + hashCode = hashCode * 59 + this.StringProp.GetHashCode(); + if (this.DateProp != null) + hashCode = hashCode * 59 + this.DateProp.GetHashCode(); + if (this.DatetimeProp != null) + hashCode = hashCode * 59 + this.DatetimeProp.GetHashCode(); + if (this.ArrayNullableProp != null) + hashCode = hashCode * 59 + this.ArrayNullableProp.GetHashCode(); + if (this.ArrayAndItemsNullableProp != null) + hashCode = hashCode * 59 + this.ArrayAndItemsNullableProp.GetHashCode(); + if (this.ArrayItemsNullable != null) + hashCode = hashCode * 59 + this.ArrayItemsNullable.GetHashCode(); + if (this.ObjectNullableProp != null) + hashCode = hashCode * 59 + this.ObjectNullableProp.GetHashCode(); + if (this.ObjectAndItemsNullableProp != null) + hashCode = hashCode * 59 + this.ObjectAndItemsNullableProp.GetHashCode(); + if (this.ObjectItemsNullable != null) + hashCode = hashCode * 59 + this.ObjectItemsNullable.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NumberOnly.cs index 0318fbd87957..b873c592922e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -94,6 +94,22 @@ public bool Equals(NumberOnly? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.JustNumber.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs index 6c05036c3c03..d3668abbc43c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs @@ -167,6 +167,28 @@ public bool Equals(Order? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.Id.GetHashCode(); + hashCode = hashCode * 59 + this.PetId.GetHashCode(); + hashCode = hashCode * 59 + this.Quantity.GetHashCode(); + if (this.ShipDate != null) + hashCode = hashCode * 59 + this.ShipDate.GetHashCode(); + hashCode = hashCode * 59 + this.Status.GetHashCode(); + hashCode = hashCode * 59 + this.Complete.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterComposite.cs index 95ca33ecddb1..59a84201d67f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -112,6 +112,25 @@ public bool Equals(OuterComposite? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.MyNumber.GetHashCode(); + if (this.MyString != null) + hashCode = hashCode * 59 + this.MyString.GetHashCode(); + hashCode = hashCode * 59 + this.MyBoolean.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ParentPet.cs index 732f3faca2f2..d6c298498466 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ParentPet.cs @@ -99,6 +99,21 @@ public bool Equals(ParentPet? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs index e98c4c34f17d..9c60f7dd5ea0 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs @@ -180,6 +180,31 @@ public bool Equals(Pet? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.Id.GetHashCode(); + if (this.Category != null) + hashCode = hashCode * 59 + this.Category.GetHashCode(); + if (this.Name != null) + hashCode = hashCode * 59 + this.Name.GetHashCode(); + if (this.PhotoUrls != null) + hashCode = hashCode * 59 + this.PhotoUrls.GetHashCode(); + if (this.Tags != null) + hashCode = hashCode * 59 + this.Tags.GetHashCode(); + hashCode = hashCode * 59 + this.Status.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index f2f9c3cd3ec4..21ece5ddb767 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -105,6 +105,23 @@ public bool Equals(QuadrilateralInterface? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.QuadrilateralType != null) + hashCode = hashCode * 59 + this.QuadrilateralType.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index 7d091650a0c8..22ad0fb2a9e4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -110,6 +110,25 @@ public bool Equals(ReadOnlyFirst? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Bar != null) + hashCode = hashCode * 59 + this.Bar.GetHashCode(); + if (this.Baz != null) + hashCode = hashCode * 59 + this.Baz.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Return.cs index 6761ae446861..fd56cc052c77 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Return.cs @@ -94,6 +94,22 @@ public bool Equals(Return? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this._Return.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index 6a6b5cc22ba1..ad295d97343a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -116,6 +116,25 @@ public bool Equals(ScaleneTriangle? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ShapeType != null) + hashCode = hashCode * 59 + this.ShapeType.GetHashCode(); + if (this.TriangleType != null) + hashCode = hashCode * 59 + this.TriangleType.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeInterface.cs index 6fb5a6cfd587..eca229af761d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -105,6 +105,23 @@ public bool Equals(ShapeInterface? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ShapeType != null) + hashCode = hashCode * 59 + this.ShapeType.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index df65c3f42a79..cc6cf0fe35e8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -116,6 +116,25 @@ public bool Equals(SimpleQuadrilateral? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ShapeType != null) + hashCode = hashCode * 59 + this.ShapeType.GetHashCode(); + if (this.QuadrilateralType != null) + hashCode = hashCode * 59 + this.QuadrilateralType.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SpecialModelName.cs index b58a5a1b2261..a34e9382470b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -94,6 +94,22 @@ public bool Equals(SpecialModelName? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.SpecialPropertyName.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Tag.cs index c37c15bbb877..15f46fa62d45 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Tag.cs @@ -103,6 +103,24 @@ public bool Equals(Tag? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.Id.GetHashCode(); + if (this.Name != null) + hashCode = hashCode * 59 + this.Name.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/TriangleInterface.cs index a63bba46a983..055dec6a9cf5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -105,6 +105,23 @@ public bool Equals(TriangleInterface? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.TriangleType != null) + hashCode = hashCode * 59 + this.TriangleType.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/User.cs index acc36e28c7ca..bc7ffaaa63fb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/User.cs @@ -198,6 +198,43 @@ public bool Equals(User? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.Id.GetHashCode(); + if (this.Username != null) + hashCode = hashCode * 59 + this.Username.GetHashCode(); + if (this.FirstName != null) + hashCode = hashCode * 59 + this.FirstName.GetHashCode(); + if (this.LastName != null) + hashCode = hashCode * 59 + this.LastName.GetHashCode(); + if (this.Email != null) + hashCode = hashCode * 59 + this.Email.GetHashCode(); + if (this.Password != null) + hashCode = hashCode * 59 + this.Password.GetHashCode(); + if (this.Phone != null) + hashCode = hashCode * 59 + this.Phone.GetHashCode(); + hashCode = hashCode * 59 + this.UserStatus.GetHashCode(); + if (this.ObjectWithNoDeclaredProps != null) + hashCode = hashCode * 59 + this.ObjectWithNoDeclaredProps.GetHashCode(); + if (this.ObjectWithNoDeclaredPropsNullable != null) + hashCode = hashCode * 59 + this.ObjectWithNoDeclaredPropsNullable.GetHashCode(); + if (this.AnyTypeProp != null) + hashCode = hashCode * 59 + this.AnyTypeProp.GetHashCode(); + if (this.AnyTypePropNullable != null) + hashCode = hashCode * 59 + this.AnyTypePropNullable.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Whale.cs index 710cf59ce73e..0778d715e6fe 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Whale.cs @@ -123,6 +123,25 @@ public bool Equals(Whale? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = hashCode * 59 + this.HasBaleen.GetHashCode(); + hashCode = hashCode * 59 + this.HasTeeth.GetHashCode(); + if (this.ClassName != null) + hashCode = hashCode * 59 + this.ClassName.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs index 5ad638bcee37..9a6bb5832dda 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs @@ -141,6 +141,24 @@ public bool Equals(Zebra? input) return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + hashCode = hashCode * 59 + this.Type.GetHashCode(); + if (this.ClassName != null) + hashCode = hashCode * 59 + this.ClassName.GetHashCode(); + if (this.AdditionalProperties != null) + hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// From be57439416a03b90f7c10ec94a24243c1918f9d0 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 27 Feb 2021 12:58:17 -0500 Subject: [PATCH 16/20] removed new csharp feature --- .../resources/csharp-netcore/libraries/httpclient/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache index 89f88d695c1b..6f930608e127 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache @@ -312,7 +312,7 @@ namespace {{packageName}}.{{apiPackage}} string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> apiResponse = new(responseMessage, responseContent); + ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> apiResponse = new ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); From 0f94cac65de17bc5fe432cc335c962c4ebfe87f6 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 27 Feb 2021 14:54:10 -0500 Subject: [PATCH 17/20] added .net standard fallback --- .../libraries/httpclient/ApiResponse.mustache | 4 +- .../httpclient/AssemblyInfo.mustache | 37 ++++++++++++++ .../libraries/httpclient/README.mustache | 36 ------------- .../httpclient/modelGeneric.mustache | 2 +- .../httpclient/netcore_project.mustache | 7 ++- .../libraries/httpclient/nuspec.mustache | 51 +++++++++++++++++++ 6 files changed, 94 insertions(+), 43 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/AssemblyInfo.mustache create mode 100644 modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/nuspec.mustache diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache index 5d6259381501..31421aac9f3b 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiResponse.mustache @@ -44,7 +44,7 @@ namespace {{packageName}}.Client /// /// The deserialized content /// - public T? Content { get; set; } + public T??? Content { get; set; } /// /// Gets or sets the status code (HTTP status code) @@ -78,7 +78,7 @@ namespace {{packageName}}.Client /// /// The reason phrase contained in the api response /// - public string? ReasonPhrase { get; } + public string??? ReasonPhrase { get; } /// /// The headers contained in the api response diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/AssemblyInfo.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/AssemblyInfo.mustache new file mode 100644 index 000000000000..c5d19bfd2357 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/AssemblyInfo.mustache @@ -0,0 +1,37 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("{{packageTitle}}")] +[assembly: AssemblyDescription("{{packageDescription}}")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("{{packageCompany}}")] +[assembly: AssemblyProduct("{{packageProductName}}")] +[assembly: AssemblyCopyright("{{packageCopyright}}")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("{{packageVersion}}")] +[assembly: AssemblyFileVersion("{{packageVersion}}")] +{{^supportsAsync}} +[assembly: InternalsVisibleTo("NewtonSoft.Json")] +[assembly: InternalsVisibleTo("JsonSubTypes")] +{{/supportsAsync}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache index 8b2155858847..c3f501bb2423 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache @@ -1,35 +1,3 @@ -This library requires some post processing. - -``` -cmd /c start /wait java -jar openapi-generator-cli.jar generate ` - -g csharp-netcore ` - -i swagger.yml ` - -o output ` - --library httpclient | Out-Null - # optional parameters you probably want - # -t templates - # -c generator-config.json - # other csharp properties: https://openapi-generator.tech/docs/generators/csharp-netcore - # other global properties: https://openapi-generator.tech/docs/globals - -$files = Get-ChildItem output -Recurse -foreach ($file in $files) -{ - if ($file.PSIsContainer){ - continue - } - - $content=Get-Content $file.PSPath -raw - - if (-Not($content)){ - continue; - } - - $content=$content -replace '\?{3,4}', '?' # replace every three to four consecutive occurrences of '?' with a single one - Set-Content $file.PSPath $content -} -``` - # {{packageName}} - the C# library for the {{appName}} {{#appDescriptionWithNewLines}} @@ -59,7 +27,6 @@ This C# SDK is automatically generated by the [OpenAPI Generator](https://openap ## Dependencies -- [RestSharp](https://www.nuget.org/packages/RestSharp) - 106.11.4 or later - [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 12.0.3 or later - [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/) - 1.7.0 or later {{#useCompareNetObjects}} @@ -71,7 +38,6 @@ This C# SDK is automatically generated by the [OpenAPI Generator](https://openap The DLLs included in the package may not be the latest version. We recommend using [NuGet](https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages: ``` -Install-Package RestSharp Install-Package Newtonsoft.Json Install-Package JsonSubTypes {{#validatable}} @@ -82,8 +48,6 @@ Install-Package CompareNETObjects {{/useCompareNetObjects}} ``` -NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742) - ## Installation {{#netStandard}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache index d941d2e10d7e..1827f9f61e3a 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache @@ -186,7 +186,7 @@ /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { {{#useCompareNetObjects}} return OpenAPIClientUtils.compareLogic.Compare(this, input as {{classname}}).AreEqual; diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/netcore_project.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/netcore_project.mustache index 518562446cbd..b7684dd9af61 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/netcore_project.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/netcore_project.mustache @@ -1,9 +1,8 @@ - - - net5.0 + false + {{targetFramework}} {{packageName}} {{packageName}} Library @@ -31,7 +30,7 @@ {{#validatable}} - + {{/validatable}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/nuspec.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/nuspec.mustache new file mode 100644 index 000000000000..4b9b30a5fe25 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/nuspec.mustache @@ -0,0 +1,51 @@ + + + + + $id$ + {{packageTitle}} + + + $version$ + + + $author$ + + + $author$ + false + false + + + {{packageDescription}} + {{#termsOfService}} + {{termsOfService}} + {{/termsOfService}} + {{#licenseUrl}} + {{licenseUrl}} + {{/licenseUrl}} + + + + + + {{#useCompareNetObjects}} + + {{/useCompareNetObjects}} + + {{#validatable}} + + {{/validatable}} + + + + + + + + + + + From 8d1d639a1a2d68c998300ff97c0a48def4c0766a Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 27 Feb 2021 15:03:20 -0500 Subject: [PATCH 18/20] build samples --- .../OpenAPIClient-httpclient/README.md | 36 ------------------- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 2 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 2 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 30 ++++++++-------- .../Api/FakeClassnameTags123Api.cs | 2 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 18 +++++----- .../src/Org.OpenAPITools/Api/StoreApi.cs | 8 ++--- .../src/Org.OpenAPITools/Api/UserApi.cs | 16 ++++----- .../Org.OpenAPITools/Client/ApiResponse.cs | 4 +-- .../Model/AdditionalPropertiesClass.cs | 2 +- .../src/Org.OpenAPITools/Model/Animal.cs | 2 +- .../src/Org.OpenAPITools/Model/ApiResponse.cs | 2 +- .../src/Org.OpenAPITools/Model/Apple.cs | 2 +- .../src/Org.OpenAPITools/Model/AppleReq.cs | 2 +- .../Model/ArrayOfArrayOfNumberOnly.cs | 2 +- .../Model/ArrayOfNumberOnly.cs | 2 +- .../src/Org.OpenAPITools/Model/ArrayTest.cs | 2 +- .../src/Org.OpenAPITools/Model/Banana.cs | 2 +- .../src/Org.OpenAPITools/Model/BananaReq.cs | 2 +- .../src/Org.OpenAPITools/Model/BasquePig.cs | 2 +- .../Org.OpenAPITools/Model/Capitalization.cs | 2 +- .../src/Org.OpenAPITools/Model/Cat.cs | 2 +- .../src/Org.OpenAPITools/Model/CatAllOf.cs | 2 +- .../src/Org.OpenAPITools/Model/Category.cs | 2 +- .../src/Org.OpenAPITools/Model/ChildCat.cs | 2 +- .../Org.OpenAPITools/Model/ChildCatAllOf.cs | 2 +- .../src/Org.OpenAPITools/Model/ClassModel.cs | 2 +- .../Model/ComplexQuadrilateral.cs | 2 +- .../src/Org.OpenAPITools/Model/DanishPig.cs | 2 +- .../src/Org.OpenAPITools/Model/Dog.cs | 2 +- .../src/Org.OpenAPITools/Model/DogAllOf.cs | 2 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../src/Org.OpenAPITools/Model/EnumArrays.cs | 2 +- .../src/Org.OpenAPITools/Model/EnumTest.cs | 2 +- .../Model/EquilateralTriangle.cs | 2 +- .../src/Org.OpenAPITools/Model/File.cs | 2 +- .../Model/FileSchemaTestClass.cs | 2 +- .../src/Org.OpenAPITools/Model/Foo.cs | 2 +- .../src/Org.OpenAPITools/Model/FormatTest.cs | 2 +- .../Model/GrandparentAnimal.cs | 2 +- .../Org.OpenAPITools/Model/HasOnlyReadOnly.cs | 2 +- .../Model/HealthCheckResult.cs | 2 +- .../Model/InlineResponseDefault.cs | 2 +- .../Model/IsoscelesTriangle.cs | 2 +- .../src/Org.OpenAPITools/Model/List.cs | 2 +- .../src/Org.OpenAPITools/Model/MapTest.cs | 2 +- ...dPropertiesAndAdditionalPropertiesClass.cs | 2 +- .../Model/Model200Response.cs | 2 +- .../src/Org.OpenAPITools/Model/ModelClient.cs | 2 +- .../src/Org.OpenAPITools/Model/Name.cs | 2 +- .../Org.OpenAPITools/Model/NullableClass.cs | 2 +- .../src/Org.OpenAPITools/Model/NumberOnly.cs | 2 +- .../src/Org.OpenAPITools/Model/Order.cs | 2 +- .../Org.OpenAPITools/Model/OuterComposite.cs | 2 +- .../src/Org.OpenAPITools/Model/ParentPet.cs | 2 +- .../src/Org.OpenAPITools/Model/Pet.cs | 2 +- .../Model/QuadrilateralInterface.cs | 2 +- .../Org.OpenAPITools/Model/ReadOnlyFirst.cs | 2 +- .../src/Org.OpenAPITools/Model/Return.cs | 2 +- .../Org.OpenAPITools/Model/ScaleneTriangle.cs | 2 +- .../Org.OpenAPITools/Model/ShapeInterface.cs | 2 +- .../Model/SimpleQuadrilateral.cs | 2 +- .../Model/SpecialModelName.cs | 2 +- .../src/Org.OpenAPITools/Model/Tag.cs | 2 +- .../Model/TriangleInterface.cs | 2 +- .../src/Org.OpenAPITools/Model/User.cs | 2 +- .../src/Org.OpenAPITools/Model/Whale.cs | 2 +- .../src/Org.OpenAPITools/Model/Zebra.cs | 2 +- .../Org.OpenAPITools/Org.OpenAPITools.csproj | 7 ++-- 69 files changed, 103 insertions(+), 140 deletions(-) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md index 4fade86ef479..80080ff900af 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md @@ -1,35 +1,3 @@ -This library requires some post processing. - -``` -cmd /c start /wait java -jar openapi-generator-cli.jar generate ` - -g csharp-netcore ` - -i swagger.yml ` - -o output ` - --library httpclient | Out-Null - # optional parameters you probably want - # -t templates - # -c generator-config.json - # other csharp properties: https://openapi-generator.tech/docs/generators/csharp-netcore - # other global properties: https://openapi-generator.tech/docs/globals - -$files = Get-ChildItem output -Recurse -foreach ($file in $files) -{ - if ($file.PSIsContainer){ - continue - } - - $content=Get-Content $file.PSPath -raw - - if (-Not($content)){ - continue; - } - - $content=$content -replace '\?{3,4}', '?' # replace every three to four consecutive occurrences of '?' with a single one - Set-Content $file.PSPath $content -} -``` - # Org.OpenAPITools - the C# library for the OpenAPI Petstore This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ @@ -49,7 +17,6 @@ This C# SDK is automatically generated by the [OpenAPI Generator](https://openap ## Dependencies -- [RestSharp](https://www.nuget.org/packages/RestSharp) - 106.11.4 or later - [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 12.0.3 or later - [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/) - 1.7.0 or later - [CompareNETObjects](https://www.nuget.org/packages/CompareNETObjects) - 4.61.0 or later @@ -57,15 +24,12 @@ This C# SDK is automatically generated by the [OpenAPI Generator](https://openap The DLLs included in the package may not be the latest version. We recommend using [NuGet](https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages: ``` -Install-Package RestSharp Install-Package Newtonsoft.Json Install-Package JsonSubTypes Install-Package System.ComponentModel.Annotations Install-Package CompareNETObjects ``` -NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742) - ## Installation Generate the DLL using your preferred tool (e.g. `dotnet build`) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index e7d3fa99b39f..c62cf571bf8e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -169,7 +169,7 @@ public async System.Threading.Tasks.Task Call123TestSpecialTagsAsyn string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs index eb42e5d528c8..3a461daa69ac 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -157,7 +157,7 @@ public async System.Threading.Tasks.Task FooGetAsync(Syst string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs index eea3c1c4294f..c60603d01acf 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs @@ -612,7 +612,7 @@ public async System.Threading.Tasks.Task FakeHealthGetAsync(S string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -705,7 +705,7 @@ public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bo string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -798,7 +798,7 @@ public async System.Threading.Tasks.Task FakeOuterCompositeSeria string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -891,7 +891,7 @@ public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync( string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -984,7 +984,7 @@ public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(s string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -1070,7 +1070,7 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse> apiResponse = new(responseMessage, responseContent); + ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -1137,7 +1137,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithFileSchem string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -1210,7 +1210,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithQueryPara string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -1305,7 +1305,7 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -1447,7 +1447,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestEndpointParameter string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -1549,7 +1549,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestEnumParametersReq string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -1639,7 +1639,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestGroupParametersRe string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -1706,7 +1706,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestInlineAdditionalP string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -1778,7 +1778,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestJsonFormDataReque string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -1868,7 +1868,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestQueryParameterCol string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index a245d7c6ab11..5d216ada5846 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -172,7 +172,7 @@ public async System.Threading.Tasks.Task TestClassnameAsync(ModelCl string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs index 81921fd798c0..6f2c3ac5bddb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs @@ -416,7 +416,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateAddPetRequestAsync(Pe string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -488,7 +488,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeletePetRequestAsync string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -606,7 +606,7 @@ public async System.Threading.Tasks.Task> FindPetsByStatusAsync(List> apiResponse = new(responseMessage, responseContent); + ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -724,7 +724,7 @@ public async System.Threading.Tasks.Task> FindPetsByTagsAsync(List> apiResponse = new(responseMessage, responseContent); + ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -825,7 +825,7 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -917,7 +917,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetRequestAsync string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -999,7 +999,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetWithFormRequ string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -1113,7 +1113,7 @@ public async System.Threading.Tasks.Task UploadFileAsync(long petId string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -1226,7 +1226,7 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs index d357d07c6497..600395f5b108 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs @@ -229,7 +229,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeleteOrderRequestAsy string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -323,7 +323,7 @@ public async System.Threading.Tasks.Task> GetInventoryAs string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse> apiResponse = new(responseMessage, responseContent); + ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -416,7 +416,7 @@ public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -512,7 +512,7 @@ public async System.Threading.Tasks.Task PlaceOrderAsync(Order order, Sys string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs index 030f219ba48f..e44144d49e2d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs @@ -322,7 +322,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUserRequestAsyn string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -389,7 +389,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithArrayI string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -456,7 +456,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithListIn string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -522,7 +522,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeleteUserRequestAsyn string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -617,7 +617,7 @@ public async System.Threading.Tasks.Task GetUserByNameAsync(string usernam string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -720,7 +720,7 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -780,7 +780,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateLogoutUserRequestAsyn string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); @@ -853,7 +853,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdateUserRequestAsyn string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponse = new(responseMessage, responseContent); + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiResponse.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiResponse.cs index ea3645fe4ca8..a4f46cd204be 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiResponse.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiResponse.cs @@ -52,7 +52,7 @@ public partial class ApiResponse : IApiResponse /// /// The deserialized content /// - public T? Content { get; set; } + public T??? Content { get; set; } /// /// Gets or sets the status code (HTTP status code) @@ -86,7 +86,7 @@ public Type ResponseType /// /// The reason phrase contained in the api response /// - public string? ReasonPhrase { get; } + public string??? ReasonPhrase { get; } /// /// The headers contained in the api response diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index ec2fb4606642..1f3ffcfe3377 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -143,7 +143,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as AdditionalPropertiesClass).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Animal.cs index 44325625b09b..27315b09c419 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Animal.cs @@ -104,7 +104,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Animal).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ApiResponse.cs index 7862124b432b..cbccff5c47e1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -97,7 +97,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ApiResponse).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Apple.cs index ecec44f78db9..1ae420255734 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Apple.cs @@ -88,7 +88,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Apple).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AppleReq.cs index 018d42100633..0d18a148eaa7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/AppleReq.cs @@ -87,7 +87,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as AppleReq).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index 96669b6f2df3..dd3ebfb7e343 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ArrayOfArrayOfNumberOnly).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index ca077be2fd00..297ee6c14eca 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ArrayOfNumberOnly).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayTest.cs index 589b38db3ea6..9c22f08d15d7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -97,7 +97,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ArrayTest).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Banana.cs index e42f4522500a..ff4e3de7bcb7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Banana.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Banana).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BananaReq.cs index 2a2bcb13c1a6..c1cc13285c3a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BananaReq.cs @@ -86,7 +86,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as BananaReq).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BasquePig.cs index 4007742f83ab..66259ad4bb22 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/BasquePig.cs @@ -90,7 +90,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as BasquePig).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Capitalization.cs index f6dee4c7f111..6d20b732d026 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Capitalization.cs @@ -125,7 +125,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Capitalization).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Cat.cs index 4d0eafcf00d3..e60a6507ec8b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Cat.cs @@ -93,7 +93,7 @@ public override string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerial /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Cat).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/CatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/CatAllOf.cs index a3bdea1c2ca0..3dc55b472918 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/CatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/CatAllOf.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as CatAllOf).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Category.cs index bf227cfd9697..61fcf845854d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Category.cs @@ -99,7 +99,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Category).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs index e9f157abc28d..effd531402ca 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs @@ -115,7 +115,7 @@ public override string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerial /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ChildCat).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs index 2e8ef815b8cf..12eba360d3e3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs @@ -102,7 +102,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ChildCatAllOf).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ClassModel.cs index 28e0d851aa74..cba532bef754 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ClassModel.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ClassModel).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index c7f39e5c49b5..e064e5a0ff0e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -101,7 +101,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ComplexQuadrilateral).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DanishPig.cs index 5f124294caa9..6eff67a555ba 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DanishPig.cs @@ -90,7 +90,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as DanishPig).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Dog.cs index c14d555066cf..a3a9889e51bb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Dog.cs @@ -93,7 +93,7 @@ public override string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerial /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Dog).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DogAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DogAllOf.cs index 6c2f57709cc4..eb14c5d63774 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DogAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DogAllOf.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as DogAllOf).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs index ff23371e230d..50e4de4c197c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs @@ -99,7 +99,7 @@ public string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSetti /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Drawing).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs index fb6e61bc833e..7ad39af66ea8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -129,7 +129,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as EnumArrays).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs index 76d41388f9a9..ce68379d944b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs @@ -241,7 +241,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as EnumTest).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index f38a802284b4..c870b32f841f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -101,7 +101,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as EquilateralTriangle).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/File.cs index 608945fa77d4..9e67654e5691 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/File.cs @@ -80,7 +80,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as File).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index 23e9027ea040..2f67bda493ed 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -88,7 +88,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as FileSchemaTestClass).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Foo.cs index b4535593db98..9643e1ab97fc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Foo.cs @@ -80,7 +80,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Foo).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FormatTest.cs index e3f491a3a055..b224071573d6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FormatTest.cs @@ -232,7 +232,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as FormatTest).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index a23780d39479..4a85e09bd443 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -94,7 +94,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as GrandparentAnimal).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index 91e824dd9218..ff580ed1bc4c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -103,7 +103,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as HasOnlyReadOnly).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HealthCheckResult.cs index af7e7bf1bb6c..33abc7169e17 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as HealthCheckResult).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/InlineResponseDefault.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/InlineResponseDefault.cs index 431988c45624..21318273d8d2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/InlineResponseDefault.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/InlineResponseDefault.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as InlineResponseDefault).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index 23bb2fad4c4a..1314675aaf9d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -89,7 +89,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as IsoscelesTriangle).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/List.cs index 5d913b5711e1..becac7836312 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/List.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as List).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs index cd23fdec0976..b0947aafb55e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs @@ -127,7 +127,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as MapTest).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 56945b09cf94..fafa4537259a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -97,7 +97,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedPropertiesAndAdditionalPropertiesClass).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Model200Response.cs index 728f392bf833..ad85c9fc3689 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Model200Response.cs @@ -88,7 +88,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Model200Response).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ModelClient.cs index 7ab780a3db1f..164ccadec8d1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ModelClient.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ModelClient).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Name.cs index e4866d8ca928..d80698c27f44 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Name.cs @@ -130,7 +130,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Name).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs index bbfdf373d65d..09516927bedf 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs @@ -172,7 +172,7 @@ public string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSetti /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as NullableClass).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NumberOnly.cs index b873c592922e..8ab72763a878 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as NumberOnly).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs index d3668abbc43c..1715233b838a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs @@ -152,7 +152,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Order).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterComposite.cs index 59a84201d67f..81e957f7f390 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -97,7 +97,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as OuterComposite).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ParentPet.cs index d6c298498466..1ebd85f1d127 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ParentPet.cs @@ -84,7 +84,7 @@ public override string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerial /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ParentPet).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs index 9c60f7dd5ea0..6a5faf56cf2a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs @@ -165,7 +165,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Pet).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index 21ece5ddb767..e6907c958bd4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -90,7 +90,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as QuadrilateralInterface).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index 22ad0fb2a9e4..b5bb2ba49d04 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -95,7 +95,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ReadOnlyFirst).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Return.cs index fd56cc052c77..17dde3fac7e1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Return.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Return).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index ad295d97343a..62a466e26d72 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -101,7 +101,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ScaleneTriangle).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeInterface.cs index eca229af761d..8dcdde81b869 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -90,7 +90,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ShapeInterface).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index cc6cf0fe35e8..70d3116a3e18 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -101,7 +101,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as SimpleQuadrilateral).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SpecialModelName.cs index a34e9382470b..eab25c66d0e5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -79,7 +79,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as SpecialModelName).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Tag.cs index 15f46fa62d45..ea7577d88f0d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Tag.cs @@ -88,7 +88,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Tag).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/TriangleInterface.cs index 055dec6a9cf5..8ffa8fbf7b10 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -90,7 +90,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as TriangleInterface).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/User.cs index bc7ffaaa63fb..a0f56c846f95 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/User.cs @@ -183,7 +183,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as User).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Whale.cs index 0778d715e6fe..a717bc00acf2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Whale.cs @@ -108,7 +108,7 @@ public virtual string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSeriali /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Whale).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs index 9a6bb5832dda..cb25a58b8ab1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs @@ -126,7 +126,7 @@ public string ToJson(Newtonsoft.Json.JsonSerializerSettings? jsonSerializerSetti /// /// Object to be compared /// Boolean - public override bool Equals(object? input) + public override bool Equals(object??? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Zebra).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 3acb9f77d18c..4a8f62cf5beb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -1,9 +1,8 @@ - - - net5.0 + false + netstandard2.0 Org.OpenAPITools Org.OpenAPITools Library @@ -26,7 +25,7 @@ - + From f17a59a9f9abf5e1c343e5cd5557ad253bcc0e8d Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 27 Feb 2021 15:18:01 -0500 Subject: [PATCH 19/20] removed testing api reference and restored postprocessing instructions --- .../libraries/httpclient/README.mustache | 33 +++++++++++++++++++ .../libraries/httpclient/api.mustache | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache index c3f501bb2423..08386374f42c 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache @@ -1,3 +1,36 @@ +This library requires some post procesing. You can use this PowerShell script to run the generator and process the results. + +If you are not using .Net Standard, consider setting validatable to false in your generator-config.json due to this bug: https://github.com/dotnet/project-system/issues/3934 + +``` +java -jar "../openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate ` + -g csharp-netcore ` + -i "your-swagger-file.yml" ` + -c generator-config.json ` + -o output ` + -t templates ` + --library httpclient + +$files = Get-ChildItem output -Recurse | Where-Object {-Not($_.PSIsContainer)} +foreach ($file in $files) +{ + $content=Get-Content $file.PSPath + + if (-Not($content)){ + continue; + } + + # if null reference types are enabled + $content=$content -replace '\?{3,4}', '?' # replace every three to four consecutive occurrences of '?' with a single one + + # if null reference types are not enabled + # $content=$content.Replace("????", "?") # reference type + # $content=$content.Replace("???", "") # value type + + Set-Content $file.PSPath $content +} +``` + # {{packageName}} - the C# library for the {{appName}} {{#appDescriptionWithNewLines}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache index 6f930608e127..d250749ab934 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache @@ -315,7 +315,7 @@ namespace {{packageName}}.{{apiPackage}} ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> apiResponse = new ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>(apiResponse.RawContent, {{packageName}}.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } From 5d42a26c4234ffcff38d641b9e9027447ba3f621 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 27 Feb 2021 15:25:45 -0500 Subject: [PATCH 20/20] build samples --- .../OpenAPIClient-httpclient/README.md | 33 +++++++++++++++++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 2 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 2 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 30 ++++++++--------- .../Api/FakeClassnameTags123Api.cs | 2 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 18 +++++----- .../src/Org.OpenAPITools/Api/StoreApi.cs | 8 ++--- .../src/Org.OpenAPITools/Api/UserApi.cs | 16 ++++----- 8 files changed, 72 insertions(+), 39 deletions(-) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md index 80080ff900af..a273e0c51575 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md @@ -1,3 +1,36 @@ +This library requires some post procesing. You can use this PowerShell script to run the generator and process the results. + +If you are not using .Net Standard, consider setting validatable to false in your generator-config.json due to this bug: https://github.com/dotnet/project-system/issues/3934 + +``` +java -jar "../openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate ` + -g csharp-netcore ` + -i "your-swagger-file.yml" ` + -c generator-config.json ` + -o output ` + -t templates ` + --library httpclient + +$files = Get-ChildItem output -Recurse | Where-Object {-Not($_.PSIsContainer)} +foreach ($file in $files) +{ + $content=Get-Content $file.PSPath + + if (-Not($content)){ + continue; + } + + # if null reference types are enabled + $content=$content -replace '\?{3,4}', '?' # replace every three to four consecutive occurrences of '?' with a single one + + # if null reference types are not enabled + # $content=$content.Replace("????", "?") # reference type + # $content=$content.Replace("???", "") # value type + + Set-Content $file.PSPath $content +} +``` + # Org.OpenAPITools - the C# library for the OpenAPI Petstore This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index c62cf571bf8e..eb9f5c92647f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -172,7 +172,7 @@ public async System.Threading.Tasks.Task Call123TestSpecialTagsAsyn ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs index 3a461daa69ac..4932f85fa838 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -160,7 +160,7 @@ public async System.Threading.Tasks.Task FooGetAsync(Syst ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs index c60603d01acf..12278f589c02 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs @@ -615,7 +615,7 @@ public async System.Threading.Tasks.Task FakeHealthGetAsync(S ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -708,7 +708,7 @@ public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bo ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -801,7 +801,7 @@ public async System.Threading.Tasks.Task FakeOuterCompositeSeria ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -894,7 +894,7 @@ public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync( ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -987,7 +987,7 @@ public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(s ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1073,7 +1073,7 @@ public async System.Threading.Tasks.Task> GetArrayOfEnumsAsync(S ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1140,7 +1140,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithFileSchem ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1213,7 +1213,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithQueryPara ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1308,7 +1308,7 @@ public async System.Threading.Tasks.Task TestClientModelAsync(Model ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1450,7 +1450,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestEndpointParameter ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1552,7 +1552,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestEnumParametersReq ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1642,7 +1642,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestGroupParametersRe ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1709,7 +1709,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestInlineAdditionalP ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1781,7 +1781,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestJsonFormDataReque ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1871,7 +1871,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestQueryParameterCol ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 5d216ada5846..6f465616b245 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -175,7 +175,7 @@ public async System.Threading.Tasks.Task TestClassnameAsync(ModelCl ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs index 6f2c3ac5bddb..47bfa210df29 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs @@ -419,7 +419,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateAddPetRequestAsync(Pe ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -491,7 +491,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeletePetRequestAsync ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -609,7 +609,7 @@ public async System.Threading.Tasks.Task> FindPetsByStatusAsync(List> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -727,7 +727,7 @@ public async System.Threading.Tasks.Task> FindPetsByTagsAsync(List> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -828,7 +828,7 @@ public async System.Threading.Tasks.Task GetPetByIdAsync(long petId, System ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -920,7 +920,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetRequestAsync ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1002,7 +1002,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdatePetWithFormRequ ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1116,7 +1116,7 @@ public async System.Threading.Tasks.Task UploadFileAsync(long petId ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -1229,7 +1229,7 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs index 600395f5b108..93e133c8c6d0 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs @@ -232,7 +232,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeleteOrderRequestAsy ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -326,7 +326,7 @@ public async System.Threading.Tasks.Task> GetInventoryAs ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -419,7 +419,7 @@ public async System.Threading.Tasks.Task GetOrderByIdAsync(long orderId, ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -515,7 +515,7 @@ public async System.Threading.Tasks.Task PlaceOrderAsync(Order order, Sys ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs index e44144d49e2d..bf6b9cb60b49 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs @@ -325,7 +325,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUserRequestAsyn ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -392,7 +392,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithArrayI ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -459,7 +459,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCreateUsersWithListIn ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -525,7 +525,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateDeleteUserRequestAsyn ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -620,7 +620,7 @@ public async System.Threading.Tasks.Task GetUserByNameAsync(string usernam ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -723,7 +723,7 @@ public async System.Threading.Tasks.Task LoginUserAsync(string username, ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -783,7 +783,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateLogoutUserRequestAsyn ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; } @@ -856,7 +856,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateUpdateUserRequestAsyn ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, CocApi.Client.ClientUtils.JsonSerializerSettings); + apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings); return apiResponse; }