diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 3199e40577c..2a5145e1030 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -5701,8 +5701,6 @@ public class DefaultCodegen implements CodegenConfig { } } - private final Map seenOperationIds = new HashMap(); - /** * Add operation to group * @@ -5723,18 +5721,13 @@ public class DefaultCodegen implements CodegenConfig { } // check for operationId uniqueness String uniqueName = co.operationId; - int counter = seenOperationIds.getOrDefault(uniqueName, 0); - while (seenOperationIds.containsKey(uniqueName)) { - uniqueName = co.operationId + "_" + counter; - counter++; - } + int counter = 0; for (CodegenOperation op : opList) { if (uniqueName.equals(op.operationId)) { uniqueName = co.operationId + "_" + counter; counter++; } } - seenOperationIds.put(co.operationId, counter); if (!co.operationId.equals(uniqueName)) { LOGGER.warn("generated unique operationId `{}`", uniqueName); } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java index c09ea9b0a9a..02043c013d9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java @@ -823,6 +823,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen { httpStatusesWithReturn.add(status); } } + private HashMap duplicateOf = new HashMap(); @Override @SuppressWarnings("unchecked") @@ -842,6 +843,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen { if (operations != null) { List ops = operations.getOperation(); for (CodegenOperation operation : ops) { + String duplicates = duplicateOf.get(operation.operationId); + if (duplicates != null) { + operation.vendorExtensions.put("x-duplicates", duplicates); + } else { + duplicateOf.put(operation.operationId, operations.getClassname()); + } if (operation.responses != null) { for (CodegenResponse response : operation.responses) { diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache index bd8d6fae493..b33115f0a5e 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache @@ -85,6 +85,7 @@ namespace {{packageName}}.{{apiPackage}} {{/operation}} } {{#operation}} + {{^vendorExtensions.x-duplicates}} {{#responses}} {{#-first}} @@ -115,6 +116,7 @@ namespace {{packageName}}.{{apiPackage}} } {{/-first}} {{/responses}} + {{/vendorExtensions.x-duplicates}} {{/operation}} /// @@ -134,7 +136,7 @@ namespace {{packageName}}.{{apiPackage}} /// public event EventHandler{{nrt?}} OnError{{operationId}}; - internal void ExecuteOn{{operationId}}({{classname}}.{{operationId}}ApiResponse apiResponse) + internal void ExecuteOn{{operationId}}({{#vendorExtensions.x-duplicates}}{{.}}{{/vendorExtensions.x-duplicates}}{{^vendorExtensions.x-duplicates}}{{classname}}{{/vendorExtensions.x-duplicates}}.{{operationId}}ApiResponse apiResponse) { On{{operationId}}?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } @@ -619,9 +621,9 @@ namespace {{packageName}}.{{apiPackage}} { string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync({{#net60OrLater}}cancellationToken{{/net60OrLater}}).ConfigureAwait(false); - ILogger<{{operationId}}ApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<{{operationId}}ApiResponse>(); + ILogger<{{#vendorExtensions.x-duplicates}}{{.}}.{{/vendorExtensions.x-duplicates}}{{operationId}}ApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<{{#vendorExtensions.x-duplicates}}{{.}}.{{/vendorExtensions.x-duplicates}}{{operationId}}ApiResponse>(); - {{operationId}}ApiResponse apiResponseLocalVar = new{{^net60OrLater}} {{operationId}}ApiResponse{{/net60OrLater}}(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "{{{path}}}", requestedAtLocalVar, _jsonSerializerOptions); + {{#vendorExtensions.x-duplicates}}{{.}}.{{/vendorExtensions.x-duplicates}}{{operationId}}ApiResponse apiResponseLocalVar = new{{^net60OrLater}} {{operationId}}ApiResponse{{/net60OrLater}}(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "{{{path}}}", requestedAtLocalVar, _jsonSerializerOptions); After{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}apiResponseLocalVar {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); @@ -680,6 +682,7 @@ namespace {{packageName}}.{{apiPackage}} } {{/lambda.trimLineBreaks}} } + {{^vendorExtensions.x-duplicates}} {{#responses}} {{#-first}} @@ -792,6 +795,7 @@ namespace {{packageName}}.{{apiPackage}} } {{/-first}} {{/responses}} + {{/vendorExtensions.x-duplicates}} {{/operation}} } {{/operations}} diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/docs/apis/APIKEYSApi.md b/samples/client/petstore/csharp/generichost/latest/Tags/docs/apis/APIKEYSApi.md index bae5c9ea169..ce4c24a87f4 100644 --- a/samples/client/petstore/csharp/generichost/latest/Tags/docs/apis/APIKEYSApi.md +++ b/samples/client/petstore/csharp/generichost/latest/Tags/docs/apis/APIKEYSApi.md @@ -4,11 +4,11 @@ All URIs are relative to *http://app.files.com/api/rest/v1* | Method | HTTP request | Description | |--------|--------------|-------------| -| [**GetApiKeysId_1**](APIKEYSApi.md#getapikeysid_1) | **GET** /api_keys/{id} | Show API Key | +| [**GetApiKeysId**](APIKEYSApi.md#getapikeysid) | **GET** /api_keys/{id} | Show API Key | - -# **GetApiKeysId_1** -> void GetApiKeysId_1 (int id) + +# **GetApiKeysId** +> void GetApiKeysId (int id) Show API Key @@ -24,7 +24,7 @@ using Org.OpenAPITools.Model; namespace Example { - public class GetApiKeysId_1Example + public class GetApiKeysIdExample { public static void Main() { @@ -36,11 +36,11 @@ namespace Example try { // Show API Key - apiInstance.GetApiKeysId_1(id); + apiInstance.GetApiKeysId(id); } catch (ApiException e) { - Debug.Print("Exception when calling APIKEYSApi.GetApiKeysId_1: " + e.Message); + Debug.Print("Exception when calling APIKEYSApi.GetApiKeysId: " + e.Message); Debug.Print("Status Code: " + e.ErrorCode); Debug.Print(e.StackTrace); } @@ -49,18 +49,18 @@ namespace Example } ``` -#### Using the GetApiKeysId_1WithHttpInfo variant +#### Using the GetApiKeysIdWithHttpInfo variant This returns an ApiResponse object which contains the response data, status code and headers. ```csharp try { // Show API Key - apiInstance.GetApiKeysId_1WithHttpInfo(id); + apiInstance.GetApiKeysIdWithHttpInfo(id); } catch (ApiException e) { - Debug.Print("Exception when calling APIKEYSApi.GetApiKeysId_1WithHttpInfo: " + e.Message); + Debug.Print("Exception when calling APIKEYSApi.GetApiKeysIdWithHttpInfo: " + e.Message); Debug.Print("Status Code: " + e.ErrorCode); Debug.Print(e.StackTrace); } diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/docs/apis/APIKeys0Api.md b/samples/client/petstore/csharp/generichost/latest/Tags/docs/apis/APIKeys0Api.md index c0520bd8d8d..7c763a0cc57 100644 --- a/samples/client/petstore/csharp/generichost/latest/Tags/docs/apis/APIKeys0Api.md +++ b/samples/client/petstore/csharp/generichost/latest/Tags/docs/apis/APIKeys0Api.md @@ -4,11 +4,11 @@ All URIs are relative to *http://app.files.com/api/rest/v1* | Method | HTTP request | Description | |--------|--------------|-------------| -| [**GetApiKeysId_0**](APIKeysApi.md#getapikeysid_0) | **GET** /api_keys/{id} | Show API Key | +| [**GetApiKeysId**](APIKeysApi.md#getapikeysid) | **GET** /api_keys/{id} | Show API Key | - -# **GetApiKeysId_0** -> void GetApiKeysId_0 (int id) + +# **GetApiKeysId** +> void GetApiKeysId (int id) Show API Key @@ -24,7 +24,7 @@ using Org.OpenAPITools.Model; namespace Example { - public class GetApiKeysId_0Example + public class GetApiKeysIdExample { public static void Main() { @@ -36,11 +36,11 @@ namespace Example try { // Show API Key - apiInstance.GetApiKeysId_0(id); + apiInstance.GetApiKeysId(id); } catch (ApiException e) { - Debug.Print("Exception when calling APIKeysApi.GetApiKeysId_0: " + e.Message); + Debug.Print("Exception when calling APIKeysApi.GetApiKeysId: " + e.Message); Debug.Print("Status Code: " + e.ErrorCode); Debug.Print(e.StackTrace); } @@ -49,18 +49,18 @@ namespace Example } ``` -#### Using the GetApiKeysId_0WithHttpInfo variant +#### Using the GetApiKeysIdWithHttpInfo variant This returns an ApiResponse object which contains the response data, status code and headers. ```csharp try { // Show API Key - apiInstance.GetApiKeysId_0WithHttpInfo(id); + apiInstance.GetApiKeysIdWithHttpInfo(id); } catch (ApiException e) { - Debug.Print("Exception when calling APIKeysApi.GetApiKeysId_0WithHttpInfo: " + e.Message); + Debug.Print("Exception when calling APIKeysApi.GetApiKeysIdWithHttpInfo: " + e.Message); Debug.Print("Status Code: " + e.ErrorCode); Debug.Print(e.StackTrace); } diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools.Test/Api/APIKEYSApiTests.cs b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools.Test/Api/APIKEYSApiTests.cs index 75525420b62..eb6f442e4d3 100644 --- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools.Test/Api/APIKEYSApiTests.cs +++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools.Test/Api/APIKEYSApiTests.cs @@ -51,13 +51,13 @@ namespace Org.OpenAPITools.Test.Api } /// - /// Test GetApiKeysId_1 + /// Test GetApiKeysId /// [Fact (Skip = "not implemented")] - public async Task GetApiKeysId_1AsyncTest() + public async Task GetApiKeysIdAsyncTest() { int id = default!; - await _instance.GetApiKeysId_1Async(id); + await _instance.GetApiKeysIdAsync(id); } } } diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools.Test/Api/APIKeys0ApiTests.cs b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools.Test/Api/APIKeys0ApiTests.cs index b05a814880f..d3c390b7f38 100644 --- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools.Test/Api/APIKeys0ApiTests.cs +++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools.Test/Api/APIKeys0ApiTests.cs @@ -51,13 +51,13 @@ namespace Org.OpenAPITools.Test.Api } /// - /// Test GetApiKeysId_0 + /// Test GetApiKeysId /// [Fact (Skip = "not implemented")] - public async Task GetApiKeysId_0AsyncTest() + public async Task GetApiKeysIdAsyncTest() { int id = default!; - await _instance.GetApiKeysId_0Async(id); + await _instance.GetApiKeysIdAsync(id); } } } diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKEYSApi.cs b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKEYSApi.cs index 01bfb94eced..a69943340cf 100644 --- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKEYSApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKEYSApi.cs @@ -44,8 +44,8 @@ namespace Org.OpenAPITools.Api /// Thrown when fails to make API call /// Api Key ID. /// Cancellation Token to cancel the request. - /// <> - Task GetApiKeysId_1Async(int id, System.Threading.CancellationToken cancellationToken = default); + /// <> + Task GetApiKeysIdAsync(int id, System.Threading.CancellationToken cancellationToken = default); /// /// Show API Key @@ -55,14 +55,14 @@ namespace Org.OpenAPITools.Api /// /// Api Key ID. /// Cancellation Token to cancel the request. - /// <?> - Task GetApiKeysId_1OrDefaultAsync(int id, System.Threading.CancellationToken cancellationToken = default); + /// <?> + Task GetApiKeysIdOrDefaultAsync(int id, System.Threading.CancellationToken cancellationToken = default); } /// - /// The + /// The /// - public interface IGetApiKeysId_1ApiResponse : Org.OpenAPITools.Client.IApiResponse + public interface IGetApiKeysIdApiResponse : Org.OpenAPITools.Client.IApiResponse { /// /// Returns true if the response is 400 BadRequest @@ -79,21 +79,21 @@ namespace Org.OpenAPITools.Api /// /// The event raised after the server response /// - public event EventHandler? OnGetApiKeysId_1; + public event EventHandler? OnGetApiKeysId; /// /// The event raised after an error querying the server /// - public event EventHandler? OnErrorGetApiKeysId_1; + public event EventHandler? OnErrorGetApiKeysId; - internal void ExecuteOnGetApiKeysId_1(APIKEYSApi.GetApiKeysId_1ApiResponse apiResponse) + internal void ExecuteOnGetApiKeysId(APIKEYSApi.GetApiKeysIdApiResponse apiResponse) { - OnGetApiKeysId_1?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + OnGetApiKeysId?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } - internal void ExecuteOnErrorGetApiKeysId_1(Exception exception) + internal void ExecuteOnErrorGetApiKeysId(Exception exception) { - OnErrorGetApiKeysId_1?.Invoke(this, new ExceptionEventArgs(exception)); + OnErrorGetApiKeysId?.Invoke(this, new ExceptionEventArgs(exception)); } } @@ -144,17 +144,17 @@ namespace Org.OpenAPITools.Api ApiKeyProvider = apiKeyProvider; } - partial void FormatGetApiKeysId_1(ref int id); + partial void FormatGetApiKeysId(ref int id); /// /// Processes the server response /// /// /// - private void AfterGetApiKeysId_1DefaultImplementation(IGetApiKeysId_1ApiResponse apiResponseLocalVar, int id) + private void AfterGetApiKeysIdDefaultImplementation(IGetApiKeysIdApiResponse apiResponseLocalVar, int id) { bool suppressDefaultLog = false; - AfterGetApiKeysId_1(ref suppressDefaultLog, apiResponseLocalVar, id); + AfterGetApiKeysId(ref suppressDefaultLog, apiResponseLocalVar, id); if (!suppressDefaultLog) Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); } @@ -165,7 +165,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void AfterGetApiKeysId_1(ref bool suppressDefaultLog, IGetApiKeysId_1ApiResponse apiResponseLocalVar, int id); + partial void AfterGetApiKeysId(ref bool suppressDefaultLog, IGetApiKeysIdApiResponse apiResponseLocalVar, int id); /// /// Logs exceptions that occur while retrieving the server response @@ -174,10 +174,10 @@ namespace Org.OpenAPITools.Api /// /// /// - private void OnErrorGetApiKeysId_1DefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, int id) + private void OnErrorGetApiKeysIdDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, int id) { bool suppressDefaultLogLocalVar = false; - OnErrorGetApiKeysId_1(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, id); + OnErrorGetApiKeysId(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, id); if (!suppressDefaultLogLocalVar) Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); } @@ -190,19 +190,19 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorGetApiKeysId_1(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, int id); + partial void OnErrorGetApiKeysId(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, int id); /// /// Show API Key Show API Key /// /// Api Key ID. /// Cancellation Token to cancel the request. - /// <> - public async Task GetApiKeysId_1OrDefaultAsync(int id, System.Threading.CancellationToken cancellationToken = default) + /// <> + public async Task GetApiKeysIdOrDefaultAsync(int id, System.Threading.CancellationToken cancellationToken = default) { try { - return await GetApiKeysId_1Async(id, cancellationToken).ConfigureAwait(false); + return await GetApiKeysIdAsync(id, cancellationToken).ConfigureAwait(false); } catch (Exception) { @@ -216,14 +216,14 @@ namespace Org.OpenAPITools.Api /// Thrown when fails to make API call /// Api Key ID. /// Cancellation Token to cancel the request. - /// <> - public async Task GetApiKeysId_1Async(int id, System.Threading.CancellationToken cancellationToken = default) + /// <> + public async Task GetApiKeysIdAsync(int id, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); try { - FormatGetApiKeysId_1(ref id); + FormatGetApiKeysId(ref id); using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) { @@ -243,13 +243,13 @@ namespace Org.OpenAPITools.Api { string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetApiKeysId_1ApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions); + GetApiKeysIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetApiKeysId_1DefaultImplementation(apiResponseLocalVar, id); + AfterGetApiKeysIdDefaultImplementation(apiResponseLocalVar, id); - Events.ExecuteOnGetApiKeysId_1(apiResponseLocalVar); + Events.ExecuteOnGetApiKeysId(apiResponseLocalVar); return apiResponseLocalVar; } @@ -257,24 +257,24 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetApiKeysId_1DefaultImplementation(e, "/api_keys/{id}", uriBuilderLocalVar.Path, id); - Events.ExecuteOnErrorGetApiKeysId_1(e); + OnErrorGetApiKeysIdDefaultImplementation(e, "/api_keys/{id}", uriBuilderLocalVar.Path, id); + Events.ExecuteOnErrorGetApiKeysId(e); throw; } } /// - /// The + /// The /// - public partial class GetApiKeysId_1ApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetApiKeysId_1ApiResponse + public partial class GetApiKeysIdApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetApiKeysIdApiResponse { /// /// The logger /// - public ILogger Logger { get; } + public ILogger Logger { get; } /// - /// The + /// The /// /// /// @@ -283,7 +283,7 @@ namespace Org.OpenAPITools.Api /// /// /// - public GetApiKeysId_1ApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + public GetApiKeysIdApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) { Logger = logger; OnCreated(httpRequestMessage, httpResponseMessage); diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKeys0Api.cs b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKeys0Api.cs index 01f8b704639..cfa1ca9243d 100644 --- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKeys0Api.cs +++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKeys0Api.cs @@ -44,8 +44,8 @@ namespace Org.OpenAPITools.Api /// Thrown when fails to make API call /// Api Key ID. /// Cancellation Token to cancel the request. - /// <> - Task GetApiKeysId_0Async(int id, System.Threading.CancellationToken cancellationToken = default); + /// <> + Task GetApiKeysIdAsync(int id, System.Threading.CancellationToken cancellationToken = default); /// /// Show API Key @@ -55,20 +55,8 @@ namespace Org.OpenAPITools.Api /// /// Api Key ID. /// Cancellation Token to cancel the request. - /// <?> - Task GetApiKeysId_0OrDefaultAsync(int id, System.Threading.CancellationToken cancellationToken = default); - } - - /// - /// The - /// - public interface IGetApiKeysId_0ApiResponse : Org.OpenAPITools.Client.IApiResponse - { - /// - /// Returns true if the response is 400 BadRequest - /// - /// - bool IsBadRequest { get; } + /// <?> + Task GetApiKeysIdOrDefaultAsync(int id, System.Threading.CancellationToken cancellationToken = default); } /// @@ -79,21 +67,21 @@ namespace Org.OpenAPITools.Api /// /// The event raised after the server response /// - public event EventHandler? OnGetApiKeysId_0; + public event EventHandler? OnGetApiKeysId; /// /// The event raised after an error querying the server /// - public event EventHandler? OnErrorGetApiKeysId_0; + public event EventHandler? OnErrorGetApiKeysId; - internal void ExecuteOnGetApiKeysId_0(APIKeysApi.GetApiKeysId_0ApiResponse apiResponse) + internal void ExecuteOnGetApiKeysId(APIKEYSApi.GetApiKeysIdApiResponse apiResponse) { - OnGetApiKeysId_0?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + OnGetApiKeysId?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } - internal void ExecuteOnErrorGetApiKeysId_0(Exception exception) + internal void ExecuteOnErrorGetApiKeysId(Exception exception) { - OnErrorGetApiKeysId_0?.Invoke(this, new ExceptionEventArgs(exception)); + OnErrorGetApiKeysId?.Invoke(this, new ExceptionEventArgs(exception)); } } @@ -144,17 +132,17 @@ namespace Org.OpenAPITools.Api ApiKeyProvider = apiKeyProvider; } - partial void FormatGetApiKeysId_0(ref int id); + partial void FormatGetApiKeysId(ref int id); /// /// Processes the server response /// /// /// - private void AfterGetApiKeysId_0DefaultImplementation(IGetApiKeysId_0ApiResponse apiResponseLocalVar, int id) + private void AfterGetApiKeysIdDefaultImplementation(IGetApiKeysIdApiResponse apiResponseLocalVar, int id) { bool suppressDefaultLog = false; - AfterGetApiKeysId_0(ref suppressDefaultLog, apiResponseLocalVar, id); + AfterGetApiKeysId(ref suppressDefaultLog, apiResponseLocalVar, id); if (!suppressDefaultLog) Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); } @@ -165,7 +153,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void AfterGetApiKeysId_0(ref bool suppressDefaultLog, IGetApiKeysId_0ApiResponse apiResponseLocalVar, int id); + partial void AfterGetApiKeysId(ref bool suppressDefaultLog, IGetApiKeysIdApiResponse apiResponseLocalVar, int id); /// /// Logs exceptions that occur while retrieving the server response @@ -174,10 +162,10 @@ namespace Org.OpenAPITools.Api /// /// /// - private void OnErrorGetApiKeysId_0DefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, int id) + private void OnErrorGetApiKeysIdDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, int id) { bool suppressDefaultLogLocalVar = false; - OnErrorGetApiKeysId_0(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, id); + OnErrorGetApiKeysId(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, id); if (!suppressDefaultLogLocalVar) Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); } @@ -190,19 +178,19 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorGetApiKeysId_0(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, int id); + partial void OnErrorGetApiKeysId(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, int id); /// /// Show API Key Show API Key /// /// Api Key ID. /// Cancellation Token to cancel the request. - /// <> - public async Task GetApiKeysId_0OrDefaultAsync(int id, System.Threading.CancellationToken cancellationToken = default) + /// <> + public async Task GetApiKeysIdOrDefaultAsync(int id, System.Threading.CancellationToken cancellationToken = default) { try { - return await GetApiKeysId_0Async(id, cancellationToken).ConfigureAwait(false); + return await GetApiKeysIdAsync(id, cancellationToken).ConfigureAwait(false); } catch (Exception) { @@ -216,14 +204,14 @@ namespace Org.OpenAPITools.Api /// Thrown when fails to make API call /// Api Key ID. /// Cancellation Token to cancel the request. - /// <> - public async Task GetApiKeysId_0Async(int id, System.Threading.CancellationToken cancellationToken = default) + /// <> + public async Task GetApiKeysIdAsync(int id, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); try { - FormatGetApiKeysId_0(ref id); + FormatGetApiKeysId(ref id); using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) { @@ -243,13 +231,13 @@ namespace Org.OpenAPITools.Api { string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetApiKeysId_0ApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions); + APIKEYSApi.GetApiKeysIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetApiKeysId_0DefaultImplementation(apiResponseLocalVar, id); + AfterGetApiKeysIdDefaultImplementation(apiResponseLocalVar, id); - Events.ExecuteOnGetApiKeysId_0(apiResponseLocalVar); + Events.ExecuteOnGetApiKeysId(apiResponseLocalVar); return apiResponseLocalVar; } @@ -257,55 +245,10 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetApiKeysId_0DefaultImplementation(e, "/api_keys/{id}", uriBuilderLocalVar.Path, id); - Events.ExecuteOnErrorGetApiKeysId_0(e); + OnErrorGetApiKeysIdDefaultImplementation(e, "/api_keys/{id}", uriBuilderLocalVar.Path, id); + Events.ExecuteOnErrorGetApiKeysId(e); throw; } } - - /// - /// The - /// - public partial class GetApiKeysId_0ApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetApiKeysId_0ApiResponse - { - /// - /// The logger - /// - public ILogger Logger { get; } - - /// - /// The - /// - /// - /// - /// - /// - /// - /// - /// - public GetApiKeysId_0ApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) - { - Logger = logger; - OnCreated(httpRequestMessage, httpResponseMessage); - } - - partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); - - /// - /// Returns true if the response is 400 BadRequest - /// - /// - public bool IsBadRequest => 400 == (int)StatusCode; - - private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) - { - bool suppressDefaultLog = false; - OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); - if (!suppressDefaultLog) - Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); - } - - partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); - } } } diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/ApiKeys1Api.cs b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/ApiKeys1Api.cs index be13fa923c7..ffce7ebc04e 100644 --- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/ApiKeys1Api.cs +++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/ApiKeys1Api.cs @@ -59,18 +59,6 @@ namespace Org.OpenAPITools.Api Task GetApiKeysIdOrDefaultAsync(int id, System.Threading.CancellationToken cancellationToken = default); } - /// - /// The - /// - public interface IGetApiKeysIdApiResponse : Org.OpenAPITools.Client.IApiResponse - { - /// - /// Returns true if the response is 400 BadRequest - /// - /// - bool IsBadRequest { get; } - } - /// /// Represents a collection of functions to interact with the API endpoints /// @@ -86,7 +74,7 @@ namespace Org.OpenAPITools.Api /// public event EventHandler? OnErrorGetApiKeysId; - internal void ExecuteOnGetApiKeysId(ApiKeysApi.GetApiKeysIdApiResponse apiResponse) + internal void ExecuteOnGetApiKeysId(APIKEYSApi.GetApiKeysIdApiResponse apiResponse) { OnGetApiKeysId?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } @@ -243,9 +231,9 @@ namespace Org.OpenAPITools.Api { string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetApiKeysIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions); + APIKEYSApi.GetApiKeysIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetApiKeysIdDefaultImplementation(apiResponseLocalVar, id); @@ -262,50 +250,5 @@ namespace Org.OpenAPITools.Api throw; } } - - /// - /// The - /// - public partial class GetApiKeysIdApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetApiKeysIdApiResponse - { - /// - /// The logger - /// - public ILogger Logger { get; } - - /// - /// The - /// - /// - /// - /// - /// - /// - /// - /// - public GetApiKeysIdApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) - { - Logger = logger; - OnCreated(httpRequestMessage, httpResponseMessage); - } - - partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); - - /// - /// Returns true if the response is 400 BadRequest - /// - /// - public bool IsBadRequest => 400 == (int)StatusCode; - - private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) - { - bool suppressDefaultLog = false; - OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); - if (!suppressDefaultLog) - Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); - } - - partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); - } } } diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/README.md b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/README.md index b82a7527d4a..1065029951f 100644 --- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/README.md +++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/README.md @@ -61,7 +61,7 @@ namespace YourProject { var host = CreateHostBuilder(args).Build(); var api = host.Services.GetRequiredService(); - GetApiKeysId_1ApiResponse apiResponse = await api.GetApiKeysId_1Async("todo"); + GetApiKeysIdApiResponse apiResponse = await api.GetApiKeysIdAsync("todo"); object model = apiResponse.Ok(); }