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 5bb4b0261573..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
@@ -31,20 +31,20 @@ namespace {{packageName}}.Client
///
/// The raw content of this response
///
- string RawData { get; }
+ string RawContent { get; }
}
///
/// API Response
///
- public class ApiResponse : IApiResponse
+ {{>visibility}} 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)
@@ -68,7 +68,7 @@ namespace {{packageName}}.Client
///
/// The raw data
///
- public string RawData { get; }
+ public string RawContent { get; }
///
/// The IsSuccessStatusCode from the api response
@@ -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
@@ -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/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
new file mode 100644
index 000000000000..08386374f42c
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/README.mustache
@@ -0,0 +1,252 @@
+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}}
+{{{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
+
+- [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 Newtonsoft.Json
+Install-Package JsonSubTypes
+{{#validatable}}
+Install-Package System.ComponentModel.Annotations
+{{/validatable}}
+{{#useCompareNetObjects}}
+Install-Package CompareNETObjects
+{{/useCompareNetObjects}}
+```
+
+
+## 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}}
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..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
@@ -110,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}}
@@ -129,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}}
@@ -228,7 +228,7 @@ namespace {{packageName}}.{{apiPackage}}
{{/formParams}}
{{#bodyParam}}
- // todo localVarRequestOptions.Data = {{paramName}};
+ // todo localVarRequestOptions.Content = {{paramName}};
{{/bodyParam}}
{{#authMethods}}
@@ -312,10 +312,10 @@ 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.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, {{packageName}}.Client.ClientUtils.JsonSerializerSettings);
return apiResponse;
}
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/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..1827f9f61e3a
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/modelGeneric.mustache
@@ -0,0 +1,353 @@
+ ///
+ /// {{#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}}
+ }
+
+ ///
+ /// 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}}
+ ///
+ /// 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/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..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
@@ -2,7 +2,7 @@
false
- net5.0
+ {{targetFramework}}
{{packageName}}
{{packageName}}
Library
@@ -28,11 +28,9 @@
{{/useCompareNetObjects}}
-
{{#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}}
+
+
+
+
+
+
+
+
+
+
+
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/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md
index 1cca61e28718..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: \" \\
@@ -17,7 +50,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
@@ -25,15 +57,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 0d6ff9ad905b..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
@@ -100,7 +100,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateCall123TestSpecialTag
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();
}
///
@@ -115,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;
}
@@ -151,7 +151,7 @@ public async System.Threading.Tasks.Task Call123TestSpecialTagsAsyn
- // todo localVarRequestOptions.Data = modelClient;
+ // todo localVarRequestOptions.Content = modelClient;
request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
@@ -169,10 +169,10 @@ 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.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, 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 5ee6e54c869a..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
@@ -95,7 +95,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateFooGetRequestAsync(Sy
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();
}
///
@@ -109,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;
}
@@ -157,10 +157,10 @@ 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.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, 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 f4aee0c37628..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
@@ -550,7 +550,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateFakeHealthGetRequestA
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();
}
///
@@ -564,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;
}
@@ -612,10 +612,10 @@ 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.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings);
+ apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings);
return apiResponse;
}
@@ -638,7 +638,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterBooleanSeria
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();
}
///
@@ -653,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;
}
@@ -687,7 +687,7 @@ public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync(bo
- // todo localVarRequestOptions.Data = body;
+ // todo localVarRequestOptions.Content = body;
request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
@@ -705,10 +705,10 @@ 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.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings);
+ apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings);
return apiResponse;
}
@@ -731,7 +731,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterCompositeSer
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();
}
///
@@ -746,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;
}
@@ -780,7 +780,7 @@ public async System.Threading.Tasks.Task FakeOuterCompositeSeria
- // todo localVarRequestOptions.Data = outerComposite;
+ // todo localVarRequestOptions.Content = outerComposite;
request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
@@ -798,10 +798,10 @@ 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.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings);
+ apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings);
return apiResponse;
}
@@ -824,7 +824,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterNumberSerial
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();
}
///
@@ -839,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;
}
@@ -873,7 +873,7 @@ public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync(
- // todo localVarRequestOptions.Data = body;
+ // todo localVarRequestOptions.Content = body;
request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
@@ -891,10 +891,10 @@ 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.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings);
+ apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings);
return apiResponse;
}
@@ -917,7 +917,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateFakeOuterStringSerial
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();
}
///
@@ -932,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;
}
@@ -966,7 +966,7 @@ public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync(s
- // todo localVarRequestOptions.Data = body;
+ // todo localVarRequestOptions.Content = body;
request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
@@ -984,10 +984,10 @@ 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.Data = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings);
+ apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings);
return apiResponse;
}
@@ -1008,7 +1008,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateGetArrayOfEnumsReques
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();
}
///
@@ -1022,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;
}
@@ -1070,10 +1070,10 @@ 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.Data = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawData, CocApi.Client.ClientUtils.JsonSerializerSettings);
+ apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, Org.OpenAPITools.Client.ClientUtils.JsonSerializerSettings);
return apiResponse;
}
@@ -1120,7 +1120,7 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithFileSchem
- // todo localVarRequestOptions.Data = fileSchemaTestClass;
+ // todo localVarRequestOptions.Content = fileSchemaTestClass;
request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
@@ -1137,10 +1137,10 @@ protected virtual System.Threading.Tasks.ValueTask ValidateTestBodyWithFileSchem
string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
- ApiResponse