diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/AfterOperationDefaultImplementation.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/AfterOperationDefaultImplementation.mustache new file mode 100644 index 00000000000..5db1afeab5e --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/AfterOperationDefaultImplementation.mustache @@ -0,0 +1 @@ + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/ApiResponse`1.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/ApiResponse`1.mustache index 03b9256153c..20823fd8fc1 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/ApiResponse`1.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/ApiResponse`1.mustache @@ -28,7 +28,7 @@ namespace {{packageName}}.{{clientPackage}} HttpStatusCode StatusCode { get; } /// - /// The raw content of this response + /// The raw content of this response. /// string RawContent { get; } @@ -36,6 +36,16 @@ namespace {{packageName}}.{{clientPackage}} /// The DateTime when the request was retrieved. /// DateTime DownloadedAt { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The Uri used when making the request. + /// + Uri{{nrt?}} RequestUri { get; } } /// @@ -82,6 +92,21 @@ namespace {{packageName}}.{{clientPackage}} /// public DateTime DownloadedAt { get; } = DateTime.UtcNow; + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri{{nrt?}} RequestUri { get; } + /// /// The JsonSerialzierOptions /// @@ -93,14 +118,19 @@ namespace {{packageName}}.{{clientPackage}} /// /// /// + /// + /// /// - public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) { StatusCode = httpResponseMessage.StatusCode; Headers = httpResponseMessage.Headers; IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; ReasonPhrase = httpResponseMessage.ReasonPhrase; RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; _jsonSerializerOptions = jsonSerializerOptions; OnCreated(httpRequestMessage, httpResponseMessage); } diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/OnErrorDefaultImplementation.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/OnErrorDefaultImplementation.mustache new file mode 100644 index 00000000000..bdefb67c6e4 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/OnErrorDefaultImplementation.mustache @@ -0,0 +1 @@ + Logger.LogError(exception, "An error occurred while sending the request to the server."); \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/api.mustache index bdafdaa9470..a3d24e5b7ca 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/api.mustache @@ -124,15 +124,6 @@ namespace {{packageName}}.{{apiPackage}} HttpSignatureTokenProvider = httpSignatureTokenProvider;{{/hasHttpSignatureMethods}}{{#hasOAuthMethods}} OauthTokenProvider = oauthTokenProvider;{{/hasOAuthMethods}} } - - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } {{#operation}} {{#allParams}} @@ -186,24 +177,47 @@ namespace {{packageName}}.{{apiPackage}} {{#allParams}} /// {{/allParams}} - protected virtual void After{{operationId}}({{#lambda.joinWithComma}}ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}> apiResponseLocalVar {{#allParams}}{{#requiredAndNotNullable}}{{#lambda.required}}{{{dataType}}}{{/lambda.required}} {{paramName}} {{/requiredAndNotNullable}}{{^requiredAndNotNullable}}{{#lambda.optional}}{{{dataType}}}{{/lambda.optional}} {{paramName}} {{/requiredAndNotNullable}}{{/allParams}}{{/lambda.joinWithComma}}) + private void After{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}> apiResponseLocalVar {{#allParams}}{{#requiredAndNotNullable}}{{#lambda.required}}{{{dataType}}}{{/lambda.required}} {{paramName}} {{/requiredAndNotNullable}}{{^requiredAndNotNullable}}{{#lambda.optional}}{{{dataType}}}{{/lambda.optional}} {{paramName}} {{/requiredAndNotNullable}}{{/allParams}}{{/lambda.joinWithComma}}) { +{{>AfterOperationDefaultImplementation}} + After{{operationId}}({{#lambda.joinWithComma}}apiResponseLocalVar {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); } /// /// Processes the server response /// + /// + {{#allParams}} + /// + {{/allParams}} + partial void After{{operationId}}({{#lambda.joinWithComma}}ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}> apiResponseLocalVar {{#allParams}}{{#requiredAndNotNullable}}{{#lambda.required}}{{{dataType}}}{{/lambda.required}} {{paramName}} {{/requiredAndNotNullable}}{{^requiredAndNotNullable}}{{#lambda.optional}}{{{dataType}}}{{/lambda.optional}} {{paramName}} {{/requiredAndNotNullable}}{{/allParams}}{{/lambda.joinWithComma}}); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// {{#allParams}} /// {{/allParams}} - protected virtual void OnError{{operationId}}({{#lambda.joinWithComma}}Exception exception string pathFormat string path {{#allParams}}{{#requiredAndNotNullable}}{{#lambda.required}}{{{dataType}}}{{/lambda.required}} {{paramName}} {{/requiredAndNotNullable}}{{^requiredAndNotNullable}}{{#lambda.optional}}{{{dataType}}}{{/lambda.optional}} {{paramName}} {{/requiredAndNotNullable}}{{/allParams}}{{/lambda.joinWithComma}}) + private void OnError{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}Exception exception string pathFormat string path {{#allParams}}{{#requiredAndNotNullable}}{{#lambda.required}}{{{dataType}}}{{/lambda.required}} {{paramName}} {{/requiredAndNotNullable}}{{^requiredAndNotNullable}}{{#lambda.optional}}{{{dataType}}}{{/lambda.optional}} {{paramName}} {{/requiredAndNotNullable}}{{/allParams}}{{/lambda.joinWithComma}}) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); +{{>OnErrorDefaultImplementation}} + OnError{{operationId}}({{#lambda.joinWithComma}}exception pathFormat path {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + {{#allParams}} + /// + {{/allParams}} + partial void OnError{{operationId}}({{#lambda.joinWithComma}}Exception exception string pathFormat string path {{#allParams}}{{#requiredAndNotNullable}}{{#lambda.required}}{{{dataType}}}{{/lambda.required}} {{paramName}} {{/requiredAndNotNullable}}{{^requiredAndNotNullable}}{{#lambda.optional}}{{{dataType}}}{{/lambda.optional}} {{paramName}} {{/requiredAndNotNullable}}{{/allParams}}{{/lambda.joinWithComma}}); + /// /// {{summary}} {{notes}} /// @@ -477,13 +491,11 @@ namespace {{packageName}}.{{apiPackage}} using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "{{path}}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync({{#net60OrLater}}cancellationToken{{/net60OrLater}}).ConfigureAwait(false); - ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}> apiResponseLocalVar = new ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}> apiResponseLocalVar = new ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "{{path}}", requestedAtLocalVar, _jsonSerializerOptions); - After{{operationId}}({{#lambda.joinWithComma}}apiResponseLocalVar {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); + After{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}apiResponseLocalVar {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); {{#authMethods}} if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) @@ -497,7 +509,7 @@ namespace {{packageName}}.{{apiPackage}} } catch(Exception e) { - OnError{{operationId}}({{#lambda.joinWithComma}}e "{{path}}" uriBuilderLocalVar.Path {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); + OnError{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}e "{{path}}" uriBuilderLocalVar.Path {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); throw; } {{/lambda.trimLineBreaks}} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 3f531b66344..3480bac3400 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -119,15 +119,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatCall123TestSpecialTags(ModelClient modelClient); /// @@ -152,22 +143,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterCall123TestSpecialTags(ApiResponse apiResponseLocalVar, ModelClient modelClient) + private void AfterCall123TestSpecialTagsDefaultImplementation(ApiResponse apiResponseLocalVar, ModelClient modelClient) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterCall123TestSpecialTags(apiResponseLocalVar, modelClient); } /// /// Processes the server response /// + /// + /// + partial void AfterCall123TestSpecialTags(ApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorCall123TestSpecialTags(Exception exception, string pathFormat, string path, ModelClient modelClient) + private void OnErrorCall123TestSpecialTagsDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorCall123TestSpecialTags(exception, pathFormat, path, modelClient); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorCall123TestSpecialTags(Exception exception, string pathFormat, string path, ModelClient modelClient); + /// /// To test special tags To test special tags and operation ID starting with number /// @@ -240,13 +250,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/another-fake/dummy", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); - AfterCall123TestSpecialTags(apiResponseLocalVar, modelClient); + AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient); return apiResponseLocalVar; } @@ -254,7 +262,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorCall123TestSpecialTags(e, "/another-fake/dummy", uriBuilderLocalVar.Path, modelClient); + OnErrorCall123TestSpecialTagsDefaultImplementation(e, "/another-fake/dummy", uriBuilderLocalVar.Path, modelClient); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs index 4fd131b66e8..0883057e578 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -162,33 +162,41 @@ namespace Org.OpenAPITools.Api } /// - /// Logs the api response + /// Processes the server response /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) + /// + private void AfterFooGetDefaultImplementation(ApiResponse apiResponseLocalVar) { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFooGet(apiResponseLocalVar); } /// /// Processes the server response /// /// - protected virtual void AfterFooGet(ApiResponse apiResponseLocalVar) - { - } + partial void AfterFooGet(ApiResponse apiResponseLocalVar); /// - /// Processes the server response + /// Logs exceptions that occur while retrieving the server response /// /// /// /// - protected virtual void OnErrorFooGet(Exception exception, string pathFormat, string path) + private void OnErrorFooGetDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFooGet(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorFooGet(Exception exception, string pathFormat, string path); + /// /// /// @@ -242,13 +250,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/foo", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); - AfterFooGet(apiResponseLocalVar); + AfterFooGetDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -256,7 +262,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFooGet(e, "/foo", uriBuilderLocalVar.Path); + OnErrorFooGetDefaultImplementation(e, "/foo", uriBuilderLocalVar.Path); throw; } } @@ -285,22 +291,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterGetCountry(ApiResponse apiResponseLocalVar, string country) + private void AfterGetCountryDefaultImplementation(ApiResponse apiResponseLocalVar, string country) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetCountry(apiResponseLocalVar, country); } /// /// Processes the server response /// + /// + /// + partial void AfterGetCountry(ApiResponse apiResponseLocalVar, string country); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorGetCountry(Exception exception, string pathFormat, string path, string country) + private void OnErrorGetCountryDefaultImplementation(Exception exception, string pathFormat, string path, string country) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetCountry(exception, pathFormat, path, country); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetCountry(Exception exception, string pathFormat, string path, string country); + /// /// /// @@ -370,13 +395,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/country", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetCountry(apiResponseLocalVar, country); + AfterGetCountryDefaultImplementation(apiResponseLocalVar, country); return apiResponseLocalVar; } @@ -384,7 +407,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetCountry(e, "/country", uriBuilderLocalVar.Path, country); + OnErrorGetCountryDefaultImplementation(e, "/country", uriBuilderLocalVar.Path, country); throw; } } @@ -393,21 +416,38 @@ namespace Org.OpenAPITools.Api /// Processes the server response /// /// - protected virtual void AfterHello(ApiResponse> apiResponseLocalVar) + private void AfterHelloDefaultImplementation(ApiResponse> apiResponseLocalVar) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterHello(apiResponseLocalVar); } /// /// Processes the server response /// + /// + partial void AfterHello(ApiResponse> apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// - protected virtual void OnErrorHello(Exception exception, string pathFormat, string path) + private void OnErrorHelloDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorHello(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorHello(Exception exception, string pathFormat, string path); + /// /// Hello Hello /// @@ -461,13 +501,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/hello", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); - AfterHello(apiResponseLocalVar); + AfterHelloDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -475,7 +513,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorHello(e, "/hello", uriBuilderLocalVar.Path); + OnErrorHelloDefaultImplementation(e, "/hello", uriBuilderLocalVar.Path); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeApi.cs index d9e57e7ac43..8ad80b8b91e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeApi.cs @@ -502,33 +502,41 @@ namespace Org.OpenAPITools.Api } /// - /// Logs the api response + /// Processes the server response /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) + /// + private void AfterFakeHealthGetDefaultImplementation(ApiResponse apiResponseLocalVar) { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeHealthGet(apiResponseLocalVar); } /// /// Processes the server response /// /// - protected virtual void AfterFakeHealthGet(ApiResponse apiResponseLocalVar) - { - } + partial void AfterFakeHealthGet(ApiResponse apiResponseLocalVar); /// - /// Processes the server response + /// Logs exceptions that occur while retrieving the server response /// /// /// /// - protected virtual void OnErrorFakeHealthGet(Exception exception, string pathFormat, string path) + private void OnErrorFakeHealthGetDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeHealthGet(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorFakeHealthGet(Exception exception, string pathFormat, string path); + /// /// Health check endpoint /// @@ -582,13 +590,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/health", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeHealthGet(apiResponseLocalVar); + AfterFakeHealthGetDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -596,7 +602,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeHealthGet(e, "/fake/health", uriBuilderLocalVar.Path); + OnErrorFakeHealthGetDefaultImplementation(e, "/fake/health", uriBuilderLocalVar.Path); throw; } } @@ -608,22 +614,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFakeOuterBooleanSerialize(ApiResponse apiResponseLocalVar, bool? body) + private void AfterFakeOuterBooleanSerializeDefaultImplementation(ApiResponse apiResponseLocalVar, bool? body) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeOuterBooleanSerialize(apiResponseLocalVar, body); } /// /// Processes the server response /// + /// + /// + partial void AfterFakeOuterBooleanSerialize(ApiResponse apiResponseLocalVar, bool? body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFakeOuterBooleanSerialize(Exception exception, string pathFormat, string path, bool? body) + private void OnErrorFakeOuterBooleanSerializeDefaultImplementation(Exception exception, string pathFormat, string path, bool? body) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeOuterBooleanSerialize(exception, pathFormat, path, body); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterBooleanSerialize(Exception exception, string pathFormat, string path, bool? body); + /// /// Test serialization of outer boolean types /// @@ -694,13 +719,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/outer/boolean", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeOuterBooleanSerialize(apiResponseLocalVar, body); + AfterFakeOuterBooleanSerializeDefaultImplementation(apiResponseLocalVar, body); return apiResponseLocalVar; } @@ -708,7 +731,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeOuterBooleanSerialize(e, "/fake/outer/boolean", uriBuilderLocalVar.Path, body); + OnErrorFakeOuterBooleanSerializeDefaultImplementation(e, "/fake/outer/boolean", uriBuilderLocalVar.Path, body); throw; } } @@ -720,22 +743,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFakeOuterCompositeSerialize(ApiResponse apiResponseLocalVar, OuterComposite? outerComposite) + private void AfterFakeOuterCompositeSerializeDefaultImplementation(ApiResponse apiResponseLocalVar, OuterComposite? outerComposite) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeOuterCompositeSerialize(apiResponseLocalVar, outerComposite); } /// /// Processes the server response /// + /// + /// + partial void AfterFakeOuterCompositeSerialize(ApiResponse apiResponseLocalVar, OuterComposite? outerComposite); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFakeOuterCompositeSerialize(Exception exception, string pathFormat, string path, OuterComposite? outerComposite) + private void OnErrorFakeOuterCompositeSerializeDefaultImplementation(Exception exception, string pathFormat, string path, OuterComposite? outerComposite) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeOuterCompositeSerialize(exception, pathFormat, path, outerComposite); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterCompositeSerialize(Exception exception, string pathFormat, string path, OuterComposite? outerComposite); + /// /// Test serialization of object with outer number type /// @@ -806,13 +848,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/outer/composite", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeOuterCompositeSerialize(apiResponseLocalVar, outerComposite); + AfterFakeOuterCompositeSerializeDefaultImplementation(apiResponseLocalVar, outerComposite); return apiResponseLocalVar; } @@ -820,7 +860,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeOuterCompositeSerialize(e, "/fake/outer/composite", uriBuilderLocalVar.Path, outerComposite); + OnErrorFakeOuterCompositeSerializeDefaultImplementation(e, "/fake/outer/composite", uriBuilderLocalVar.Path, outerComposite); throw; } } @@ -832,22 +872,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFakeOuterNumberSerialize(ApiResponse apiResponseLocalVar, decimal? body) + private void AfterFakeOuterNumberSerializeDefaultImplementation(ApiResponse apiResponseLocalVar, decimal? body) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeOuterNumberSerialize(apiResponseLocalVar, body); } /// /// Processes the server response /// + /// + /// + partial void AfterFakeOuterNumberSerialize(ApiResponse apiResponseLocalVar, decimal? body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFakeOuterNumberSerialize(Exception exception, string pathFormat, string path, decimal? body) + private void OnErrorFakeOuterNumberSerializeDefaultImplementation(Exception exception, string pathFormat, string path, decimal? body) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeOuterNumberSerialize(exception, pathFormat, path, body); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterNumberSerialize(Exception exception, string pathFormat, string path, decimal? body); + /// /// Test serialization of outer number types /// @@ -918,13 +977,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/outer/number", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeOuterNumberSerialize(apiResponseLocalVar, body); + AfterFakeOuterNumberSerializeDefaultImplementation(apiResponseLocalVar, body); return apiResponseLocalVar; } @@ -932,7 +989,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeOuterNumberSerialize(e, "/fake/outer/number", uriBuilderLocalVar.Path, body); + OnErrorFakeOuterNumberSerializeDefaultImplementation(e, "/fake/outer/number", uriBuilderLocalVar.Path, body); throw; } } @@ -962,23 +1019,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFakeOuterStringSerialize(ApiResponse apiResponseLocalVar, Guid requiredStringUuid, string? body) + private void AfterFakeOuterStringSerializeDefaultImplementation(ApiResponse apiResponseLocalVar, Guid requiredStringUuid, string? body) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeOuterStringSerialize(apiResponseLocalVar, requiredStringUuid, body); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterFakeOuterStringSerialize(ApiResponse apiResponseLocalVar, Guid requiredStringUuid, string? body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorFakeOuterStringSerialize(Exception exception, string pathFormat, string path, Guid requiredStringUuid, string? body) + private void OnErrorFakeOuterStringSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Guid requiredStringUuid, string? body) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeOuterStringSerialize(exception, pathFormat, path, requiredStringUuid, body); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterStringSerialize(Exception exception, string pathFormat, string path, Guid requiredStringUuid, string? body); + /// /// Test serialization of outer string types /// @@ -1059,13 +1137,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/outer/string", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeOuterStringSerialize(apiResponseLocalVar, requiredStringUuid, body); + AfterFakeOuterStringSerializeDefaultImplementation(apiResponseLocalVar, requiredStringUuid, body); return apiResponseLocalVar; } @@ -1073,7 +1149,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeOuterStringSerialize(e, "/fake/outer/string", uriBuilderLocalVar.Path, requiredStringUuid, body); + OnErrorFakeOuterStringSerializeDefaultImplementation(e, "/fake/outer/string", uriBuilderLocalVar.Path, requiredStringUuid, body); throw; } } @@ -1082,21 +1158,38 @@ namespace Org.OpenAPITools.Api /// Processes the server response /// /// - protected virtual void AfterGetArrayOfEnums(ApiResponse> apiResponseLocalVar) + private void AfterGetArrayOfEnumsDefaultImplementation(ApiResponse> apiResponseLocalVar) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetArrayOfEnums(apiResponseLocalVar); } /// /// Processes the server response /// + /// + partial void AfterGetArrayOfEnums(ApiResponse> apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// - protected virtual void OnErrorGetArrayOfEnums(Exception exception, string pathFormat, string path) + private void OnErrorGetArrayOfEnumsDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetArrayOfEnums(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorGetArrayOfEnums(Exception exception, string pathFormat, string path); + /// /// Array of Enums /// @@ -1150,13 +1243,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/array-of-enums", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetArrayOfEnums(apiResponseLocalVar); + AfterGetArrayOfEnumsDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -1164,7 +1255,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetArrayOfEnums(e, "/fake/array-of-enums", uriBuilderLocalVar.Path); + OnErrorGetArrayOfEnumsDefaultImplementation(e, "/fake/array-of-enums", uriBuilderLocalVar.Path); throw; } } @@ -1193,22 +1284,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestBodyWithFileSchema(ApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass) + private void AfterTestBodyWithFileSchemaDefaultImplementation(ApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestBodyWithFileSchema(apiResponseLocalVar, fileSchemaTestClass); } /// /// Processes the server response /// + /// + /// + partial void AfterTestBodyWithFileSchema(ApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorTestBodyWithFileSchema(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass) + private void OnErrorTestBodyWithFileSchemaDefaultImplementation(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestBodyWithFileSchema(exception, pathFormat, path, fileSchemaTestClass); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTestBodyWithFileSchema(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass); + /// /// For this test, the body for this request much reference a schema named `File`. /// @@ -1272,13 +1382,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/body-with-file-schema", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestBodyWithFileSchema(apiResponseLocalVar, fileSchemaTestClass); + AfterTestBodyWithFileSchemaDefaultImplementation(apiResponseLocalVar, fileSchemaTestClass); return apiResponseLocalVar; } @@ -1286,7 +1394,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestBodyWithFileSchema(e, "/fake/body-with-file-schema", uriBuilderLocalVar.Path, fileSchemaTestClass); + OnErrorTestBodyWithFileSchemaDefaultImplementation(e, "/fake/body-with-file-schema", uriBuilderLocalVar.Path, fileSchemaTestClass); throw; } } @@ -1320,23 +1428,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestBodyWithQueryParams(ApiResponse apiResponseLocalVar, User user, string query) + private void AfterTestBodyWithQueryParamsDefaultImplementation(ApiResponse apiResponseLocalVar, User user, string query) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestBodyWithQueryParams(apiResponseLocalVar, user, query); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterTestBodyWithQueryParams(ApiResponse apiResponseLocalVar, User user, string query); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorTestBodyWithQueryParams(Exception exception, string pathFormat, string path, User user, string query) + private void OnErrorTestBodyWithQueryParamsDefaultImplementation(Exception exception, string pathFormat, string path, User user, string query) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestBodyWithQueryParams(exception, pathFormat, path, user, query); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestBodyWithQueryParams(Exception exception, string pathFormat, string path, User user, string query); + /// /// /// @@ -1408,13 +1537,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/body-with-query-params", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestBodyWithQueryParams(apiResponseLocalVar, user, query); + AfterTestBodyWithQueryParamsDefaultImplementation(apiResponseLocalVar, user, query); return apiResponseLocalVar; } @@ -1422,7 +1549,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestBodyWithQueryParams(e, "/fake/body-with-query-params", uriBuilderLocalVar.Path, user, query); + OnErrorTestBodyWithQueryParamsDefaultImplementation(e, "/fake/body-with-query-params", uriBuilderLocalVar.Path, user, query); throw; } } @@ -1451,22 +1578,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestClientModel(ApiResponse apiResponseLocalVar, ModelClient modelClient) + private void AfterTestClientModelDefaultImplementation(ApiResponse apiResponseLocalVar, ModelClient modelClient) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestClientModel(apiResponseLocalVar, modelClient); } /// /// Processes the server response /// + /// + /// + partial void AfterTestClientModel(ApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorTestClientModel(Exception exception, string pathFormat, string path, ModelClient modelClient) + private void OnErrorTestClientModelDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestClientModel(exception, pathFormat, path, modelClient); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTestClientModel(Exception exception, string pathFormat, string path, ModelClient modelClient); + /// /// To test \"client\" model To test \"client\" model /// @@ -1539,13 +1685,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestClientModel(apiResponseLocalVar, modelClient); + AfterTestClientModelDefaultImplementation(apiResponseLocalVar, modelClient); return apiResponseLocalVar; } @@ -1553,7 +1697,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestClientModel(e, "/fake", uriBuilderLocalVar.Path, modelClient); + OnErrorTestClientModelDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, modelClient); throw; } } @@ -1607,13 +1751,35 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestEndpointParameters(ApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream? binary, float? varFloat, int? integer, int? int32, long? int64, string? varString, string? password, string? callback, DateTime? dateTime) + private void AfterTestEndpointParametersDefaultImplementation(ApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream? binary, float? varFloat, int? integer, int? int32, long? int64, string? varString, string? password, string? callback, DateTime? dateTime) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestEndpointParameters(apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); } /// /// Processes the server response /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestEndpointParameters(ApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream? binary, float? varFloat, int? integer, int? int32, long? int64, string? varString, string? password, string? callback, DateTime? dateTime); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// @@ -1631,11 +1797,34 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void OnErrorTestEndpointParameters(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream? binary, float? varFloat, int? integer, int? int32, long? int64, string? varString, string? password, string? callback, DateTime? dateTime) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream? binary, float? varFloat, int? integer, int? int32, long? int64, string? varString, string? password, string? callback, DateTime? dateTime) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestEndpointParameters(exception, pathFormat, path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestEndpointParameters(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream? binary, float? varFloat, int? integer, int? int32, long? int64, string? varString, string? password, string? callback, DateTime? dateTime); + /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 /// @@ -1775,13 +1964,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestEndpointParameters(apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + AfterTestEndpointParametersDefaultImplementation(apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1793,7 +1980,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestEndpointParameters(e, "/fake", uriBuilderLocalVar.Path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + OnErrorTestEndpointParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); throw; } } @@ -1812,13 +1999,29 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestEnumParameters(ApiResponse apiResponseLocalVar, List? enumHeaderStringArray, List? enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List? enumFormStringArray, string? enumHeaderString, string? enumQueryString, string? enumFormString) + private void AfterTestEnumParametersDefaultImplementation(ApiResponse apiResponseLocalVar, List? enumHeaderStringArray, List? enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List? enumFormStringArray, string? enumHeaderString, string? enumQueryString, string? enumFormString) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestEnumParameters(apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); } /// /// Processes the server response /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestEnumParameters(ApiResponse apiResponseLocalVar, List? enumHeaderStringArray, List? enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List? enumFormStringArray, string? enumHeaderString, string? enumQueryString, string? enumFormString); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// @@ -1830,11 +2033,28 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void OnErrorTestEnumParameters(Exception exception, string pathFormat, string path, List? enumHeaderStringArray, List? enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List? enumFormStringArray, string? enumHeaderString, string? enumQueryString, string? enumFormString) + private void OnErrorTestEnumParametersDefaultImplementation(Exception exception, string pathFormat, string path, List? enumHeaderStringArray, List? enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List? enumFormStringArray, string? enumHeaderString, string? enumQueryString, string? enumFormString) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestEnumParameters(exception, pathFormat, path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestEnumParameters(Exception exception, string pathFormat, string path, List? enumHeaderStringArray, List? enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List? enumFormStringArray, string? enumHeaderString, string? enumQueryString, string? enumFormString); + /// /// To test enum parameters To test enum parameters /// @@ -1940,13 +2160,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestEnumParameters(apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + AfterTestEnumParametersDefaultImplementation(apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); return apiResponseLocalVar; } @@ -1954,7 +2172,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestEnumParameters(e, "/fake", uriBuilderLocalVar.Path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + OnErrorTestEnumParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); throw; } } @@ -1996,13 +2214,27 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestGroupParameters(ApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group) + private void AfterTestGroupParametersDefaultImplementation(ApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestGroupParameters(apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); } /// /// Processes the server response /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestGroupParameters(ApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// @@ -2012,11 +2244,26 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void OnErrorTestGroupParameters(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group) + private void OnErrorTestGroupParametersDefaultImplementation(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestGroupParameters(exception, pathFormat, path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestGroupParameters(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group); + /// /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) /// @@ -2103,13 +2350,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestGroupParameters(apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + AfterTestGroupParametersDefaultImplementation(apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -2121,7 +2366,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestGroupParameters(e, "/fake", uriBuilderLocalVar.Path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + OnErrorTestGroupParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); throw; } } @@ -2150,22 +2395,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestInlineAdditionalProperties(ApiResponse apiResponseLocalVar, Dictionary requestBody) + private void AfterTestInlineAdditionalPropertiesDefaultImplementation(ApiResponse apiResponseLocalVar, Dictionary requestBody) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestInlineAdditionalProperties(apiResponseLocalVar, requestBody); } /// /// Processes the server response /// + /// + /// + partial void AfterTestInlineAdditionalProperties(ApiResponse apiResponseLocalVar, Dictionary requestBody); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorTestInlineAdditionalProperties(Exception exception, string pathFormat, string path, Dictionary requestBody) + private void OnErrorTestInlineAdditionalPropertiesDefaultImplementation(Exception exception, string pathFormat, string path, Dictionary requestBody) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestInlineAdditionalProperties(exception, pathFormat, path, requestBody); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTestInlineAdditionalProperties(Exception exception, string pathFormat, string path, Dictionary requestBody); + /// /// test inline additionalProperties /// @@ -2229,13 +2493,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestInlineAdditionalProperties(apiResponseLocalVar, requestBody); + AfterTestInlineAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, requestBody); return apiResponseLocalVar; } @@ -2243,7 +2505,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestInlineAdditionalProperties(e, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path, requestBody); + OnErrorTestInlineAdditionalPropertiesDefaultImplementation(e, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path, requestBody); throw; } } @@ -2277,23 +2539,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestJsonFormData(ApiResponse apiResponseLocalVar, string param, string param2) + private void AfterTestJsonFormDataDefaultImplementation(ApiResponse apiResponseLocalVar, string param, string param2) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestJsonFormData(apiResponseLocalVar, param, param2); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterTestJsonFormData(ApiResponse apiResponseLocalVar, string param, string param2); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorTestJsonFormData(Exception exception, string pathFormat, string path, string param, string param2) + private void OnErrorTestJsonFormDataDefaultImplementation(Exception exception, string pathFormat, string path, string param, string param2) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestJsonFormData(exception, pathFormat, path, param, param2); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestJsonFormData(Exception exception, string pathFormat, string path, string param, string param2); + /// /// test json serialization of form data /// @@ -2367,13 +2650,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/jsonFormData", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestJsonFormData(apiResponseLocalVar, param, param2); + AfterTestJsonFormDataDefaultImplementation(apiResponseLocalVar, param, param2); return apiResponseLocalVar; } @@ -2381,7 +2662,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestJsonFormData(e, "/fake/jsonFormData", uriBuilderLocalVar.Path, param, param2); + OnErrorTestJsonFormDataDefaultImplementation(e, "/fake/jsonFormData", uriBuilderLocalVar.Path, param, param2); throw; } } @@ -2430,13 +2711,26 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestQueryParameterCollectionFormat(ApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context) + private void AfterTestQueryParameterCollectionFormatDefaultImplementation(ApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestQueryParameterCollectionFormat(apiResponseLocalVar, pipe, ioutil, http, url, context); } /// /// Processes the server response /// + /// + /// + /// + /// + /// + /// + partial void AfterTestQueryParameterCollectionFormat(ApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// @@ -2445,11 +2739,25 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void OnErrorTestQueryParameterCollectionFormat(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context) + private void OnErrorTestQueryParameterCollectionFormatDefaultImplementation(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestQueryParameterCollectionFormat(exception, pathFormat, path, pipe, ioutil, http, url, context); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestQueryParameterCollectionFormat(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context); + /// /// To test the collection format in query parameters /// @@ -2518,13 +2826,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/test-query-parameters", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestQueryParameterCollectionFormat(apiResponseLocalVar, pipe, ioutil, http, url, context); + AfterTestQueryParameterCollectionFormatDefaultImplementation(apiResponseLocalVar, pipe, ioutil, http, url, context); return apiResponseLocalVar; } @@ -2532,7 +2838,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestQueryParameterCollectionFormat(e, "/fake/test-query-parameters", uriBuilderLocalVar.Path, pipe, ioutil, http, url, context); + OnErrorTestQueryParameterCollectionFormatDefaultImplementation(e, "/fake/test-query-parameters", uriBuilderLocalVar.Path, pipe, ioutil, http, url, context); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 4234b57d9c2..0ad66d893cc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -119,15 +119,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatTestClassname(ModelClient modelClient); /// @@ -152,22 +143,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestClassname(ApiResponse apiResponseLocalVar, ModelClient modelClient) + private void AfterTestClassnameDefaultImplementation(ApiResponse apiResponseLocalVar, ModelClient modelClient) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestClassname(apiResponseLocalVar, modelClient); } /// /// Processes the server response /// + /// + /// + partial void AfterTestClassname(ApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorTestClassname(Exception exception, string pathFormat, string path, ModelClient modelClient) + private void OnErrorTestClassnameDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestClassname(exception, pathFormat, path, modelClient); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTestClassname(Exception exception, string pathFormat, string path, ModelClient modelClient); + /// /// To test class name in snake case To test class name in snake case /// @@ -251,13 +261,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake_classname_test", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestClassname(apiResponseLocalVar, modelClient); + AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -269,7 +277,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestClassname(e, "/fake_classname_test", uriBuilderLocalVar.Path, modelClient); + OnErrorTestClassnameDefaultImplementation(e, "/fake_classname_test", uriBuilderLocalVar.Path, modelClient); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/PetApi.cs index 49cb0f71980..c25400b3f96 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/PetApi.cs @@ -317,15 +317,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatAddPet(Pet pet); /// @@ -350,22 +341,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterAddPet(ApiResponse apiResponseLocalVar, Pet pet) + private void AfterAddPetDefaultImplementation(ApiResponse apiResponseLocalVar, Pet pet) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterAddPet(apiResponseLocalVar, pet); } /// /// Processes the server response /// + /// + /// + partial void AfterAddPet(ApiResponse apiResponseLocalVar, Pet pet); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorAddPet(Exception exception, string pathFormat, string path, Pet pet) + private void OnErrorAddPetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorAddPet(exception, pathFormat, path, pet); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorAddPet(Exception exception, string pathFormat, string path, Pet pet); + /// /// Add a new pet to the store /// @@ -446,13 +456,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); - AfterAddPet(apiResponseLocalVar, pet); + AfterAddPetDefaultImplementation(apiResponseLocalVar, pet); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -468,7 +476,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorAddPet(e, "/pet", uriBuilderLocalVar.Path, pet); + OnErrorAddPetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); throw; } } @@ -498,23 +506,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterDeletePet(ApiResponse apiResponseLocalVar, long petId, string? apiKey) + private void AfterDeletePetDefaultImplementation(ApiResponse apiResponseLocalVar, long petId, string? apiKey) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterDeletePet(apiResponseLocalVar, petId, apiKey); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterDeletePet(ApiResponse apiResponseLocalVar, long petId, string? apiKey); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorDeletePet(Exception exception, string pathFormat, string path, long petId, string? apiKey) + private void OnErrorDeletePetDefaultImplementation(Exception exception, string pathFormat, string path, long petId, string? apiKey) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorDeletePet(exception, pathFormat, path, petId, apiKey); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorDeletePet(Exception exception, string pathFormat, string path, long petId, string? apiKey); + /// /// Deletes a pet /// @@ -579,13 +608,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/{petId}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); - AfterDeletePet(apiResponseLocalVar, petId, apiKey); + AfterDeletePetDefaultImplementation(apiResponseLocalVar, petId, apiKey); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -597,7 +624,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorDeletePet(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, apiKey); + OnErrorDeletePetDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, apiKey); throw; } } @@ -626,22 +653,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFindPetsByStatus(ApiResponse> apiResponseLocalVar, List status) + private void AfterFindPetsByStatusDefaultImplementation(ApiResponse> apiResponseLocalVar, List status) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFindPetsByStatus(apiResponseLocalVar, status); } /// /// Processes the server response /// + /// + /// + partial void AfterFindPetsByStatus(ApiResponse> apiResponseLocalVar, List status); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFindPetsByStatus(Exception exception, string pathFormat, string path, List status) + private void OnErrorFindPetsByStatusDefaultImplementation(Exception exception, string pathFormat, string path, List status) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFindPetsByStatus(exception, pathFormat, path, status); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFindPetsByStatus(Exception exception, string pathFormat, string path, List status); + /// /// Finds Pets by status Multiple status values can be provided with comma separated strings /// @@ -724,13 +770,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/findByStatus", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); - AfterFindPetsByStatus(apiResponseLocalVar, status); + AfterFindPetsByStatusDefaultImplementation(apiResponseLocalVar, status); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -746,7 +790,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFindPetsByStatus(e, "/pet/findByStatus", uriBuilderLocalVar.Path, status); + OnErrorFindPetsByStatusDefaultImplementation(e, "/pet/findByStatus", uriBuilderLocalVar.Path, status); throw; } } @@ -775,22 +819,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFindPetsByTags(ApiResponse> apiResponseLocalVar, List tags) + private void AfterFindPetsByTagsDefaultImplementation(ApiResponse> apiResponseLocalVar, List tags) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFindPetsByTags(apiResponseLocalVar, tags); } /// /// Processes the server response /// + /// + /// + partial void AfterFindPetsByTags(ApiResponse> apiResponseLocalVar, List tags); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFindPetsByTags(Exception exception, string pathFormat, string path, List tags) + private void OnErrorFindPetsByTagsDefaultImplementation(Exception exception, string pathFormat, string path, List tags) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFindPetsByTags(exception, pathFormat, path, tags); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFindPetsByTags(Exception exception, string pathFormat, string path, List tags); + /// /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// @@ -873,13 +936,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/findByTags", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); - AfterFindPetsByTags(apiResponseLocalVar, tags); + AfterFindPetsByTagsDefaultImplementation(apiResponseLocalVar, tags); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -895,7 +956,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFindPetsByTags(e, "/pet/findByTags", uriBuilderLocalVar.Path, tags); + OnErrorFindPetsByTagsDefaultImplementation(e, "/pet/findByTags", uriBuilderLocalVar.Path, tags); throw; } } @@ -924,22 +985,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterGetPetById(ApiResponse apiResponseLocalVar, long petId) + private void AfterGetPetByIdDefaultImplementation(ApiResponse apiResponseLocalVar, long petId) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetPetById(apiResponseLocalVar, petId); } /// /// Processes the server response /// + /// + /// + partial void AfterGetPetById(ApiResponse apiResponseLocalVar, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorGetPetById(Exception exception, string pathFormat, string path, long petId) + private void OnErrorGetPetByIdDefaultImplementation(Exception exception, string pathFormat, string path, long petId) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetPetById(exception, pathFormat, path, petId); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetPetById(Exception exception, string pathFormat, string path, long petId); + /// /// Find pet by ID Returns a single pet /// @@ -1009,13 +1089,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/{petId}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetPetById(apiResponseLocalVar, petId); + AfterGetPetByIdDefaultImplementation(apiResponseLocalVar, petId); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1027,7 +1105,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetPetById(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId); + OnErrorGetPetByIdDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId); throw; } } @@ -1056,22 +1134,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUpdatePet(ApiResponse apiResponseLocalVar, Pet pet) + private void AfterUpdatePetDefaultImplementation(ApiResponse apiResponseLocalVar, Pet pet) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUpdatePet(apiResponseLocalVar, pet); } /// /// Processes the server response /// + /// + /// + partial void AfterUpdatePet(ApiResponse apiResponseLocalVar, Pet pet); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorUpdatePet(Exception exception, string pathFormat, string path, Pet pet) + private void OnErrorUpdatePetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUpdatePet(exception, pathFormat, path, pet); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorUpdatePet(Exception exception, string pathFormat, string path, Pet pet); + /// /// Update an existing pet /// @@ -1152,13 +1249,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); - AfterUpdatePet(apiResponseLocalVar, pet); + AfterUpdatePetDefaultImplementation(apiResponseLocalVar, pet); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1174,7 +1269,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUpdatePet(e, "/pet", uriBuilderLocalVar.Path, pet); + OnErrorUpdatePetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); throw; } } @@ -1205,24 +1300,47 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUpdatePetWithForm(ApiResponse apiResponseLocalVar, long petId, string? name, string? status) + private void AfterUpdatePetWithFormDefaultImplementation(ApiResponse apiResponseLocalVar, long petId, string? name, string? status) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUpdatePetWithForm(apiResponseLocalVar, petId, name, status); } /// /// Processes the server response /// + /// + /// + /// + /// + partial void AfterUpdatePetWithForm(ApiResponse apiResponseLocalVar, long petId, string? name, string? status); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// /// - protected virtual void OnErrorUpdatePetWithForm(Exception exception, string pathFormat, string path, long petId, string? name, string? status) + private void OnErrorUpdatePetWithFormDefaultImplementation(Exception exception, string pathFormat, string path, long petId, string? name, string? status) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUpdatePetWithForm(exception, pathFormat, path, petId, name, status); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUpdatePetWithForm(Exception exception, string pathFormat, string path, long petId, string? name, string? status); + /// /// Updates a pet in the store with form data /// @@ -1307,13 +1425,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/{petId}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); - AfterUpdatePetWithForm(apiResponseLocalVar, petId, name, status); + AfterUpdatePetWithFormDefaultImplementation(apiResponseLocalVar, petId, name, status); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1325,7 +1441,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUpdatePetWithForm(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, name, status); + OnErrorUpdatePetWithFormDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, name, status); throw; } } @@ -1356,24 +1472,47 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUploadFile(ApiResponse apiResponseLocalVar, long petId, System.IO.Stream? file, string? additionalMetadata) + private void AfterUploadFileDefaultImplementation(ApiResponse apiResponseLocalVar, long petId, System.IO.Stream? file, string? additionalMetadata) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUploadFile(apiResponseLocalVar, petId, file, additionalMetadata); } /// /// Processes the server response /// + /// + /// + /// + /// + partial void AfterUploadFile(ApiResponse apiResponseLocalVar, long petId, System.IO.Stream? file, string? additionalMetadata); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// /// - protected virtual void OnErrorUploadFile(Exception exception, string pathFormat, string path, long petId, System.IO.Stream? file, string? additionalMetadata) + private void OnErrorUploadFileDefaultImplementation(Exception exception, string pathFormat, string path, long petId, System.IO.Stream? file, string? additionalMetadata) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUploadFile(exception, pathFormat, path, petId, file, additionalMetadata); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFile(Exception exception, string pathFormat, string path, long petId, System.IO.Stream? file, string? additionalMetadata); + /// /// uploads an image /// @@ -1467,13 +1606,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); - AfterUploadFile(apiResponseLocalVar, petId, file, additionalMetadata); + AfterUploadFileDefaultImplementation(apiResponseLocalVar, petId, file, additionalMetadata); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1485,7 +1622,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUploadFile(e, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path, petId, file, additionalMetadata); + OnErrorUploadFileDefaultImplementation(e, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path, petId, file, additionalMetadata); throw; } } @@ -1520,24 +1657,47 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUploadFileWithRequiredFile(ApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, string? additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(ApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, string? additionalMetadata) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUploadFileWithRequiredFile(apiResponseLocalVar, requiredFile, petId, additionalMetadata); } /// /// Processes the server response /// + /// + /// + /// + /// + partial void AfterUploadFileWithRequiredFile(ApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, string? additionalMetadata); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// /// - protected virtual void OnErrorUploadFileWithRequiredFile(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, string? additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, string? additionalMetadata) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUploadFileWithRequiredFile(exception, pathFormat, path, requiredFile, petId, additionalMetadata); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFileWithRequiredFile(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, string? additionalMetadata); + /// /// uploads an image (required) /// @@ -1631,13 +1791,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); - AfterUploadFileWithRequiredFile(apiResponseLocalVar, requiredFile, petId, additionalMetadata); + AfterUploadFileWithRequiredFileDefaultImplementation(apiResponseLocalVar, requiredFile, petId, additionalMetadata); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1649,7 +1807,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUploadFileWithRequiredFile(e, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path, requiredFile, petId, additionalMetadata); + OnErrorUploadFileWithRequiredFileDefaultImplementation(e, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path, requiredFile, petId, additionalMetadata); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/StoreApi.cs index 87d37a755f9..e607da39b30 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/StoreApi.cs @@ -186,15 +186,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatDeleteOrder(ref string orderId); /// @@ -219,22 +210,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterDeleteOrder(ApiResponse apiResponseLocalVar, string orderId) + private void AfterDeleteOrderDefaultImplementation(ApiResponse apiResponseLocalVar, string orderId) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterDeleteOrder(apiResponseLocalVar, orderId); } /// /// Processes the server response /// + /// + /// + partial void AfterDeleteOrder(ApiResponse apiResponseLocalVar, string orderId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorDeleteOrder(Exception exception, string pathFormat, string path, string orderId) + private void OnErrorDeleteOrderDefaultImplementation(Exception exception, string pathFormat, string path, string orderId) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorDeleteOrder(exception, pathFormat, path, orderId); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorDeleteOrder(Exception exception, string pathFormat, string path, string orderId); + /// /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors /// @@ -286,13 +296,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/store/order/{order_id}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); - AfterDeleteOrder(apiResponseLocalVar, orderId); + AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId); return apiResponseLocalVar; } @@ -300,7 +308,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorDeleteOrder(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + OnErrorDeleteOrderDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); throw; } } @@ -309,21 +317,38 @@ namespace Org.OpenAPITools.Api /// Processes the server response /// /// - protected virtual void AfterGetInventory(ApiResponse> apiResponseLocalVar) + private void AfterGetInventoryDefaultImplementation(ApiResponse> apiResponseLocalVar) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetInventory(apiResponseLocalVar); } /// /// Processes the server response /// + /// + partial void AfterGetInventory(ApiResponse> apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// - protected virtual void OnErrorGetInventory(Exception exception, string pathFormat, string path) + private void OnErrorGetInventoryDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetInventory(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorGetInventory(Exception exception, string pathFormat, string path); + /// /// Returns pet inventories by status Returns a map of status codes to quantities /// @@ -385,13 +410,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/store/inventory", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetInventory(apiResponseLocalVar); + AfterGetInventoryDefaultImplementation(apiResponseLocalVar); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -403,7 +426,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetInventory(e, "/store/inventory", uriBuilderLocalVar.Path); + OnErrorGetInventoryDefaultImplementation(e, "/store/inventory", uriBuilderLocalVar.Path); throw; } } @@ -432,22 +455,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterGetOrderById(ApiResponse apiResponseLocalVar, long orderId) + private void AfterGetOrderByIdDefaultImplementation(ApiResponse apiResponseLocalVar, long orderId) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetOrderById(apiResponseLocalVar, orderId); } /// /// Processes the server response /// + /// + /// + partial void AfterGetOrderById(ApiResponse apiResponseLocalVar, long orderId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorGetOrderById(Exception exception, string pathFormat, string path, long orderId) + private void OnErrorGetOrderByIdDefaultImplementation(Exception exception, string pathFormat, string path, long orderId) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetOrderById(exception, pathFormat, path, orderId); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetOrderById(Exception exception, string pathFormat, string path, long orderId); + /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions /// @@ -509,13 +551,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/store/order/{order_id}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetOrderById(apiResponseLocalVar, orderId); + AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId); return apiResponseLocalVar; } @@ -523,7 +563,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetOrderById(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + OnErrorGetOrderByIdDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); throw; } } @@ -552,22 +592,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterPlaceOrder(ApiResponse apiResponseLocalVar, Order order) + private void AfterPlaceOrderDefaultImplementation(ApiResponse apiResponseLocalVar, Order order) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterPlaceOrder(apiResponseLocalVar, order); } /// /// Processes the server response /// + /// + /// + partial void AfterPlaceOrder(ApiResponse apiResponseLocalVar, Order order); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorPlaceOrder(Exception exception, string pathFormat, string path, Order order) + private void OnErrorPlaceOrderDefaultImplementation(Exception exception, string pathFormat, string path, Order order) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorPlaceOrder(exception, pathFormat, path, order); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorPlaceOrder(Exception exception, string pathFormat, string path, Order order); + /// /// Place an order for a pet /// @@ -641,13 +700,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/store/order", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); - AfterPlaceOrder(apiResponseLocalVar, order); + AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order); return apiResponseLocalVar; } @@ -655,7 +712,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorPlaceOrder(e, "/store/order", uriBuilderLocalVar.Path, order); + OnErrorPlaceOrderDefaultImplementation(e, "/store/order", uriBuilderLocalVar.Path, order); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/UserApi.cs index 4c5641d5e1e..987e066f482 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/UserApi.cs @@ -282,15 +282,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatCreateUser(User user); /// @@ -315,22 +306,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterCreateUser(ApiResponse apiResponseLocalVar, User user) + private void AfterCreateUserDefaultImplementation(ApiResponse apiResponseLocalVar, User user) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterCreateUser(apiResponseLocalVar, user); } /// /// Processes the server response /// + /// + /// + partial void AfterCreateUser(ApiResponse apiResponseLocalVar, User user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorCreateUser(Exception exception, string pathFormat, string path, User user) + private void OnErrorCreateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorCreateUser(exception, pathFormat, path, user); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorCreateUser(Exception exception, string pathFormat, string path, User user); + /// /// Create user This can only be done by the logged in user. /// @@ -394,13 +404,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); - AfterCreateUser(apiResponseLocalVar, user); + AfterCreateUserDefaultImplementation(apiResponseLocalVar, user); return apiResponseLocalVar; } @@ -408,7 +416,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorCreateUser(e, "/user", uriBuilderLocalVar.Path, user); + OnErrorCreateUserDefaultImplementation(e, "/user", uriBuilderLocalVar.Path, user); throw; } } @@ -437,22 +445,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterCreateUsersWithArrayInput(ApiResponse apiResponseLocalVar, List user) + private void AfterCreateUsersWithArrayInputDefaultImplementation(ApiResponse apiResponseLocalVar, List user) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterCreateUsersWithArrayInput(apiResponseLocalVar, user); } /// /// Processes the server response /// + /// + /// + partial void AfterCreateUsersWithArrayInput(ApiResponse apiResponseLocalVar, List user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorCreateUsersWithArrayInput(Exception exception, string pathFormat, string path, List user) + private void OnErrorCreateUsersWithArrayInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorCreateUsersWithArrayInput(exception, pathFormat, path, user); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorCreateUsersWithArrayInput(Exception exception, string pathFormat, string path, List user); + /// /// Creates list of users with given input array /// @@ -516,13 +543,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/createWithArray", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); - AfterCreateUsersWithArrayInput(apiResponseLocalVar, user); + AfterCreateUsersWithArrayInputDefaultImplementation(apiResponseLocalVar, user); return apiResponseLocalVar; } @@ -530,7 +555,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorCreateUsersWithArrayInput(e, "/user/createWithArray", uriBuilderLocalVar.Path, user); + OnErrorCreateUsersWithArrayInputDefaultImplementation(e, "/user/createWithArray", uriBuilderLocalVar.Path, user); throw; } } @@ -559,22 +584,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterCreateUsersWithListInput(ApiResponse apiResponseLocalVar, List user) + private void AfterCreateUsersWithListInputDefaultImplementation(ApiResponse apiResponseLocalVar, List user) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterCreateUsersWithListInput(apiResponseLocalVar, user); } /// /// Processes the server response /// + /// + /// + partial void AfterCreateUsersWithListInput(ApiResponse apiResponseLocalVar, List user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorCreateUsersWithListInput(Exception exception, string pathFormat, string path, List user) + private void OnErrorCreateUsersWithListInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorCreateUsersWithListInput(exception, pathFormat, path, user); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorCreateUsersWithListInput(Exception exception, string pathFormat, string path, List user); + /// /// Creates list of users with given input array /// @@ -638,13 +682,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/createWithList", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); - AfterCreateUsersWithListInput(apiResponseLocalVar, user); + AfterCreateUsersWithListInputDefaultImplementation(apiResponseLocalVar, user); return apiResponseLocalVar; } @@ -652,7 +694,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorCreateUsersWithListInput(e, "/user/createWithList", uriBuilderLocalVar.Path, user); + OnErrorCreateUsersWithListInputDefaultImplementation(e, "/user/createWithList", uriBuilderLocalVar.Path, user); throw; } } @@ -681,22 +723,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterDeleteUser(ApiResponse apiResponseLocalVar, string username) + private void AfterDeleteUserDefaultImplementation(ApiResponse apiResponseLocalVar, string username) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterDeleteUser(apiResponseLocalVar, username); } /// /// Processes the server response /// + /// + /// + partial void AfterDeleteUser(ApiResponse apiResponseLocalVar, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorDeleteUser(Exception exception, string pathFormat, string path, string username) + private void OnErrorDeleteUserDefaultImplementation(Exception exception, string pathFormat, string path, string username) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorDeleteUser(exception, pathFormat, path, username); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorDeleteUser(Exception exception, string pathFormat, string path, string username); + /// /// Delete user This can only be done by the logged in user. /// @@ -748,13 +809,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/{username}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); - AfterDeleteUser(apiResponseLocalVar, username); + AfterDeleteUserDefaultImplementation(apiResponseLocalVar, username); return apiResponseLocalVar; } @@ -762,7 +821,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorDeleteUser(e, "/user/{username}", uriBuilderLocalVar.Path, username); + OnErrorDeleteUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); throw; } } @@ -791,22 +850,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterGetUserByName(ApiResponse apiResponseLocalVar, string username) + private void AfterGetUserByNameDefaultImplementation(ApiResponse apiResponseLocalVar, string username) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetUserByName(apiResponseLocalVar, username); } /// /// Processes the server response /// + /// + /// + partial void AfterGetUserByName(ApiResponse apiResponseLocalVar, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorGetUserByName(Exception exception, string pathFormat, string path, string username) + private void OnErrorGetUserByNameDefaultImplementation(Exception exception, string pathFormat, string path, string username) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetUserByName(exception, pathFormat, path, username); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetUserByName(Exception exception, string pathFormat, string path, string username); + /// /// Get user by user name /// @@ -868,13 +946,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/{username}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetUserByName(apiResponseLocalVar, username); + AfterGetUserByNameDefaultImplementation(apiResponseLocalVar, username); return apiResponseLocalVar; } @@ -882,7 +958,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetUserByName(e, "/user/{username}", uriBuilderLocalVar.Path, username); + OnErrorGetUserByNameDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); throw; } } @@ -916,23 +992,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterLoginUser(ApiResponse apiResponseLocalVar, string username, string password) + private void AfterLoginUserDefaultImplementation(ApiResponse apiResponseLocalVar, string username, string password) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterLoginUser(apiResponseLocalVar, username, password); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterLoginUser(ApiResponse apiResponseLocalVar, string username, string password); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorLoginUser(Exception exception, string pathFormat, string path, string username, string password) + private void OnErrorLoginUserDefaultImplementation(Exception exception, string pathFormat, string path, string username, string password) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorLoginUser(exception, pathFormat, path, username, password); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorLoginUser(Exception exception, string pathFormat, string path, string username, string password); + /// /// Logs user into the system /// @@ -1002,13 +1099,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/login", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); - AfterLoginUser(apiResponseLocalVar, username, password); + AfterLoginUserDefaultImplementation(apiResponseLocalVar, username, password); return apiResponseLocalVar; } @@ -1016,7 +1111,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorLoginUser(e, "/user/login", uriBuilderLocalVar.Path, username, password); + OnErrorLoginUserDefaultImplementation(e, "/user/login", uriBuilderLocalVar.Path, username, password); throw; } } @@ -1025,21 +1120,38 @@ namespace Org.OpenAPITools.Api /// Processes the server response /// /// - protected virtual void AfterLogoutUser(ApiResponse apiResponseLocalVar) + private void AfterLogoutUserDefaultImplementation(ApiResponse apiResponseLocalVar) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterLogoutUser(apiResponseLocalVar); } /// /// Processes the server response /// + /// + partial void AfterLogoutUser(ApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// - protected virtual void OnErrorLogoutUser(Exception exception, string pathFormat, string path) + private void OnErrorLogoutUserDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorLogoutUser(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorLogoutUser(Exception exception, string pathFormat, string path); + /// /// Logs out current logged in user session /// @@ -1084,13 +1196,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/logout", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); - AfterLogoutUser(apiResponseLocalVar); + AfterLogoutUserDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -1098,7 +1208,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorLogoutUser(e, "/user/logout", uriBuilderLocalVar.Path); + OnErrorLogoutUserDefaultImplementation(e, "/user/logout", uriBuilderLocalVar.Path); throw; } } @@ -1132,23 +1242,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUpdateUser(ApiResponse apiResponseLocalVar, User user, string username) + private void AfterUpdateUserDefaultImplementation(ApiResponse apiResponseLocalVar, User user, string username) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUpdateUser(apiResponseLocalVar, user, username); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterUpdateUser(ApiResponse apiResponseLocalVar, User user, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorUpdateUser(Exception exception, string pathFormat, string path, User user, string username) + private void OnErrorUpdateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user, string username) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUpdateUser(exception, pathFormat, path, user, username); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorUpdateUser(Exception exception, string pathFormat, string path, User user, string username); + /// /// Updated user This can only be done by the logged in user. /// @@ -1215,13 +1346,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/{username}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); - AfterUpdateUser(apiResponseLocalVar, user, username); + AfterUpdateUserDefaultImplementation(apiResponseLocalVar, user, username); return apiResponseLocalVar; } @@ -1229,7 +1358,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUpdateUser(e, "/user/{username}", uriBuilderLocalVar.Path, user, username); + OnErrorUpdateUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, user, username); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 9f7c5fb6b41..078a1f82504 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -34,7 +34,7 @@ namespace Org.OpenAPITools.Client HttpStatusCode StatusCode { get; } /// - /// The raw content of this response + /// The raw content of this response. /// string RawContent { get; } @@ -42,6 +42,16 @@ namespace Org.OpenAPITools.Client /// The DateTime when the request was retrieved. /// DateTime DownloadedAt { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The Uri used when making the request. + /// + Uri? RequestUri { get; } } /// @@ -88,6 +98,21 @@ namespace Org.OpenAPITools.Client /// public DateTime DownloadedAt { get; } = DateTime.UtcNow; + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri? RequestUri { get; } + /// /// The JsonSerialzierOptions /// @@ -99,14 +124,19 @@ namespace Org.OpenAPITools.Client /// /// /// + /// + /// /// - public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) { StatusCode = httpResponseMessage.StatusCode; Headers = httpResponseMessage.Headers; IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; ReasonPhrase = httpResponseMessage.ReasonPhrase; RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; _jsonSerializerOptions = jsonSerializerOptions; OnCreated(httpRequestMessage, httpResponseMessage); } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index a25bc76a734..1fa678f2831 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -117,15 +117,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatCall123TestSpecialTags(ModelClient modelClient); /// @@ -150,22 +141,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterCall123TestSpecialTags(ApiResponse apiResponseLocalVar, ModelClient modelClient) + private void AfterCall123TestSpecialTagsDefaultImplementation(ApiResponse apiResponseLocalVar, ModelClient modelClient) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterCall123TestSpecialTags(apiResponseLocalVar, modelClient); } /// /// Processes the server response /// + /// + /// + partial void AfterCall123TestSpecialTags(ApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorCall123TestSpecialTags(Exception exception, string pathFormat, string path, ModelClient modelClient) + private void OnErrorCall123TestSpecialTagsDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorCall123TestSpecialTags(exception, pathFormat, path, modelClient); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorCall123TestSpecialTags(Exception exception, string pathFormat, string path, ModelClient modelClient); + /// /// To test special tags To test special tags and operation ID starting with number /// @@ -238,13 +248,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/another-fake/dummy", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); - AfterCall123TestSpecialTags(apiResponseLocalVar, modelClient); + AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient); return apiResponseLocalVar; } @@ -252,7 +260,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorCall123TestSpecialTags(e, "/another-fake/dummy", uriBuilderLocalVar.Path, modelClient); + OnErrorCall123TestSpecialTagsDefaultImplementation(e, "/another-fake/dummy", uriBuilderLocalVar.Path, modelClient); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs index dfb6cd8dcf9..de994fbaa13 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -160,33 +160,41 @@ namespace Org.OpenAPITools.Api } /// - /// Logs the api response + /// Processes the server response /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) + /// + private void AfterFooGetDefaultImplementation(ApiResponse apiResponseLocalVar) { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFooGet(apiResponseLocalVar); } /// /// Processes the server response /// /// - protected virtual void AfterFooGet(ApiResponse apiResponseLocalVar) - { - } + partial void AfterFooGet(ApiResponse apiResponseLocalVar); /// - /// Processes the server response + /// Logs exceptions that occur while retrieving the server response /// /// /// /// - protected virtual void OnErrorFooGet(Exception exception, string pathFormat, string path) + private void OnErrorFooGetDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFooGet(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorFooGet(Exception exception, string pathFormat, string path); + /// /// /// @@ -240,13 +248,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/foo", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); - AfterFooGet(apiResponseLocalVar); + AfterFooGetDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -254,7 +260,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFooGet(e, "/foo", uriBuilderLocalVar.Path); + OnErrorFooGetDefaultImplementation(e, "/foo", uriBuilderLocalVar.Path); throw; } } @@ -283,22 +289,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterGetCountry(ApiResponse apiResponseLocalVar, string country) + private void AfterGetCountryDefaultImplementation(ApiResponse apiResponseLocalVar, string country) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetCountry(apiResponseLocalVar, country); } /// /// Processes the server response /// + /// + /// + partial void AfterGetCountry(ApiResponse apiResponseLocalVar, string country); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorGetCountry(Exception exception, string pathFormat, string path, string country) + private void OnErrorGetCountryDefaultImplementation(Exception exception, string pathFormat, string path, string country) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetCountry(exception, pathFormat, path, country); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetCountry(Exception exception, string pathFormat, string path, string country); + /// /// /// @@ -368,13 +393,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/country", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetCountry(apiResponseLocalVar, country); + AfterGetCountryDefaultImplementation(apiResponseLocalVar, country); return apiResponseLocalVar; } @@ -382,7 +405,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetCountry(e, "/country", uriBuilderLocalVar.Path, country); + OnErrorGetCountryDefaultImplementation(e, "/country", uriBuilderLocalVar.Path, country); throw; } } @@ -391,21 +414,38 @@ namespace Org.OpenAPITools.Api /// Processes the server response /// /// - protected virtual void AfterHello(ApiResponse> apiResponseLocalVar) + private void AfterHelloDefaultImplementation(ApiResponse> apiResponseLocalVar) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterHello(apiResponseLocalVar); } /// /// Processes the server response /// + /// + partial void AfterHello(ApiResponse> apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// - protected virtual void OnErrorHello(Exception exception, string pathFormat, string path) + private void OnErrorHelloDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorHello(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorHello(Exception exception, string pathFormat, string path); + /// /// Hello Hello /// @@ -459,13 +499,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/hello", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); - AfterHello(apiResponseLocalVar); + AfterHelloDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -473,7 +511,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorHello(e, "/hello", uriBuilderLocalVar.Path); + OnErrorHelloDefaultImplementation(e, "/hello", uriBuilderLocalVar.Path); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeApi.cs index 3160c1b429b..ce1f614322d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeApi.cs @@ -500,33 +500,41 @@ namespace Org.OpenAPITools.Api } /// - /// Logs the api response + /// Processes the server response /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) + /// + private void AfterFakeHealthGetDefaultImplementation(ApiResponse apiResponseLocalVar) { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeHealthGet(apiResponseLocalVar); } /// /// Processes the server response /// /// - protected virtual void AfterFakeHealthGet(ApiResponse apiResponseLocalVar) - { - } + partial void AfterFakeHealthGet(ApiResponse apiResponseLocalVar); /// - /// Processes the server response + /// Logs exceptions that occur while retrieving the server response /// /// /// /// - protected virtual void OnErrorFakeHealthGet(Exception exception, string pathFormat, string path) + private void OnErrorFakeHealthGetDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeHealthGet(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorFakeHealthGet(Exception exception, string pathFormat, string path); + /// /// Health check endpoint /// @@ -580,13 +588,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/health", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeHealthGet(apiResponseLocalVar); + AfterFakeHealthGetDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -594,7 +600,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeHealthGet(e, "/fake/health", uriBuilderLocalVar.Path); + OnErrorFakeHealthGetDefaultImplementation(e, "/fake/health", uriBuilderLocalVar.Path); throw; } } @@ -606,22 +612,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFakeOuterBooleanSerialize(ApiResponse apiResponseLocalVar, bool? body) + private void AfterFakeOuterBooleanSerializeDefaultImplementation(ApiResponse apiResponseLocalVar, bool? body) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeOuterBooleanSerialize(apiResponseLocalVar, body); } /// /// Processes the server response /// + /// + /// + partial void AfterFakeOuterBooleanSerialize(ApiResponse apiResponseLocalVar, bool? body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFakeOuterBooleanSerialize(Exception exception, string pathFormat, string path, bool? body) + private void OnErrorFakeOuterBooleanSerializeDefaultImplementation(Exception exception, string pathFormat, string path, bool? body) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeOuterBooleanSerialize(exception, pathFormat, path, body); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterBooleanSerialize(Exception exception, string pathFormat, string path, bool? body); + /// /// Test serialization of outer boolean types /// @@ -692,13 +717,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/outer/boolean", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeOuterBooleanSerialize(apiResponseLocalVar, body); + AfterFakeOuterBooleanSerializeDefaultImplementation(apiResponseLocalVar, body); return apiResponseLocalVar; } @@ -706,7 +729,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeOuterBooleanSerialize(e, "/fake/outer/boolean", uriBuilderLocalVar.Path, body); + OnErrorFakeOuterBooleanSerializeDefaultImplementation(e, "/fake/outer/boolean", uriBuilderLocalVar.Path, body); throw; } } @@ -718,22 +741,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFakeOuterCompositeSerialize(ApiResponse apiResponseLocalVar, OuterComposite outerComposite) + private void AfterFakeOuterCompositeSerializeDefaultImplementation(ApiResponse apiResponseLocalVar, OuterComposite outerComposite) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeOuterCompositeSerialize(apiResponseLocalVar, outerComposite); } /// /// Processes the server response /// + /// + /// + partial void AfterFakeOuterCompositeSerialize(ApiResponse apiResponseLocalVar, OuterComposite outerComposite); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFakeOuterCompositeSerialize(Exception exception, string pathFormat, string path, OuterComposite outerComposite) + private void OnErrorFakeOuterCompositeSerializeDefaultImplementation(Exception exception, string pathFormat, string path, OuterComposite outerComposite) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeOuterCompositeSerialize(exception, pathFormat, path, outerComposite); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterCompositeSerialize(Exception exception, string pathFormat, string path, OuterComposite outerComposite); + /// /// Test serialization of object with outer number type /// @@ -804,13 +846,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/outer/composite", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeOuterCompositeSerialize(apiResponseLocalVar, outerComposite); + AfterFakeOuterCompositeSerializeDefaultImplementation(apiResponseLocalVar, outerComposite); return apiResponseLocalVar; } @@ -818,7 +858,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeOuterCompositeSerialize(e, "/fake/outer/composite", uriBuilderLocalVar.Path, outerComposite); + OnErrorFakeOuterCompositeSerializeDefaultImplementation(e, "/fake/outer/composite", uriBuilderLocalVar.Path, outerComposite); throw; } } @@ -830,22 +870,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFakeOuterNumberSerialize(ApiResponse apiResponseLocalVar, decimal? body) + private void AfterFakeOuterNumberSerializeDefaultImplementation(ApiResponse apiResponseLocalVar, decimal? body) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeOuterNumberSerialize(apiResponseLocalVar, body); } /// /// Processes the server response /// + /// + /// + partial void AfterFakeOuterNumberSerialize(ApiResponse apiResponseLocalVar, decimal? body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFakeOuterNumberSerialize(Exception exception, string pathFormat, string path, decimal? body) + private void OnErrorFakeOuterNumberSerializeDefaultImplementation(Exception exception, string pathFormat, string path, decimal? body) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeOuterNumberSerialize(exception, pathFormat, path, body); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterNumberSerialize(Exception exception, string pathFormat, string path, decimal? body); + /// /// Test serialization of outer number types /// @@ -916,13 +975,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/outer/number", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeOuterNumberSerialize(apiResponseLocalVar, body); + AfterFakeOuterNumberSerializeDefaultImplementation(apiResponseLocalVar, body); return apiResponseLocalVar; } @@ -930,7 +987,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeOuterNumberSerialize(e, "/fake/outer/number", uriBuilderLocalVar.Path, body); + OnErrorFakeOuterNumberSerializeDefaultImplementation(e, "/fake/outer/number", uriBuilderLocalVar.Path, body); throw; } } @@ -960,23 +1017,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFakeOuterStringSerialize(ApiResponse apiResponseLocalVar, Guid requiredStringUuid, string body) + private void AfterFakeOuterStringSerializeDefaultImplementation(ApiResponse apiResponseLocalVar, Guid requiredStringUuid, string body) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeOuterStringSerialize(apiResponseLocalVar, requiredStringUuid, body); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterFakeOuterStringSerialize(ApiResponse apiResponseLocalVar, Guid requiredStringUuid, string body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorFakeOuterStringSerialize(Exception exception, string pathFormat, string path, Guid requiredStringUuid, string body) + private void OnErrorFakeOuterStringSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Guid requiredStringUuid, string body) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeOuterStringSerialize(exception, pathFormat, path, requiredStringUuid, body); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterStringSerialize(Exception exception, string pathFormat, string path, Guid requiredStringUuid, string body); + /// /// Test serialization of outer string types /// @@ -1057,13 +1135,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/outer/string", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeOuterStringSerialize(apiResponseLocalVar, requiredStringUuid, body); + AfterFakeOuterStringSerializeDefaultImplementation(apiResponseLocalVar, requiredStringUuid, body); return apiResponseLocalVar; } @@ -1071,7 +1147,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeOuterStringSerialize(e, "/fake/outer/string", uriBuilderLocalVar.Path, requiredStringUuid, body); + OnErrorFakeOuterStringSerializeDefaultImplementation(e, "/fake/outer/string", uriBuilderLocalVar.Path, requiredStringUuid, body); throw; } } @@ -1080,21 +1156,38 @@ namespace Org.OpenAPITools.Api /// Processes the server response /// /// - protected virtual void AfterGetArrayOfEnums(ApiResponse> apiResponseLocalVar) + private void AfterGetArrayOfEnumsDefaultImplementation(ApiResponse> apiResponseLocalVar) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetArrayOfEnums(apiResponseLocalVar); } /// /// Processes the server response /// + /// + partial void AfterGetArrayOfEnums(ApiResponse> apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// - protected virtual void OnErrorGetArrayOfEnums(Exception exception, string pathFormat, string path) + private void OnErrorGetArrayOfEnumsDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetArrayOfEnums(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorGetArrayOfEnums(Exception exception, string pathFormat, string path); + /// /// Array of Enums /// @@ -1148,13 +1241,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/array-of-enums", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetArrayOfEnums(apiResponseLocalVar); + AfterGetArrayOfEnumsDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -1162,7 +1253,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetArrayOfEnums(e, "/fake/array-of-enums", uriBuilderLocalVar.Path); + OnErrorGetArrayOfEnumsDefaultImplementation(e, "/fake/array-of-enums", uriBuilderLocalVar.Path); throw; } } @@ -1191,22 +1282,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestBodyWithFileSchema(ApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass) + private void AfterTestBodyWithFileSchemaDefaultImplementation(ApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestBodyWithFileSchema(apiResponseLocalVar, fileSchemaTestClass); } /// /// Processes the server response /// + /// + /// + partial void AfterTestBodyWithFileSchema(ApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorTestBodyWithFileSchema(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass) + private void OnErrorTestBodyWithFileSchemaDefaultImplementation(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestBodyWithFileSchema(exception, pathFormat, path, fileSchemaTestClass); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTestBodyWithFileSchema(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass); + /// /// For this test, the body for this request much reference a schema named `File`. /// @@ -1270,13 +1380,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/body-with-file-schema", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestBodyWithFileSchema(apiResponseLocalVar, fileSchemaTestClass); + AfterTestBodyWithFileSchemaDefaultImplementation(apiResponseLocalVar, fileSchemaTestClass); return apiResponseLocalVar; } @@ -1284,7 +1392,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestBodyWithFileSchema(e, "/fake/body-with-file-schema", uriBuilderLocalVar.Path, fileSchemaTestClass); + OnErrorTestBodyWithFileSchemaDefaultImplementation(e, "/fake/body-with-file-schema", uriBuilderLocalVar.Path, fileSchemaTestClass); throw; } } @@ -1318,23 +1426,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestBodyWithQueryParams(ApiResponse apiResponseLocalVar, User user, string query) + private void AfterTestBodyWithQueryParamsDefaultImplementation(ApiResponse apiResponseLocalVar, User user, string query) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestBodyWithQueryParams(apiResponseLocalVar, user, query); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterTestBodyWithQueryParams(ApiResponse apiResponseLocalVar, User user, string query); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorTestBodyWithQueryParams(Exception exception, string pathFormat, string path, User user, string query) + private void OnErrorTestBodyWithQueryParamsDefaultImplementation(Exception exception, string pathFormat, string path, User user, string query) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestBodyWithQueryParams(exception, pathFormat, path, user, query); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestBodyWithQueryParams(Exception exception, string pathFormat, string path, User user, string query); + /// /// /// @@ -1406,13 +1535,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/body-with-query-params", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestBodyWithQueryParams(apiResponseLocalVar, user, query); + AfterTestBodyWithQueryParamsDefaultImplementation(apiResponseLocalVar, user, query); return apiResponseLocalVar; } @@ -1420,7 +1547,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestBodyWithQueryParams(e, "/fake/body-with-query-params", uriBuilderLocalVar.Path, user, query); + OnErrorTestBodyWithQueryParamsDefaultImplementation(e, "/fake/body-with-query-params", uriBuilderLocalVar.Path, user, query); throw; } } @@ -1449,22 +1576,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestClientModel(ApiResponse apiResponseLocalVar, ModelClient modelClient) + private void AfterTestClientModelDefaultImplementation(ApiResponse apiResponseLocalVar, ModelClient modelClient) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestClientModel(apiResponseLocalVar, modelClient); } /// /// Processes the server response /// + /// + /// + partial void AfterTestClientModel(ApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorTestClientModel(Exception exception, string pathFormat, string path, ModelClient modelClient) + private void OnErrorTestClientModelDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestClientModel(exception, pathFormat, path, modelClient); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTestClientModel(Exception exception, string pathFormat, string path, ModelClient modelClient); + /// /// To test \"client\" model To test \"client\" model /// @@ -1537,13 +1683,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestClientModel(apiResponseLocalVar, modelClient); + AfterTestClientModelDefaultImplementation(apiResponseLocalVar, modelClient); return apiResponseLocalVar; } @@ -1551,7 +1695,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestClientModel(e, "/fake", uriBuilderLocalVar.Path, modelClient); + OnErrorTestClientModelDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, modelClient); throw; } } @@ -1605,13 +1749,35 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestEndpointParameters(ApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream binary, float? varFloat, int? integer, int? int32, long? int64, string varString, string password, string callback, DateTime? dateTime) + private void AfterTestEndpointParametersDefaultImplementation(ApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream binary, float? varFloat, int? integer, int? int32, long? int64, string varString, string password, string callback, DateTime? dateTime) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestEndpointParameters(apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); } /// /// Processes the server response /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestEndpointParameters(ApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream binary, float? varFloat, int? integer, int? int32, long? int64, string varString, string password, string callback, DateTime? dateTime); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// @@ -1629,11 +1795,34 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void OnErrorTestEndpointParameters(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream binary, float? varFloat, int? integer, int? int32, long? int64, string varString, string password, string callback, DateTime? dateTime) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream binary, float? varFloat, int? integer, int? int32, long? int64, string varString, string password, string callback, DateTime? dateTime) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestEndpointParameters(exception, pathFormat, path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestEndpointParameters(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream binary, float? varFloat, int? integer, int? int32, long? int64, string varString, string password, string callback, DateTime? dateTime); + /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 /// @@ -1773,13 +1962,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestEndpointParameters(apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + AfterTestEndpointParametersDefaultImplementation(apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1791,7 +1978,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestEndpointParameters(e, "/fake", uriBuilderLocalVar.Path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + OnErrorTestEndpointParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); throw; } } @@ -1810,13 +1997,29 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestEnumParameters(ApiResponse apiResponseLocalVar, List enumHeaderStringArray, List enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List enumFormStringArray, string enumHeaderString, string enumQueryString, string enumFormString) + private void AfterTestEnumParametersDefaultImplementation(ApiResponse apiResponseLocalVar, List enumHeaderStringArray, List enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List enumFormStringArray, string enumHeaderString, string enumQueryString, string enumFormString) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestEnumParameters(apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); } /// /// Processes the server response /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestEnumParameters(ApiResponse apiResponseLocalVar, List enumHeaderStringArray, List enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List enumFormStringArray, string enumHeaderString, string enumQueryString, string enumFormString); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// @@ -1828,11 +2031,28 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void OnErrorTestEnumParameters(Exception exception, string pathFormat, string path, List enumHeaderStringArray, List enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List enumFormStringArray, string enumHeaderString, string enumQueryString, string enumFormString) + private void OnErrorTestEnumParametersDefaultImplementation(Exception exception, string pathFormat, string path, List enumHeaderStringArray, List enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List enumFormStringArray, string enumHeaderString, string enumQueryString, string enumFormString) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestEnumParameters(exception, pathFormat, path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestEnumParameters(Exception exception, string pathFormat, string path, List enumHeaderStringArray, List enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List enumFormStringArray, string enumHeaderString, string enumQueryString, string enumFormString); + /// /// To test enum parameters To test enum parameters /// @@ -1938,13 +2158,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestEnumParameters(apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + AfterTestEnumParametersDefaultImplementation(apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); return apiResponseLocalVar; } @@ -1952,7 +2170,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestEnumParameters(e, "/fake", uriBuilderLocalVar.Path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + OnErrorTestEnumParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); throw; } } @@ -1994,13 +2212,27 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestGroupParameters(ApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group) + private void AfterTestGroupParametersDefaultImplementation(ApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestGroupParameters(apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); } /// /// Processes the server response /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestGroupParameters(ApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// @@ -2010,11 +2242,26 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void OnErrorTestGroupParameters(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group) + private void OnErrorTestGroupParametersDefaultImplementation(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestGroupParameters(exception, pathFormat, path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestGroupParameters(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group); + /// /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) /// @@ -2101,13 +2348,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestGroupParameters(apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + AfterTestGroupParametersDefaultImplementation(apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -2119,7 +2364,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestGroupParameters(e, "/fake", uriBuilderLocalVar.Path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + OnErrorTestGroupParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); throw; } } @@ -2148,22 +2393,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestInlineAdditionalProperties(ApiResponse apiResponseLocalVar, Dictionary requestBody) + private void AfterTestInlineAdditionalPropertiesDefaultImplementation(ApiResponse apiResponseLocalVar, Dictionary requestBody) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestInlineAdditionalProperties(apiResponseLocalVar, requestBody); } /// /// Processes the server response /// + /// + /// + partial void AfterTestInlineAdditionalProperties(ApiResponse apiResponseLocalVar, Dictionary requestBody); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorTestInlineAdditionalProperties(Exception exception, string pathFormat, string path, Dictionary requestBody) + private void OnErrorTestInlineAdditionalPropertiesDefaultImplementation(Exception exception, string pathFormat, string path, Dictionary requestBody) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestInlineAdditionalProperties(exception, pathFormat, path, requestBody); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTestInlineAdditionalProperties(Exception exception, string pathFormat, string path, Dictionary requestBody); + /// /// test inline additionalProperties /// @@ -2227,13 +2491,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestInlineAdditionalProperties(apiResponseLocalVar, requestBody); + AfterTestInlineAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, requestBody); return apiResponseLocalVar; } @@ -2241,7 +2503,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestInlineAdditionalProperties(e, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path, requestBody); + OnErrorTestInlineAdditionalPropertiesDefaultImplementation(e, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path, requestBody); throw; } } @@ -2275,23 +2537,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestJsonFormData(ApiResponse apiResponseLocalVar, string param, string param2) + private void AfterTestJsonFormDataDefaultImplementation(ApiResponse apiResponseLocalVar, string param, string param2) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestJsonFormData(apiResponseLocalVar, param, param2); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterTestJsonFormData(ApiResponse apiResponseLocalVar, string param, string param2); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorTestJsonFormData(Exception exception, string pathFormat, string path, string param, string param2) + private void OnErrorTestJsonFormDataDefaultImplementation(Exception exception, string pathFormat, string path, string param, string param2) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestJsonFormData(exception, pathFormat, path, param, param2); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestJsonFormData(Exception exception, string pathFormat, string path, string param, string param2); + /// /// test json serialization of form data /// @@ -2365,13 +2648,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/jsonFormData", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestJsonFormData(apiResponseLocalVar, param, param2); + AfterTestJsonFormDataDefaultImplementation(apiResponseLocalVar, param, param2); return apiResponseLocalVar; } @@ -2379,7 +2660,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestJsonFormData(e, "/fake/jsonFormData", uriBuilderLocalVar.Path, param, param2); + OnErrorTestJsonFormDataDefaultImplementation(e, "/fake/jsonFormData", uriBuilderLocalVar.Path, param, param2); throw; } } @@ -2428,13 +2709,26 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestQueryParameterCollectionFormat(ApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context) + private void AfterTestQueryParameterCollectionFormatDefaultImplementation(ApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestQueryParameterCollectionFormat(apiResponseLocalVar, pipe, ioutil, http, url, context); } /// /// Processes the server response /// + /// + /// + /// + /// + /// + /// + partial void AfterTestQueryParameterCollectionFormat(ApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// @@ -2443,11 +2737,25 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void OnErrorTestQueryParameterCollectionFormat(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context) + private void OnErrorTestQueryParameterCollectionFormatDefaultImplementation(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestQueryParameterCollectionFormat(exception, pathFormat, path, pipe, ioutil, http, url, context); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestQueryParameterCollectionFormat(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context); + /// /// To test the collection format in query parameters /// @@ -2516,13 +2824,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/test-query-parameters", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestQueryParameterCollectionFormat(apiResponseLocalVar, pipe, ioutil, http, url, context); + AfterTestQueryParameterCollectionFormatDefaultImplementation(apiResponseLocalVar, pipe, ioutil, http, url, context); return apiResponseLocalVar; } @@ -2530,7 +2836,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestQueryParameterCollectionFormat(e, "/fake/test-query-parameters", uriBuilderLocalVar.Path, pipe, ioutil, http, url, context); + OnErrorTestQueryParameterCollectionFormatDefaultImplementation(e, "/fake/test-query-parameters", uriBuilderLocalVar.Path, pipe, ioutil, http, url, context); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index a7c2d4d15c7..9edd2f5ce88 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -117,15 +117,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatTestClassname(ModelClient modelClient); /// @@ -150,22 +141,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestClassname(ApiResponse apiResponseLocalVar, ModelClient modelClient) + private void AfterTestClassnameDefaultImplementation(ApiResponse apiResponseLocalVar, ModelClient modelClient) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestClassname(apiResponseLocalVar, modelClient); } /// /// Processes the server response /// + /// + /// + partial void AfterTestClassname(ApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorTestClassname(Exception exception, string pathFormat, string path, ModelClient modelClient) + private void OnErrorTestClassnameDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestClassname(exception, pathFormat, path, modelClient); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTestClassname(Exception exception, string pathFormat, string path, ModelClient modelClient); + /// /// To test class name in snake case To test class name in snake case /// @@ -249,13 +259,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake_classname_test", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestClassname(apiResponseLocalVar, modelClient); + AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -267,7 +275,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestClassname(e, "/fake_classname_test", uriBuilderLocalVar.Path, modelClient); + OnErrorTestClassnameDefaultImplementation(e, "/fake_classname_test", uriBuilderLocalVar.Path, modelClient); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/PetApi.cs index d35fda9e461..06d1c7867b5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/PetApi.cs @@ -315,15 +315,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatAddPet(Pet pet); /// @@ -348,22 +339,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterAddPet(ApiResponse apiResponseLocalVar, Pet pet) + private void AfterAddPetDefaultImplementation(ApiResponse apiResponseLocalVar, Pet pet) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterAddPet(apiResponseLocalVar, pet); } /// /// Processes the server response /// + /// + /// + partial void AfterAddPet(ApiResponse apiResponseLocalVar, Pet pet); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorAddPet(Exception exception, string pathFormat, string path, Pet pet) + private void OnErrorAddPetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorAddPet(exception, pathFormat, path, pet); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorAddPet(Exception exception, string pathFormat, string path, Pet pet); + /// /// Add a new pet to the store /// @@ -444,13 +454,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); - AfterAddPet(apiResponseLocalVar, pet); + AfterAddPetDefaultImplementation(apiResponseLocalVar, pet); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -466,7 +474,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorAddPet(e, "/pet", uriBuilderLocalVar.Path, pet); + OnErrorAddPetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); throw; } } @@ -496,23 +504,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterDeletePet(ApiResponse apiResponseLocalVar, long petId, string apiKey) + private void AfterDeletePetDefaultImplementation(ApiResponse apiResponseLocalVar, long petId, string apiKey) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterDeletePet(apiResponseLocalVar, petId, apiKey); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterDeletePet(ApiResponse apiResponseLocalVar, long petId, string apiKey); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorDeletePet(Exception exception, string pathFormat, string path, long petId, string apiKey) + private void OnErrorDeletePetDefaultImplementation(Exception exception, string pathFormat, string path, long petId, string apiKey) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorDeletePet(exception, pathFormat, path, petId, apiKey); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorDeletePet(Exception exception, string pathFormat, string path, long petId, string apiKey); + /// /// Deletes a pet /// @@ -577,13 +606,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/{petId}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); - AfterDeletePet(apiResponseLocalVar, petId, apiKey); + AfterDeletePetDefaultImplementation(apiResponseLocalVar, petId, apiKey); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -595,7 +622,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorDeletePet(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, apiKey); + OnErrorDeletePetDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, apiKey); throw; } } @@ -624,22 +651,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFindPetsByStatus(ApiResponse> apiResponseLocalVar, List status) + private void AfterFindPetsByStatusDefaultImplementation(ApiResponse> apiResponseLocalVar, List status) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFindPetsByStatus(apiResponseLocalVar, status); } /// /// Processes the server response /// + /// + /// + partial void AfterFindPetsByStatus(ApiResponse> apiResponseLocalVar, List status); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFindPetsByStatus(Exception exception, string pathFormat, string path, List status) + private void OnErrorFindPetsByStatusDefaultImplementation(Exception exception, string pathFormat, string path, List status) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFindPetsByStatus(exception, pathFormat, path, status); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFindPetsByStatus(Exception exception, string pathFormat, string path, List status); + /// /// Finds Pets by status Multiple status values can be provided with comma separated strings /// @@ -722,13 +768,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/findByStatus", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); - AfterFindPetsByStatus(apiResponseLocalVar, status); + AfterFindPetsByStatusDefaultImplementation(apiResponseLocalVar, status); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -744,7 +788,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFindPetsByStatus(e, "/pet/findByStatus", uriBuilderLocalVar.Path, status); + OnErrorFindPetsByStatusDefaultImplementation(e, "/pet/findByStatus", uriBuilderLocalVar.Path, status); throw; } } @@ -773,22 +817,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFindPetsByTags(ApiResponse> apiResponseLocalVar, List tags) + private void AfterFindPetsByTagsDefaultImplementation(ApiResponse> apiResponseLocalVar, List tags) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFindPetsByTags(apiResponseLocalVar, tags); } /// /// Processes the server response /// + /// + /// + partial void AfterFindPetsByTags(ApiResponse> apiResponseLocalVar, List tags); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFindPetsByTags(Exception exception, string pathFormat, string path, List tags) + private void OnErrorFindPetsByTagsDefaultImplementation(Exception exception, string pathFormat, string path, List tags) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFindPetsByTags(exception, pathFormat, path, tags); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFindPetsByTags(Exception exception, string pathFormat, string path, List tags); + /// /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// @@ -871,13 +934,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/findByTags", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); - AfterFindPetsByTags(apiResponseLocalVar, tags); + AfterFindPetsByTagsDefaultImplementation(apiResponseLocalVar, tags); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -893,7 +954,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFindPetsByTags(e, "/pet/findByTags", uriBuilderLocalVar.Path, tags); + OnErrorFindPetsByTagsDefaultImplementation(e, "/pet/findByTags", uriBuilderLocalVar.Path, tags); throw; } } @@ -922,22 +983,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterGetPetById(ApiResponse apiResponseLocalVar, long petId) + private void AfterGetPetByIdDefaultImplementation(ApiResponse apiResponseLocalVar, long petId) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetPetById(apiResponseLocalVar, petId); } /// /// Processes the server response /// + /// + /// + partial void AfterGetPetById(ApiResponse apiResponseLocalVar, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorGetPetById(Exception exception, string pathFormat, string path, long petId) + private void OnErrorGetPetByIdDefaultImplementation(Exception exception, string pathFormat, string path, long petId) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetPetById(exception, pathFormat, path, petId); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetPetById(Exception exception, string pathFormat, string path, long petId); + /// /// Find pet by ID Returns a single pet /// @@ -1007,13 +1087,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/{petId}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetPetById(apiResponseLocalVar, petId); + AfterGetPetByIdDefaultImplementation(apiResponseLocalVar, petId); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1025,7 +1103,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetPetById(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId); + OnErrorGetPetByIdDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId); throw; } } @@ -1054,22 +1132,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUpdatePet(ApiResponse apiResponseLocalVar, Pet pet) + private void AfterUpdatePetDefaultImplementation(ApiResponse apiResponseLocalVar, Pet pet) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUpdatePet(apiResponseLocalVar, pet); } /// /// Processes the server response /// + /// + /// + partial void AfterUpdatePet(ApiResponse apiResponseLocalVar, Pet pet); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorUpdatePet(Exception exception, string pathFormat, string path, Pet pet) + private void OnErrorUpdatePetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUpdatePet(exception, pathFormat, path, pet); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorUpdatePet(Exception exception, string pathFormat, string path, Pet pet); + /// /// Update an existing pet /// @@ -1150,13 +1247,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); - AfterUpdatePet(apiResponseLocalVar, pet); + AfterUpdatePetDefaultImplementation(apiResponseLocalVar, pet); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1172,7 +1267,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUpdatePet(e, "/pet", uriBuilderLocalVar.Path, pet); + OnErrorUpdatePetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); throw; } } @@ -1203,24 +1298,47 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUpdatePetWithForm(ApiResponse apiResponseLocalVar, long petId, string name, string status) + private void AfterUpdatePetWithFormDefaultImplementation(ApiResponse apiResponseLocalVar, long petId, string name, string status) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUpdatePetWithForm(apiResponseLocalVar, petId, name, status); } /// /// Processes the server response /// + /// + /// + /// + /// + partial void AfterUpdatePetWithForm(ApiResponse apiResponseLocalVar, long petId, string name, string status); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// /// - protected virtual void OnErrorUpdatePetWithForm(Exception exception, string pathFormat, string path, long petId, string name, string status) + private void OnErrorUpdatePetWithFormDefaultImplementation(Exception exception, string pathFormat, string path, long petId, string name, string status) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUpdatePetWithForm(exception, pathFormat, path, petId, name, status); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUpdatePetWithForm(Exception exception, string pathFormat, string path, long petId, string name, string status); + /// /// Updates a pet in the store with form data /// @@ -1305,13 +1423,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/{petId}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); - AfterUpdatePetWithForm(apiResponseLocalVar, petId, name, status); + AfterUpdatePetWithFormDefaultImplementation(apiResponseLocalVar, petId, name, status); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1323,7 +1439,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUpdatePetWithForm(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, name, status); + OnErrorUpdatePetWithFormDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, name, status); throw; } } @@ -1354,24 +1470,47 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUploadFile(ApiResponse apiResponseLocalVar, long petId, System.IO.Stream file, string additionalMetadata) + private void AfterUploadFileDefaultImplementation(ApiResponse apiResponseLocalVar, long petId, System.IO.Stream file, string additionalMetadata) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUploadFile(apiResponseLocalVar, petId, file, additionalMetadata); } /// /// Processes the server response /// + /// + /// + /// + /// + partial void AfterUploadFile(ApiResponse apiResponseLocalVar, long petId, System.IO.Stream file, string additionalMetadata); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// /// - protected virtual void OnErrorUploadFile(Exception exception, string pathFormat, string path, long petId, System.IO.Stream file, string additionalMetadata) + private void OnErrorUploadFileDefaultImplementation(Exception exception, string pathFormat, string path, long petId, System.IO.Stream file, string additionalMetadata) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUploadFile(exception, pathFormat, path, petId, file, additionalMetadata); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFile(Exception exception, string pathFormat, string path, long petId, System.IO.Stream file, string additionalMetadata); + /// /// uploads an image /// @@ -1465,13 +1604,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); - AfterUploadFile(apiResponseLocalVar, petId, file, additionalMetadata); + AfterUploadFileDefaultImplementation(apiResponseLocalVar, petId, file, additionalMetadata); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1483,7 +1620,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUploadFile(e, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path, petId, file, additionalMetadata); + OnErrorUploadFileDefaultImplementation(e, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path, petId, file, additionalMetadata); throw; } } @@ -1518,24 +1655,47 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUploadFileWithRequiredFile(ApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, string additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(ApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, string additionalMetadata) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUploadFileWithRequiredFile(apiResponseLocalVar, requiredFile, petId, additionalMetadata); } /// /// Processes the server response /// + /// + /// + /// + /// + partial void AfterUploadFileWithRequiredFile(ApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, string additionalMetadata); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// /// - protected virtual void OnErrorUploadFileWithRequiredFile(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, string additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, string additionalMetadata) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUploadFileWithRequiredFile(exception, pathFormat, path, requiredFile, petId, additionalMetadata); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFileWithRequiredFile(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, string additionalMetadata); + /// /// uploads an image (required) /// @@ -1629,13 +1789,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); - AfterUploadFileWithRequiredFile(apiResponseLocalVar, requiredFile, petId, additionalMetadata); + AfterUploadFileWithRequiredFileDefaultImplementation(apiResponseLocalVar, requiredFile, petId, additionalMetadata); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1647,7 +1805,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUploadFileWithRequiredFile(e, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path, requiredFile, petId, additionalMetadata); + OnErrorUploadFileWithRequiredFileDefaultImplementation(e, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path, requiredFile, petId, additionalMetadata); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/StoreApi.cs index 4e3b1170c4d..c5435e901ca 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/StoreApi.cs @@ -184,15 +184,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatDeleteOrder(ref string orderId); /// @@ -217,22 +208,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterDeleteOrder(ApiResponse apiResponseLocalVar, string orderId) + private void AfterDeleteOrderDefaultImplementation(ApiResponse apiResponseLocalVar, string orderId) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterDeleteOrder(apiResponseLocalVar, orderId); } /// /// Processes the server response /// + /// + /// + partial void AfterDeleteOrder(ApiResponse apiResponseLocalVar, string orderId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorDeleteOrder(Exception exception, string pathFormat, string path, string orderId) + private void OnErrorDeleteOrderDefaultImplementation(Exception exception, string pathFormat, string path, string orderId) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorDeleteOrder(exception, pathFormat, path, orderId); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorDeleteOrder(Exception exception, string pathFormat, string path, string orderId); + /// /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors /// @@ -284,13 +294,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/store/order/{order_id}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); - AfterDeleteOrder(apiResponseLocalVar, orderId); + AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId); return apiResponseLocalVar; } @@ -298,7 +306,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorDeleteOrder(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + OnErrorDeleteOrderDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); throw; } } @@ -307,21 +315,38 @@ namespace Org.OpenAPITools.Api /// Processes the server response /// /// - protected virtual void AfterGetInventory(ApiResponse> apiResponseLocalVar) + private void AfterGetInventoryDefaultImplementation(ApiResponse> apiResponseLocalVar) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetInventory(apiResponseLocalVar); } /// /// Processes the server response /// + /// + partial void AfterGetInventory(ApiResponse> apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// - protected virtual void OnErrorGetInventory(Exception exception, string pathFormat, string path) + private void OnErrorGetInventoryDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetInventory(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorGetInventory(Exception exception, string pathFormat, string path); + /// /// Returns pet inventories by status Returns a map of status codes to quantities /// @@ -383,13 +408,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/store/inventory", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetInventory(apiResponseLocalVar); + AfterGetInventoryDefaultImplementation(apiResponseLocalVar); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -401,7 +424,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetInventory(e, "/store/inventory", uriBuilderLocalVar.Path); + OnErrorGetInventoryDefaultImplementation(e, "/store/inventory", uriBuilderLocalVar.Path); throw; } } @@ -430,22 +453,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterGetOrderById(ApiResponse apiResponseLocalVar, long orderId) + private void AfterGetOrderByIdDefaultImplementation(ApiResponse apiResponseLocalVar, long orderId) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetOrderById(apiResponseLocalVar, orderId); } /// /// Processes the server response /// + /// + /// + partial void AfterGetOrderById(ApiResponse apiResponseLocalVar, long orderId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorGetOrderById(Exception exception, string pathFormat, string path, long orderId) + private void OnErrorGetOrderByIdDefaultImplementation(Exception exception, string pathFormat, string path, long orderId) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetOrderById(exception, pathFormat, path, orderId); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetOrderById(Exception exception, string pathFormat, string path, long orderId); + /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions /// @@ -507,13 +549,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/store/order/{order_id}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetOrderById(apiResponseLocalVar, orderId); + AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId); return apiResponseLocalVar; } @@ -521,7 +561,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetOrderById(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + OnErrorGetOrderByIdDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); throw; } } @@ -550,22 +590,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterPlaceOrder(ApiResponse apiResponseLocalVar, Order order) + private void AfterPlaceOrderDefaultImplementation(ApiResponse apiResponseLocalVar, Order order) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterPlaceOrder(apiResponseLocalVar, order); } /// /// Processes the server response /// + /// + /// + partial void AfterPlaceOrder(ApiResponse apiResponseLocalVar, Order order); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorPlaceOrder(Exception exception, string pathFormat, string path, Order order) + private void OnErrorPlaceOrderDefaultImplementation(Exception exception, string pathFormat, string path, Order order) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorPlaceOrder(exception, pathFormat, path, order); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorPlaceOrder(Exception exception, string pathFormat, string path, Order order); + /// /// Place an order for a pet /// @@ -639,13 +698,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/store/order", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); - AfterPlaceOrder(apiResponseLocalVar, order); + AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order); return apiResponseLocalVar; } @@ -653,7 +710,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorPlaceOrder(e, "/store/order", uriBuilderLocalVar.Path, order); + OnErrorPlaceOrderDefaultImplementation(e, "/store/order", uriBuilderLocalVar.Path, order); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/UserApi.cs index 4e5159f9f61..ce83e2e6ec4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/UserApi.cs @@ -280,15 +280,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatCreateUser(User user); /// @@ -313,22 +304,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterCreateUser(ApiResponse apiResponseLocalVar, User user) + private void AfterCreateUserDefaultImplementation(ApiResponse apiResponseLocalVar, User user) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterCreateUser(apiResponseLocalVar, user); } /// /// Processes the server response /// + /// + /// + partial void AfterCreateUser(ApiResponse apiResponseLocalVar, User user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorCreateUser(Exception exception, string pathFormat, string path, User user) + private void OnErrorCreateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorCreateUser(exception, pathFormat, path, user); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorCreateUser(Exception exception, string pathFormat, string path, User user); + /// /// Create user This can only be done by the logged in user. /// @@ -392,13 +402,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); - AfterCreateUser(apiResponseLocalVar, user); + AfterCreateUserDefaultImplementation(apiResponseLocalVar, user); return apiResponseLocalVar; } @@ -406,7 +414,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorCreateUser(e, "/user", uriBuilderLocalVar.Path, user); + OnErrorCreateUserDefaultImplementation(e, "/user", uriBuilderLocalVar.Path, user); throw; } } @@ -435,22 +443,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterCreateUsersWithArrayInput(ApiResponse apiResponseLocalVar, List user) + private void AfterCreateUsersWithArrayInputDefaultImplementation(ApiResponse apiResponseLocalVar, List user) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterCreateUsersWithArrayInput(apiResponseLocalVar, user); } /// /// Processes the server response /// + /// + /// + partial void AfterCreateUsersWithArrayInput(ApiResponse apiResponseLocalVar, List user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorCreateUsersWithArrayInput(Exception exception, string pathFormat, string path, List user) + private void OnErrorCreateUsersWithArrayInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorCreateUsersWithArrayInput(exception, pathFormat, path, user); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorCreateUsersWithArrayInput(Exception exception, string pathFormat, string path, List user); + /// /// Creates list of users with given input array /// @@ -514,13 +541,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/createWithArray", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); - AfterCreateUsersWithArrayInput(apiResponseLocalVar, user); + AfterCreateUsersWithArrayInputDefaultImplementation(apiResponseLocalVar, user); return apiResponseLocalVar; } @@ -528,7 +553,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorCreateUsersWithArrayInput(e, "/user/createWithArray", uriBuilderLocalVar.Path, user); + OnErrorCreateUsersWithArrayInputDefaultImplementation(e, "/user/createWithArray", uriBuilderLocalVar.Path, user); throw; } } @@ -557,22 +582,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterCreateUsersWithListInput(ApiResponse apiResponseLocalVar, List user) + private void AfterCreateUsersWithListInputDefaultImplementation(ApiResponse apiResponseLocalVar, List user) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterCreateUsersWithListInput(apiResponseLocalVar, user); } /// /// Processes the server response /// + /// + /// + partial void AfterCreateUsersWithListInput(ApiResponse apiResponseLocalVar, List user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorCreateUsersWithListInput(Exception exception, string pathFormat, string path, List user) + private void OnErrorCreateUsersWithListInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorCreateUsersWithListInput(exception, pathFormat, path, user); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorCreateUsersWithListInput(Exception exception, string pathFormat, string path, List user); + /// /// Creates list of users with given input array /// @@ -636,13 +680,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/createWithList", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); - AfterCreateUsersWithListInput(apiResponseLocalVar, user); + AfterCreateUsersWithListInputDefaultImplementation(apiResponseLocalVar, user); return apiResponseLocalVar; } @@ -650,7 +692,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorCreateUsersWithListInput(e, "/user/createWithList", uriBuilderLocalVar.Path, user); + OnErrorCreateUsersWithListInputDefaultImplementation(e, "/user/createWithList", uriBuilderLocalVar.Path, user); throw; } } @@ -679,22 +721,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterDeleteUser(ApiResponse apiResponseLocalVar, string username) + private void AfterDeleteUserDefaultImplementation(ApiResponse apiResponseLocalVar, string username) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterDeleteUser(apiResponseLocalVar, username); } /// /// Processes the server response /// + /// + /// + partial void AfterDeleteUser(ApiResponse apiResponseLocalVar, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorDeleteUser(Exception exception, string pathFormat, string path, string username) + private void OnErrorDeleteUserDefaultImplementation(Exception exception, string pathFormat, string path, string username) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorDeleteUser(exception, pathFormat, path, username); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorDeleteUser(Exception exception, string pathFormat, string path, string username); + /// /// Delete user This can only be done by the logged in user. /// @@ -746,13 +807,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/{username}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); - AfterDeleteUser(apiResponseLocalVar, username); + AfterDeleteUserDefaultImplementation(apiResponseLocalVar, username); return apiResponseLocalVar; } @@ -760,7 +819,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorDeleteUser(e, "/user/{username}", uriBuilderLocalVar.Path, username); + OnErrorDeleteUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); throw; } } @@ -789,22 +848,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterGetUserByName(ApiResponse apiResponseLocalVar, string username) + private void AfterGetUserByNameDefaultImplementation(ApiResponse apiResponseLocalVar, string username) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetUserByName(apiResponseLocalVar, username); } /// /// Processes the server response /// + /// + /// + partial void AfterGetUserByName(ApiResponse apiResponseLocalVar, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorGetUserByName(Exception exception, string pathFormat, string path, string username) + private void OnErrorGetUserByNameDefaultImplementation(Exception exception, string pathFormat, string path, string username) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetUserByName(exception, pathFormat, path, username); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetUserByName(Exception exception, string pathFormat, string path, string username); + /// /// Get user by user name /// @@ -866,13 +944,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/{username}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetUserByName(apiResponseLocalVar, username); + AfterGetUserByNameDefaultImplementation(apiResponseLocalVar, username); return apiResponseLocalVar; } @@ -880,7 +956,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetUserByName(e, "/user/{username}", uriBuilderLocalVar.Path, username); + OnErrorGetUserByNameDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); throw; } } @@ -914,23 +990,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterLoginUser(ApiResponse apiResponseLocalVar, string username, string password) + private void AfterLoginUserDefaultImplementation(ApiResponse apiResponseLocalVar, string username, string password) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterLoginUser(apiResponseLocalVar, username, password); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterLoginUser(ApiResponse apiResponseLocalVar, string username, string password); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorLoginUser(Exception exception, string pathFormat, string path, string username, string password) + private void OnErrorLoginUserDefaultImplementation(Exception exception, string pathFormat, string path, string username, string password) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorLoginUser(exception, pathFormat, path, username, password); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorLoginUser(Exception exception, string pathFormat, string path, string username, string password); + /// /// Logs user into the system /// @@ -1000,13 +1097,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/login", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); - AfterLoginUser(apiResponseLocalVar, username, password); + AfterLoginUserDefaultImplementation(apiResponseLocalVar, username, password); return apiResponseLocalVar; } @@ -1014,7 +1109,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorLoginUser(e, "/user/login", uriBuilderLocalVar.Path, username, password); + OnErrorLoginUserDefaultImplementation(e, "/user/login", uriBuilderLocalVar.Path, username, password); throw; } } @@ -1023,21 +1118,38 @@ namespace Org.OpenAPITools.Api /// Processes the server response /// /// - protected virtual void AfterLogoutUser(ApiResponse apiResponseLocalVar) + private void AfterLogoutUserDefaultImplementation(ApiResponse apiResponseLocalVar) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterLogoutUser(apiResponseLocalVar); } /// /// Processes the server response /// + /// + partial void AfterLogoutUser(ApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// - protected virtual void OnErrorLogoutUser(Exception exception, string pathFormat, string path) + private void OnErrorLogoutUserDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorLogoutUser(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorLogoutUser(Exception exception, string pathFormat, string path); + /// /// Logs out current logged in user session /// @@ -1082,13 +1194,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/logout", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); - AfterLogoutUser(apiResponseLocalVar); + AfterLogoutUserDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -1096,7 +1206,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorLogoutUser(e, "/user/logout", uriBuilderLocalVar.Path); + OnErrorLogoutUserDefaultImplementation(e, "/user/logout", uriBuilderLocalVar.Path); throw; } } @@ -1130,23 +1240,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUpdateUser(ApiResponse apiResponseLocalVar, User user, string username) + private void AfterUpdateUserDefaultImplementation(ApiResponse apiResponseLocalVar, User user, string username) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUpdateUser(apiResponseLocalVar, user, username); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterUpdateUser(ApiResponse apiResponseLocalVar, User user, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorUpdateUser(Exception exception, string pathFormat, string path, User user, string username) + private void OnErrorUpdateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user, string username) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUpdateUser(exception, pathFormat, path, user, username); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorUpdateUser(Exception exception, string pathFormat, string path, User user, string username); + /// /// Updated user This can only be done by the logged in user. /// @@ -1213,13 +1344,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/{username}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); - AfterUpdateUser(apiResponseLocalVar, user, username); + AfterUpdateUserDefaultImplementation(apiResponseLocalVar, user, username); return apiResponseLocalVar; } @@ -1227,7 +1356,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUpdateUser(e, "/user/{username}", uriBuilderLocalVar.Path, user, username); + OnErrorUpdateUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, user, username); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 261a417e9d4..e1bd4dd8821 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -32,7 +32,7 @@ namespace Org.OpenAPITools.Client HttpStatusCode StatusCode { get; } /// - /// The raw content of this response + /// The raw content of this response. /// string RawContent { get; } @@ -40,6 +40,16 @@ namespace Org.OpenAPITools.Client /// The DateTime when the request was retrieved. /// DateTime DownloadedAt { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The Uri used when making the request. + /// + Uri RequestUri { get; } } /// @@ -86,6 +96,21 @@ namespace Org.OpenAPITools.Client /// public DateTime DownloadedAt { get; } = DateTime.UtcNow; + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri RequestUri { get; } + /// /// The JsonSerialzierOptions /// @@ -97,14 +122,19 @@ namespace Org.OpenAPITools.Client /// /// /// + /// + /// /// - public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) { StatusCode = httpResponseMessage.StatusCode; Headers = httpResponseMessage.Headers; IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; ReasonPhrase = httpResponseMessage.ReasonPhrase; RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; _jsonSerializerOptions = jsonSerializerOptions; OnCreated(httpRequestMessage, httpResponseMessage); } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 7e223247d8c..93d0223c394 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -84,15 +84,6 @@ namespace Org.OpenAPITools.Api HttpClient = httpClient; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatList(ref string personId); /// @@ -117,22 +108,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterList(ApiResponse apiResponseLocalVar, string personId) + private void AfterListDefaultImplementation(ApiResponse apiResponseLocalVar, string personId) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterList(apiResponseLocalVar, personId); } /// /// Processes the server response /// + /// + /// + partial void AfterList(ApiResponse apiResponseLocalVar, string personId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorList(Exception exception, string pathFormat, string path, string personId) + private void OnErrorListDefaultImplementation(Exception exception, string pathFormat, string path, string personId) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorList(exception, pathFormat, path, personId); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorList(Exception exception, string pathFormat, string path, string personId); + /// /// /// @@ -193,13 +203,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/person/display/{personId}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/person/display/{personId}", requestedAtLocalVar, _jsonSerializerOptions); - AfterList(apiResponseLocalVar, personId); + AfterListDefaultImplementation(apiResponseLocalVar, personId); return apiResponseLocalVar; } @@ -207,7 +215,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorList(e, "/person/display/{personId}", uriBuilderLocalVar.Path, personId); + OnErrorListDefaultImplementation(e, "/person/display/{personId}", uriBuilderLocalVar.Path, personId); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 978e6cd2567..76804c63e4f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -34,7 +34,7 @@ namespace Org.OpenAPITools.Client HttpStatusCode StatusCode { get; } /// - /// The raw content of this response + /// The raw content of this response. /// string RawContent { get; } @@ -42,6 +42,16 @@ namespace Org.OpenAPITools.Client /// The DateTime when the request was retrieved. /// DateTime DownloadedAt { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The Uri used when making the request. + /// + Uri? RequestUri { get; } } /// @@ -88,6 +98,21 @@ namespace Org.OpenAPITools.Client /// public DateTime DownloadedAt { get; } = DateTime.UtcNow; + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri? RequestUri { get; } + /// /// The JsonSerialzierOptions /// @@ -99,14 +124,19 @@ namespace Org.OpenAPITools.Client /// /// /// + /// + /// /// - public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) { StatusCode = httpResponseMessage.StatusCode; Headers = httpResponseMessage.Headers; IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; ReasonPhrase = httpResponseMessage.ReasonPhrase; RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; _jsonSerializerOptions = jsonSerializerOptions; OnCreated(httpRequestMessage, httpResponseMessage); } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Api/DefaultApi.cs index e75c4a7fd25..43c62e5f280 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -83,33 +83,41 @@ namespace Org.OpenAPITools.Api } /// - /// Logs the api response + /// Processes the server response /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) + /// + private void AfterRootGetDefaultImplementation(ApiResponse apiResponseLocalVar) { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterRootGet(apiResponseLocalVar); } /// /// Processes the server response /// /// - protected virtual void AfterRootGet(ApiResponse apiResponseLocalVar) - { - } + partial void AfterRootGet(ApiResponse apiResponseLocalVar); /// - /// Processes the server response + /// Logs exceptions that occur while retrieving the server response /// /// /// /// - protected virtual void OnErrorRootGet(Exception exception, string pathFormat, string path) + private void OnErrorRootGetDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorRootGet(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorRootGet(Exception exception, string pathFormat, string path); + /// /// /// @@ -163,13 +171,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions); - AfterRootGet(apiResponseLocalVar); + AfterRootGetDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -177,7 +183,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorRootGet(e, "/", uriBuilderLocalVar.Path); + OnErrorRootGetDefaultImplementation(e, "/", uriBuilderLocalVar.Path); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 93fb981a54a..bfc858f83a9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -34,7 +34,7 @@ namespace Org.OpenAPITools.Client HttpStatusCode StatusCode { get; } /// - /// The raw content of this response + /// The raw content of this response. /// string RawContent { get; } @@ -42,6 +42,16 @@ namespace Org.OpenAPITools.Client /// The DateTime when the request was retrieved. /// DateTime DownloadedAt { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The Uri used when making the request. + /// + Uri? RequestUri { get; } } /// @@ -88,6 +98,21 @@ namespace Org.OpenAPITools.Client /// public DateTime DownloadedAt { get; } = DateTime.UtcNow; + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri? RequestUri { get; } + /// /// The JsonSerialzierOptions /// @@ -99,14 +124,19 @@ namespace Org.OpenAPITools.Client /// /// /// + /// + /// /// - public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) { StatusCode = httpResponseMessage.StatusCode; Headers = httpResponseMessage.Headers; IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; ReasonPhrase = httpResponseMessage.ReasonPhrase; RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; _jsonSerializerOptions = jsonSerializerOptions; OnCreated(httpRequestMessage, httpResponseMessage); } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Api/DefaultApi.cs index e75c4a7fd25..43c62e5f280 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -83,33 +83,41 @@ namespace Org.OpenAPITools.Api } /// - /// Logs the api response + /// Processes the server response /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) + /// + private void AfterRootGetDefaultImplementation(ApiResponse apiResponseLocalVar) { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterRootGet(apiResponseLocalVar); } /// /// Processes the server response /// /// - protected virtual void AfterRootGet(ApiResponse apiResponseLocalVar) - { - } + partial void AfterRootGet(ApiResponse apiResponseLocalVar); /// - /// Processes the server response + /// Logs exceptions that occur while retrieving the server response /// /// /// /// - protected virtual void OnErrorRootGet(Exception exception, string pathFormat, string path) + private void OnErrorRootGetDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorRootGet(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorRootGet(Exception exception, string pathFormat, string path); + /// /// /// @@ -163,13 +171,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions); - AfterRootGet(apiResponseLocalVar); + AfterRootGetDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -177,7 +183,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorRootGet(e, "/", uriBuilderLocalVar.Path); + OnErrorRootGetDefaultImplementation(e, "/", uriBuilderLocalVar.Path); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 93fb981a54a..bfc858f83a9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -34,7 +34,7 @@ namespace Org.OpenAPITools.Client HttpStatusCode StatusCode { get; } /// - /// The raw content of this response + /// The raw content of this response. /// string RawContent { get; } @@ -42,6 +42,16 @@ namespace Org.OpenAPITools.Client /// The DateTime when the request was retrieved. /// DateTime DownloadedAt { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The Uri used when making the request. + /// + Uri? RequestUri { get; } } /// @@ -88,6 +98,21 @@ namespace Org.OpenAPITools.Client /// public DateTime DownloadedAt { get; } = DateTime.UtcNow; + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri? RequestUri { get; } + /// /// The JsonSerialzierOptions /// @@ -99,14 +124,19 @@ namespace Org.OpenAPITools.Client /// /// /// + /// + /// /// - public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) { StatusCode = httpResponseMessage.StatusCode; Headers = httpResponseMessage.Headers; IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; ReasonPhrase = httpResponseMessage.ReasonPhrase; RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; _jsonSerializerOptions = jsonSerializerOptions; OnCreated(httpRequestMessage, httpResponseMessage); } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 964291f9c20..3fb5de6c1f2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -117,15 +117,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatCall123TestSpecialTags(ModelClient modelClient); /// @@ -150,22 +141,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterCall123TestSpecialTags(ApiResponse apiResponseLocalVar, ModelClient modelClient) + private void AfterCall123TestSpecialTagsDefaultImplementation(ApiResponse apiResponseLocalVar, ModelClient modelClient) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterCall123TestSpecialTags(apiResponseLocalVar, modelClient); } /// /// Processes the server response /// + /// + /// + partial void AfterCall123TestSpecialTags(ApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorCall123TestSpecialTags(Exception exception, string pathFormat, string path, ModelClient modelClient) + private void OnErrorCall123TestSpecialTagsDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorCall123TestSpecialTags(exception, pathFormat, path, modelClient); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorCall123TestSpecialTags(Exception exception, string pathFormat, string path, ModelClient modelClient); + /// /// To test special tags To test special tags and operation ID starting with number /// @@ -237,13 +247,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/another-fake/dummy", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); - AfterCall123TestSpecialTags(apiResponseLocalVar, modelClient); + AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient); return apiResponseLocalVar; } @@ -251,7 +259,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorCall123TestSpecialTags(e, "/another-fake/dummy", uriBuilderLocalVar.Path, modelClient); + OnErrorCall123TestSpecialTagsDefaultImplementation(e, "/another-fake/dummy", uriBuilderLocalVar.Path, modelClient); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs index 04dbe8b985a..452370b0cc1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -160,33 +160,41 @@ namespace Org.OpenAPITools.Api } /// - /// Logs the api response + /// Processes the server response /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) + /// + private void AfterFooGetDefaultImplementation(ApiResponse apiResponseLocalVar) { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFooGet(apiResponseLocalVar); } /// /// Processes the server response /// /// - protected virtual void AfterFooGet(ApiResponse apiResponseLocalVar) - { - } + partial void AfterFooGet(ApiResponse apiResponseLocalVar); /// - /// Processes the server response + /// Logs exceptions that occur while retrieving the server response /// /// /// /// - protected virtual void OnErrorFooGet(Exception exception, string pathFormat, string path) + private void OnErrorFooGetDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFooGet(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorFooGet(Exception exception, string pathFormat, string path); + /// /// /// @@ -239,13 +247,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/foo", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); - AfterFooGet(apiResponseLocalVar); + AfterFooGetDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -253,7 +259,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFooGet(e, "/foo", uriBuilderLocalVar.Path); + OnErrorFooGetDefaultImplementation(e, "/foo", uriBuilderLocalVar.Path); throw; } } @@ -282,22 +288,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterGetCountry(ApiResponse apiResponseLocalVar, string country) + private void AfterGetCountryDefaultImplementation(ApiResponse apiResponseLocalVar, string country) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetCountry(apiResponseLocalVar, country); } /// /// Processes the server response /// + /// + /// + partial void AfterGetCountry(ApiResponse apiResponseLocalVar, string country); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorGetCountry(Exception exception, string pathFormat, string path, string country) + private void OnErrorGetCountryDefaultImplementation(Exception exception, string pathFormat, string path, string country) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetCountry(exception, pathFormat, path, country); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetCountry(Exception exception, string pathFormat, string path, string country); + /// /// /// @@ -367,13 +392,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/country", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetCountry(apiResponseLocalVar, country); + AfterGetCountryDefaultImplementation(apiResponseLocalVar, country); return apiResponseLocalVar; } @@ -381,7 +404,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetCountry(e, "/country", uriBuilderLocalVar.Path, country); + OnErrorGetCountryDefaultImplementation(e, "/country", uriBuilderLocalVar.Path, country); throw; } } @@ -390,21 +413,38 @@ namespace Org.OpenAPITools.Api /// Processes the server response /// /// - protected virtual void AfterHello(ApiResponse> apiResponseLocalVar) + private void AfterHelloDefaultImplementation(ApiResponse> apiResponseLocalVar) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterHello(apiResponseLocalVar); } /// /// Processes the server response /// + /// + partial void AfterHello(ApiResponse> apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// - protected virtual void OnErrorHello(Exception exception, string pathFormat, string path) + private void OnErrorHelloDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorHello(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorHello(Exception exception, string pathFormat, string path); + /// /// Hello Hello /// @@ -457,13 +497,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/hello", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); - AfterHello(apiResponseLocalVar); + AfterHelloDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -471,7 +509,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorHello(e, "/hello", uriBuilderLocalVar.Path); + OnErrorHelloDefaultImplementation(e, "/hello", uriBuilderLocalVar.Path); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeApi.cs index 58116f2264d..2c368dcb45c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeApi.cs @@ -500,33 +500,41 @@ namespace Org.OpenAPITools.Api } /// - /// Logs the api response + /// Processes the server response /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) + /// + private void AfterFakeHealthGetDefaultImplementation(ApiResponse apiResponseLocalVar) { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeHealthGet(apiResponseLocalVar); } /// /// Processes the server response /// /// - protected virtual void AfterFakeHealthGet(ApiResponse apiResponseLocalVar) - { - } + partial void AfterFakeHealthGet(ApiResponse apiResponseLocalVar); /// - /// Processes the server response + /// Logs exceptions that occur while retrieving the server response /// /// /// /// - protected virtual void OnErrorFakeHealthGet(Exception exception, string pathFormat, string path) + private void OnErrorFakeHealthGetDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeHealthGet(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorFakeHealthGet(Exception exception, string pathFormat, string path); + /// /// Health check endpoint /// @@ -579,13 +587,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/health", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeHealthGet(apiResponseLocalVar); + AfterFakeHealthGetDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -593,7 +599,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeHealthGet(e, "/fake/health", uriBuilderLocalVar.Path); + OnErrorFakeHealthGetDefaultImplementation(e, "/fake/health", uriBuilderLocalVar.Path); throw; } } @@ -605,22 +611,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFakeOuterBooleanSerialize(ApiResponse apiResponseLocalVar, bool? body) + private void AfterFakeOuterBooleanSerializeDefaultImplementation(ApiResponse apiResponseLocalVar, bool? body) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeOuterBooleanSerialize(apiResponseLocalVar, body); } /// /// Processes the server response /// + /// + /// + partial void AfterFakeOuterBooleanSerialize(ApiResponse apiResponseLocalVar, bool? body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFakeOuterBooleanSerialize(Exception exception, string pathFormat, string path, bool? body) + private void OnErrorFakeOuterBooleanSerializeDefaultImplementation(Exception exception, string pathFormat, string path, bool? body) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeOuterBooleanSerialize(exception, pathFormat, path, body); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterBooleanSerialize(Exception exception, string pathFormat, string path, bool? body); + /// /// Test serialization of outer boolean types /// @@ -690,13 +715,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/outer/boolean", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeOuterBooleanSerialize(apiResponseLocalVar, body); + AfterFakeOuterBooleanSerializeDefaultImplementation(apiResponseLocalVar, body); return apiResponseLocalVar; } @@ -704,7 +727,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeOuterBooleanSerialize(e, "/fake/outer/boolean", uriBuilderLocalVar.Path, body); + OnErrorFakeOuterBooleanSerializeDefaultImplementation(e, "/fake/outer/boolean", uriBuilderLocalVar.Path, body); throw; } } @@ -716,22 +739,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFakeOuterCompositeSerialize(ApiResponse apiResponseLocalVar, OuterComposite outerComposite) + private void AfterFakeOuterCompositeSerializeDefaultImplementation(ApiResponse apiResponseLocalVar, OuterComposite outerComposite) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeOuterCompositeSerialize(apiResponseLocalVar, outerComposite); } /// /// Processes the server response /// + /// + /// + partial void AfterFakeOuterCompositeSerialize(ApiResponse apiResponseLocalVar, OuterComposite outerComposite); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFakeOuterCompositeSerialize(Exception exception, string pathFormat, string path, OuterComposite outerComposite) + private void OnErrorFakeOuterCompositeSerializeDefaultImplementation(Exception exception, string pathFormat, string path, OuterComposite outerComposite) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeOuterCompositeSerialize(exception, pathFormat, path, outerComposite); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterCompositeSerialize(Exception exception, string pathFormat, string path, OuterComposite outerComposite); + /// /// Test serialization of object with outer number type /// @@ -801,13 +843,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/outer/composite", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeOuterCompositeSerialize(apiResponseLocalVar, outerComposite); + AfterFakeOuterCompositeSerializeDefaultImplementation(apiResponseLocalVar, outerComposite); return apiResponseLocalVar; } @@ -815,7 +855,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeOuterCompositeSerialize(e, "/fake/outer/composite", uriBuilderLocalVar.Path, outerComposite); + OnErrorFakeOuterCompositeSerializeDefaultImplementation(e, "/fake/outer/composite", uriBuilderLocalVar.Path, outerComposite); throw; } } @@ -827,22 +867,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFakeOuterNumberSerialize(ApiResponse apiResponseLocalVar, decimal? body) + private void AfterFakeOuterNumberSerializeDefaultImplementation(ApiResponse apiResponseLocalVar, decimal? body) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeOuterNumberSerialize(apiResponseLocalVar, body); } /// /// Processes the server response /// + /// + /// + partial void AfterFakeOuterNumberSerialize(ApiResponse apiResponseLocalVar, decimal? body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFakeOuterNumberSerialize(Exception exception, string pathFormat, string path, decimal? body) + private void OnErrorFakeOuterNumberSerializeDefaultImplementation(Exception exception, string pathFormat, string path, decimal? body) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeOuterNumberSerialize(exception, pathFormat, path, body); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterNumberSerialize(Exception exception, string pathFormat, string path, decimal? body); + /// /// Test serialization of outer number types /// @@ -912,13 +971,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/outer/number", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeOuterNumberSerialize(apiResponseLocalVar, body); + AfterFakeOuterNumberSerializeDefaultImplementation(apiResponseLocalVar, body); return apiResponseLocalVar; } @@ -926,7 +983,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeOuterNumberSerialize(e, "/fake/outer/number", uriBuilderLocalVar.Path, body); + OnErrorFakeOuterNumberSerializeDefaultImplementation(e, "/fake/outer/number", uriBuilderLocalVar.Path, body); throw; } } @@ -956,23 +1013,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFakeOuterStringSerialize(ApiResponse apiResponseLocalVar, Guid requiredStringUuid, string body) + private void AfterFakeOuterStringSerializeDefaultImplementation(ApiResponse apiResponseLocalVar, Guid requiredStringUuid, string body) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFakeOuterStringSerialize(apiResponseLocalVar, requiredStringUuid, body); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterFakeOuterStringSerialize(ApiResponse apiResponseLocalVar, Guid requiredStringUuid, string body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorFakeOuterStringSerialize(Exception exception, string pathFormat, string path, Guid requiredStringUuid, string body) + private void OnErrorFakeOuterStringSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Guid requiredStringUuid, string body) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFakeOuterStringSerialize(exception, pathFormat, path, requiredStringUuid, body); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterStringSerialize(Exception exception, string pathFormat, string path, Guid requiredStringUuid, string body); + /// /// Test serialization of outer string types /// @@ -1052,13 +1130,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/outer/string", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); - AfterFakeOuterStringSerialize(apiResponseLocalVar, requiredStringUuid, body); + AfterFakeOuterStringSerializeDefaultImplementation(apiResponseLocalVar, requiredStringUuid, body); return apiResponseLocalVar; } @@ -1066,7 +1142,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFakeOuterStringSerialize(e, "/fake/outer/string", uriBuilderLocalVar.Path, requiredStringUuid, body); + OnErrorFakeOuterStringSerializeDefaultImplementation(e, "/fake/outer/string", uriBuilderLocalVar.Path, requiredStringUuid, body); throw; } } @@ -1075,21 +1151,38 @@ namespace Org.OpenAPITools.Api /// Processes the server response /// /// - protected virtual void AfterGetArrayOfEnums(ApiResponse> apiResponseLocalVar) + private void AfterGetArrayOfEnumsDefaultImplementation(ApiResponse> apiResponseLocalVar) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetArrayOfEnums(apiResponseLocalVar); } /// /// Processes the server response /// + /// + partial void AfterGetArrayOfEnums(ApiResponse> apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// - protected virtual void OnErrorGetArrayOfEnums(Exception exception, string pathFormat, string path) + private void OnErrorGetArrayOfEnumsDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetArrayOfEnums(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorGetArrayOfEnums(Exception exception, string pathFormat, string path); + /// /// Array of Enums /// @@ -1142,13 +1235,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/array-of-enums", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetArrayOfEnums(apiResponseLocalVar); + AfterGetArrayOfEnumsDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -1156,7 +1247,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetArrayOfEnums(e, "/fake/array-of-enums", uriBuilderLocalVar.Path); + OnErrorGetArrayOfEnumsDefaultImplementation(e, "/fake/array-of-enums", uriBuilderLocalVar.Path); throw; } } @@ -1185,22 +1276,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestBodyWithFileSchema(ApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass) + private void AfterTestBodyWithFileSchemaDefaultImplementation(ApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestBodyWithFileSchema(apiResponseLocalVar, fileSchemaTestClass); } /// /// Processes the server response /// + /// + /// + partial void AfterTestBodyWithFileSchema(ApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorTestBodyWithFileSchema(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass) + private void OnErrorTestBodyWithFileSchemaDefaultImplementation(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestBodyWithFileSchema(exception, pathFormat, path, fileSchemaTestClass); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTestBodyWithFileSchema(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass); + /// /// For this test, the body for this request much reference a schema named `File`. /// @@ -1264,13 +1374,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/body-with-file-schema", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestBodyWithFileSchema(apiResponseLocalVar, fileSchemaTestClass); + AfterTestBodyWithFileSchemaDefaultImplementation(apiResponseLocalVar, fileSchemaTestClass); return apiResponseLocalVar; } @@ -1278,7 +1386,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestBodyWithFileSchema(e, "/fake/body-with-file-schema", uriBuilderLocalVar.Path, fileSchemaTestClass); + OnErrorTestBodyWithFileSchemaDefaultImplementation(e, "/fake/body-with-file-schema", uriBuilderLocalVar.Path, fileSchemaTestClass); throw; } } @@ -1312,23 +1420,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestBodyWithQueryParams(ApiResponse apiResponseLocalVar, User user, string query) + private void AfterTestBodyWithQueryParamsDefaultImplementation(ApiResponse apiResponseLocalVar, User user, string query) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestBodyWithQueryParams(apiResponseLocalVar, user, query); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterTestBodyWithQueryParams(ApiResponse apiResponseLocalVar, User user, string query); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorTestBodyWithQueryParams(Exception exception, string pathFormat, string path, User user, string query) + private void OnErrorTestBodyWithQueryParamsDefaultImplementation(Exception exception, string pathFormat, string path, User user, string query) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestBodyWithQueryParams(exception, pathFormat, path, user, query); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestBodyWithQueryParams(Exception exception, string pathFormat, string path, User user, string query); + /// /// /// @@ -1400,13 +1529,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/body-with-query-params", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestBodyWithQueryParams(apiResponseLocalVar, user, query); + AfterTestBodyWithQueryParamsDefaultImplementation(apiResponseLocalVar, user, query); return apiResponseLocalVar; } @@ -1414,7 +1541,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestBodyWithQueryParams(e, "/fake/body-with-query-params", uriBuilderLocalVar.Path, user, query); + OnErrorTestBodyWithQueryParamsDefaultImplementation(e, "/fake/body-with-query-params", uriBuilderLocalVar.Path, user, query); throw; } } @@ -1443,22 +1570,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestClientModel(ApiResponse apiResponseLocalVar, ModelClient modelClient) + private void AfterTestClientModelDefaultImplementation(ApiResponse apiResponseLocalVar, ModelClient modelClient) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestClientModel(apiResponseLocalVar, modelClient); } /// /// Processes the server response /// + /// + /// + partial void AfterTestClientModel(ApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorTestClientModel(Exception exception, string pathFormat, string path, ModelClient modelClient) + private void OnErrorTestClientModelDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestClientModel(exception, pathFormat, path, modelClient); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTestClientModel(Exception exception, string pathFormat, string path, ModelClient modelClient); + /// /// To test \"client\" model To test \"client\" model /// @@ -1530,13 +1676,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestClientModel(apiResponseLocalVar, modelClient); + AfterTestClientModelDefaultImplementation(apiResponseLocalVar, modelClient); return apiResponseLocalVar; } @@ -1544,7 +1688,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestClientModel(e, "/fake", uriBuilderLocalVar.Path, modelClient); + OnErrorTestClientModelDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, modelClient); throw; } } @@ -1598,13 +1742,35 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestEndpointParameters(ApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream binary, float? varFloat, int? integer, int? int32, long? int64, string varString, string password, string callback, DateTime? dateTime) + private void AfterTestEndpointParametersDefaultImplementation(ApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream binary, float? varFloat, int? integer, int? int32, long? int64, string varString, string password, string callback, DateTime? dateTime) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestEndpointParameters(apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); } /// /// Processes the server response /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestEndpointParameters(ApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream binary, float? varFloat, int? integer, int? int32, long? int64, string varString, string password, string callback, DateTime? dateTime); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// @@ -1622,11 +1788,34 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void OnErrorTestEndpointParameters(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream binary, float? varFloat, int? integer, int? int32, long? int64, string varString, string password, string callback, DateTime? dateTime) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream binary, float? varFloat, int? integer, int? int32, long? int64, string varString, string password, string callback, DateTime? dateTime) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestEndpointParameters(exception, pathFormat, path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestEndpointParameters(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime? date, System.IO.Stream binary, float? varFloat, int? integer, int? int32, long? int64, string varString, string password, string callback, DateTime? dateTime); + /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 /// @@ -1766,13 +1955,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestEndpointParameters(apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + AfterTestEndpointParametersDefaultImplementation(apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1784,7 +1971,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestEndpointParameters(e, "/fake", uriBuilderLocalVar.Path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + OnErrorTestEndpointParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); throw; } } @@ -1803,13 +1990,29 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestEnumParameters(ApiResponse apiResponseLocalVar, List enumHeaderStringArray, List enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List enumFormStringArray, string enumHeaderString, string enumQueryString, string enumFormString) + private void AfterTestEnumParametersDefaultImplementation(ApiResponse apiResponseLocalVar, List enumHeaderStringArray, List enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List enumFormStringArray, string enumHeaderString, string enumQueryString, string enumFormString) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestEnumParameters(apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); } /// /// Processes the server response /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestEnumParameters(ApiResponse apiResponseLocalVar, List enumHeaderStringArray, List enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List enumFormStringArray, string enumHeaderString, string enumQueryString, string enumFormString); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// @@ -1821,11 +2024,28 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void OnErrorTestEnumParameters(Exception exception, string pathFormat, string path, List enumHeaderStringArray, List enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List enumFormStringArray, string enumHeaderString, string enumQueryString, string enumFormString) + private void OnErrorTestEnumParametersDefaultImplementation(Exception exception, string pathFormat, string path, List enumHeaderStringArray, List enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List enumFormStringArray, string enumHeaderString, string enumQueryString, string enumFormString) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestEnumParameters(exception, pathFormat, path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestEnumParameters(Exception exception, string pathFormat, string path, List enumHeaderStringArray, List enumQueryStringArray, double? enumQueryDouble, int? enumQueryInteger, List enumFormStringArray, string enumHeaderString, string enumQueryString, string enumFormString); + /// /// To test enum parameters To test enum parameters /// @@ -1931,13 +2151,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestEnumParameters(apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + AfterTestEnumParametersDefaultImplementation(apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); return apiResponseLocalVar; } @@ -1945,7 +2163,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestEnumParameters(e, "/fake", uriBuilderLocalVar.Path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + OnErrorTestEnumParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); throw; } } @@ -1987,13 +2205,27 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestGroupParameters(ApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group) + private void AfterTestGroupParametersDefaultImplementation(ApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestGroupParameters(apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); } /// /// Processes the server response /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestGroupParameters(ApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// @@ -2003,11 +2235,26 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void OnErrorTestGroupParameters(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group) + private void OnErrorTestGroupParametersDefaultImplementation(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestGroupParameters(exception, pathFormat, path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestGroupParameters(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool? booleanGroup, int? stringGroup, long? int64Group); + /// /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) /// @@ -2093,13 +2340,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestGroupParameters(apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + AfterTestGroupParametersDefaultImplementation(apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -2111,7 +2356,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestGroupParameters(e, "/fake", uriBuilderLocalVar.Path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + OnErrorTestGroupParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); throw; } } @@ -2140,22 +2385,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestInlineAdditionalProperties(ApiResponse apiResponseLocalVar, Dictionary requestBody) + private void AfterTestInlineAdditionalPropertiesDefaultImplementation(ApiResponse apiResponseLocalVar, Dictionary requestBody) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestInlineAdditionalProperties(apiResponseLocalVar, requestBody); } /// /// Processes the server response /// + /// + /// + partial void AfterTestInlineAdditionalProperties(ApiResponse apiResponseLocalVar, Dictionary requestBody); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorTestInlineAdditionalProperties(Exception exception, string pathFormat, string path, Dictionary requestBody) + private void OnErrorTestInlineAdditionalPropertiesDefaultImplementation(Exception exception, string pathFormat, string path, Dictionary requestBody) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestInlineAdditionalProperties(exception, pathFormat, path, requestBody); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTestInlineAdditionalProperties(Exception exception, string pathFormat, string path, Dictionary requestBody); + /// /// test inline additionalProperties /// @@ -2219,13 +2483,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestInlineAdditionalProperties(apiResponseLocalVar, requestBody); + AfterTestInlineAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, requestBody); return apiResponseLocalVar; } @@ -2233,7 +2495,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestInlineAdditionalProperties(e, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path, requestBody); + OnErrorTestInlineAdditionalPropertiesDefaultImplementation(e, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path, requestBody); throw; } } @@ -2267,23 +2529,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestJsonFormData(ApiResponse apiResponseLocalVar, string param, string param2) + private void AfterTestJsonFormDataDefaultImplementation(ApiResponse apiResponseLocalVar, string param, string param2) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestJsonFormData(apiResponseLocalVar, param, param2); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterTestJsonFormData(ApiResponse apiResponseLocalVar, string param, string param2); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorTestJsonFormData(Exception exception, string pathFormat, string path, string param, string param2) + private void OnErrorTestJsonFormDataDefaultImplementation(Exception exception, string pathFormat, string path, string param, string param2) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestJsonFormData(exception, pathFormat, path, param, param2); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestJsonFormData(Exception exception, string pathFormat, string path, string param, string param2); + /// /// test json serialization of form data /// @@ -2357,13 +2640,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/jsonFormData", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestJsonFormData(apiResponseLocalVar, param, param2); + AfterTestJsonFormDataDefaultImplementation(apiResponseLocalVar, param, param2); return apiResponseLocalVar; } @@ -2371,7 +2652,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestJsonFormData(e, "/fake/jsonFormData", uriBuilderLocalVar.Path, param, param2); + OnErrorTestJsonFormDataDefaultImplementation(e, "/fake/jsonFormData", uriBuilderLocalVar.Path, param, param2); throw; } } @@ -2420,13 +2701,26 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestQueryParameterCollectionFormat(ApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context) + private void AfterTestQueryParameterCollectionFormatDefaultImplementation(ApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestQueryParameterCollectionFormat(apiResponseLocalVar, pipe, ioutil, http, url, context); } /// /// Processes the server response /// + /// + /// + /// + /// + /// + /// + partial void AfterTestQueryParameterCollectionFormat(ApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// @@ -2435,11 +2729,25 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void OnErrorTestQueryParameterCollectionFormat(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context) + private void OnErrorTestQueryParameterCollectionFormatDefaultImplementation(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestQueryParameterCollectionFormat(exception, pathFormat, path, pipe, ioutil, http, url, context); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestQueryParameterCollectionFormat(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context); + /// /// To test the collection format in query parameters /// @@ -2507,13 +2815,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/test-query-parameters", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestQueryParameterCollectionFormat(apiResponseLocalVar, pipe, ioutil, http, url, context); + AfterTestQueryParameterCollectionFormatDefaultImplementation(apiResponseLocalVar, pipe, ioutil, http, url, context); return apiResponseLocalVar; } @@ -2521,7 +2827,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestQueryParameterCollectionFormat(e, "/fake/test-query-parameters", uriBuilderLocalVar.Path, pipe, ioutil, http, url, context); + OnErrorTestQueryParameterCollectionFormatDefaultImplementation(e, "/fake/test-query-parameters", uriBuilderLocalVar.Path, pipe, ioutil, http, url, context); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 64c8e8c1df9..e4b8c682efe 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -117,15 +117,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatTestClassname(ModelClient modelClient); /// @@ -150,22 +141,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterTestClassname(ApiResponse apiResponseLocalVar, ModelClient modelClient) + private void AfterTestClassnameDefaultImplementation(ApiResponse apiResponseLocalVar, ModelClient modelClient) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterTestClassname(apiResponseLocalVar, modelClient); } /// /// Processes the server response /// + /// + /// + partial void AfterTestClassname(ApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorTestClassname(Exception exception, string pathFormat, string path, ModelClient modelClient) + private void OnErrorTestClassnameDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorTestClassname(exception, pathFormat, path, modelClient); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTestClassname(Exception exception, string pathFormat, string path, ModelClient modelClient); + /// /// To test class name in snake case To test class name in snake case /// @@ -248,13 +258,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake_classname_test", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); - AfterTestClassname(apiResponseLocalVar, modelClient); + AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -266,7 +274,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorTestClassname(e, "/fake_classname_test", uriBuilderLocalVar.Path, modelClient); + OnErrorTestClassnameDefaultImplementation(e, "/fake_classname_test", uriBuilderLocalVar.Path, modelClient); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/PetApi.cs index 8190c03bbc8..e603798f661 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/PetApi.cs @@ -315,15 +315,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatAddPet(Pet pet); /// @@ -348,22 +339,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterAddPet(ApiResponse apiResponseLocalVar, Pet pet) + private void AfterAddPetDefaultImplementation(ApiResponse apiResponseLocalVar, Pet pet) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterAddPet(apiResponseLocalVar, pet); } /// /// Processes the server response /// + /// + /// + partial void AfterAddPet(ApiResponse apiResponseLocalVar, Pet pet); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorAddPet(Exception exception, string pathFormat, string path, Pet pet) + private void OnErrorAddPetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorAddPet(exception, pathFormat, path, pet); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorAddPet(Exception exception, string pathFormat, string path, Pet pet); + /// /// Add a new pet to the store /// @@ -444,13 +454,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); - AfterAddPet(apiResponseLocalVar, pet); + AfterAddPetDefaultImplementation(apiResponseLocalVar, pet); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -466,7 +474,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorAddPet(e, "/pet", uriBuilderLocalVar.Path, pet); + OnErrorAddPetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); throw; } } @@ -496,23 +504,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterDeletePet(ApiResponse apiResponseLocalVar, long petId, string apiKey) + private void AfterDeletePetDefaultImplementation(ApiResponse apiResponseLocalVar, long petId, string apiKey) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterDeletePet(apiResponseLocalVar, petId, apiKey); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterDeletePet(ApiResponse apiResponseLocalVar, long petId, string apiKey); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorDeletePet(Exception exception, string pathFormat, string path, long petId, string apiKey) + private void OnErrorDeletePetDefaultImplementation(Exception exception, string pathFormat, string path, long petId, string apiKey) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorDeletePet(exception, pathFormat, path, petId, apiKey); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorDeletePet(Exception exception, string pathFormat, string path, long petId, string apiKey); + /// /// Deletes a pet /// @@ -576,13 +605,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/{petId}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); - AfterDeletePet(apiResponseLocalVar, petId, apiKey); + AfterDeletePetDefaultImplementation(apiResponseLocalVar, petId, apiKey); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -594,7 +621,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorDeletePet(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, apiKey); + OnErrorDeletePetDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, apiKey); throw; } } @@ -623,22 +650,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFindPetsByStatus(ApiResponse> apiResponseLocalVar, List status) + private void AfterFindPetsByStatusDefaultImplementation(ApiResponse> apiResponseLocalVar, List status) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFindPetsByStatus(apiResponseLocalVar, status); } /// /// Processes the server response /// + /// + /// + partial void AfterFindPetsByStatus(ApiResponse> apiResponseLocalVar, List status); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFindPetsByStatus(Exception exception, string pathFormat, string path, List status) + private void OnErrorFindPetsByStatusDefaultImplementation(Exception exception, string pathFormat, string path, List status) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFindPetsByStatus(exception, pathFormat, path, status); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFindPetsByStatus(Exception exception, string pathFormat, string path, List status); + /// /// Finds Pets by status Multiple status values can be provided with comma separated strings /// @@ -720,13 +766,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/findByStatus", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); - AfterFindPetsByStatus(apiResponseLocalVar, status); + AfterFindPetsByStatusDefaultImplementation(apiResponseLocalVar, status); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -742,7 +786,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFindPetsByStatus(e, "/pet/findByStatus", uriBuilderLocalVar.Path, status); + OnErrorFindPetsByStatusDefaultImplementation(e, "/pet/findByStatus", uriBuilderLocalVar.Path, status); throw; } } @@ -771,22 +815,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterFindPetsByTags(ApiResponse> apiResponseLocalVar, List tags) + private void AfterFindPetsByTagsDefaultImplementation(ApiResponse> apiResponseLocalVar, List tags) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterFindPetsByTags(apiResponseLocalVar, tags); } /// /// Processes the server response /// + /// + /// + partial void AfterFindPetsByTags(ApiResponse> apiResponseLocalVar, List tags); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorFindPetsByTags(Exception exception, string pathFormat, string path, List tags) + private void OnErrorFindPetsByTagsDefaultImplementation(Exception exception, string pathFormat, string path, List tags) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorFindPetsByTags(exception, pathFormat, path, tags); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFindPetsByTags(Exception exception, string pathFormat, string path, List tags); + /// /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// @@ -868,13 +931,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/findByTags", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); - AfterFindPetsByTags(apiResponseLocalVar, tags); + AfterFindPetsByTagsDefaultImplementation(apiResponseLocalVar, tags); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -890,7 +951,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorFindPetsByTags(e, "/pet/findByTags", uriBuilderLocalVar.Path, tags); + OnErrorFindPetsByTagsDefaultImplementation(e, "/pet/findByTags", uriBuilderLocalVar.Path, tags); throw; } } @@ -919,22 +980,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterGetPetById(ApiResponse apiResponseLocalVar, long petId) + private void AfterGetPetByIdDefaultImplementation(ApiResponse apiResponseLocalVar, long petId) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetPetById(apiResponseLocalVar, petId); } /// /// Processes the server response /// + /// + /// + partial void AfterGetPetById(ApiResponse apiResponseLocalVar, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorGetPetById(Exception exception, string pathFormat, string path, long petId) + private void OnErrorGetPetByIdDefaultImplementation(Exception exception, string pathFormat, string path, long petId) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetPetById(exception, pathFormat, path, petId); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetPetById(Exception exception, string pathFormat, string path, long petId); + /// /// Find pet by ID Returns a single pet /// @@ -1003,13 +1083,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/{petId}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetPetById(apiResponseLocalVar, petId); + AfterGetPetByIdDefaultImplementation(apiResponseLocalVar, petId); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1021,7 +1099,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetPetById(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId); + OnErrorGetPetByIdDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId); throw; } } @@ -1050,22 +1128,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUpdatePet(ApiResponse apiResponseLocalVar, Pet pet) + private void AfterUpdatePetDefaultImplementation(ApiResponse apiResponseLocalVar, Pet pet) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUpdatePet(apiResponseLocalVar, pet); } /// /// Processes the server response /// + /// + /// + partial void AfterUpdatePet(ApiResponse apiResponseLocalVar, Pet pet); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorUpdatePet(Exception exception, string pathFormat, string path, Pet pet) + private void OnErrorUpdatePetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUpdatePet(exception, pathFormat, path, pet); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorUpdatePet(Exception exception, string pathFormat, string path, Pet pet); + /// /// Update an existing pet /// @@ -1146,13 +1243,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); - AfterUpdatePet(apiResponseLocalVar, pet); + AfterUpdatePetDefaultImplementation(apiResponseLocalVar, pet); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1168,7 +1263,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUpdatePet(e, "/pet", uriBuilderLocalVar.Path, pet); + OnErrorUpdatePetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); throw; } } @@ -1199,24 +1294,47 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUpdatePetWithForm(ApiResponse apiResponseLocalVar, long petId, string name, string status) + private void AfterUpdatePetWithFormDefaultImplementation(ApiResponse apiResponseLocalVar, long petId, string name, string status) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUpdatePetWithForm(apiResponseLocalVar, petId, name, status); } /// /// Processes the server response /// + /// + /// + /// + /// + partial void AfterUpdatePetWithForm(ApiResponse apiResponseLocalVar, long petId, string name, string status); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// /// - protected virtual void OnErrorUpdatePetWithForm(Exception exception, string pathFormat, string path, long petId, string name, string status) + private void OnErrorUpdatePetWithFormDefaultImplementation(Exception exception, string pathFormat, string path, long petId, string name, string status) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUpdatePetWithForm(exception, pathFormat, path, petId, name, status); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUpdatePetWithForm(Exception exception, string pathFormat, string path, long petId, string name, string status); + /// /// Updates a pet in the store with form data /// @@ -1301,13 +1419,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/{petId}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); - AfterUpdatePetWithForm(apiResponseLocalVar, petId, name, status); + AfterUpdatePetWithFormDefaultImplementation(apiResponseLocalVar, petId, name, status); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1319,7 +1435,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUpdatePetWithForm(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, name, status); + OnErrorUpdatePetWithFormDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, name, status); throw; } } @@ -1350,24 +1466,47 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUploadFile(ApiResponse apiResponseLocalVar, long petId, System.IO.Stream file, string additionalMetadata) + private void AfterUploadFileDefaultImplementation(ApiResponse apiResponseLocalVar, long petId, System.IO.Stream file, string additionalMetadata) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUploadFile(apiResponseLocalVar, petId, file, additionalMetadata); } /// /// Processes the server response /// + /// + /// + /// + /// + partial void AfterUploadFile(ApiResponse apiResponseLocalVar, long petId, System.IO.Stream file, string additionalMetadata); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// /// - protected virtual void OnErrorUploadFile(Exception exception, string pathFormat, string path, long petId, System.IO.Stream file, string additionalMetadata) + private void OnErrorUploadFileDefaultImplementation(Exception exception, string pathFormat, string path, long petId, System.IO.Stream file, string additionalMetadata) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUploadFile(exception, pathFormat, path, petId, file, additionalMetadata); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFile(Exception exception, string pathFormat, string path, long petId, System.IO.Stream file, string additionalMetadata); + /// /// uploads an image /// @@ -1460,13 +1599,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); - AfterUploadFile(apiResponseLocalVar, petId, file, additionalMetadata); + AfterUploadFileDefaultImplementation(apiResponseLocalVar, petId, file, additionalMetadata); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1478,7 +1615,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUploadFile(e, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path, petId, file, additionalMetadata); + OnErrorUploadFileDefaultImplementation(e, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path, petId, file, additionalMetadata); throw; } } @@ -1513,24 +1650,47 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUploadFileWithRequiredFile(ApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, string additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(ApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, string additionalMetadata) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUploadFileWithRequiredFile(apiResponseLocalVar, requiredFile, petId, additionalMetadata); } /// /// Processes the server response /// + /// + /// + /// + /// + partial void AfterUploadFileWithRequiredFile(ApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, string additionalMetadata); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// /// - protected virtual void OnErrorUploadFileWithRequiredFile(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, string additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, string additionalMetadata) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUploadFileWithRequiredFile(exception, pathFormat, path, requiredFile, petId, additionalMetadata); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFileWithRequiredFile(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, string additionalMetadata); + /// /// uploads an image (required) /// @@ -1623,13 +1783,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); - AfterUploadFileWithRequiredFile(apiResponseLocalVar, requiredFile, petId, additionalMetadata); + AfterUploadFileWithRequiredFileDefaultImplementation(apiResponseLocalVar, requiredFile, petId, additionalMetadata); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -1641,7 +1799,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUploadFileWithRequiredFile(e, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path, requiredFile, petId, additionalMetadata); + OnErrorUploadFileWithRequiredFileDefaultImplementation(e, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path, requiredFile, petId, additionalMetadata); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/StoreApi.cs index 8a3434557af..f2e85a51dad 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/StoreApi.cs @@ -184,15 +184,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatDeleteOrder(ref string orderId); /// @@ -217,22 +208,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterDeleteOrder(ApiResponse apiResponseLocalVar, string orderId) + private void AfterDeleteOrderDefaultImplementation(ApiResponse apiResponseLocalVar, string orderId) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterDeleteOrder(apiResponseLocalVar, orderId); } /// /// Processes the server response /// + /// + /// + partial void AfterDeleteOrder(ApiResponse apiResponseLocalVar, string orderId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorDeleteOrder(Exception exception, string pathFormat, string path, string orderId) + private void OnErrorDeleteOrderDefaultImplementation(Exception exception, string pathFormat, string path, string orderId) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorDeleteOrder(exception, pathFormat, path, orderId); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorDeleteOrder(Exception exception, string pathFormat, string path, string orderId); + /// /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors /// @@ -283,13 +293,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/store/order/{order_id}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); - AfterDeleteOrder(apiResponseLocalVar, orderId); + AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId); return apiResponseLocalVar; } @@ -297,7 +305,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorDeleteOrder(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + OnErrorDeleteOrderDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); throw; } } @@ -306,21 +314,38 @@ namespace Org.OpenAPITools.Api /// Processes the server response /// /// - protected virtual void AfterGetInventory(ApiResponse> apiResponseLocalVar) + private void AfterGetInventoryDefaultImplementation(ApiResponse> apiResponseLocalVar) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetInventory(apiResponseLocalVar); } /// /// Processes the server response /// + /// + partial void AfterGetInventory(ApiResponse> apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// - protected virtual void OnErrorGetInventory(Exception exception, string pathFormat, string path) + private void OnErrorGetInventoryDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetInventory(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorGetInventory(Exception exception, string pathFormat, string path); + /// /// Returns pet inventories by status Returns a map of status codes to quantities /// @@ -381,13 +406,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/store/inventory", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse> apiResponseLocalVar = new ApiResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetInventory(apiResponseLocalVar); + AfterGetInventoryDefaultImplementation(apiResponseLocalVar); if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) @@ -399,7 +422,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetInventory(e, "/store/inventory", uriBuilderLocalVar.Path); + OnErrorGetInventoryDefaultImplementation(e, "/store/inventory", uriBuilderLocalVar.Path); throw; } } @@ -428,22 +451,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterGetOrderById(ApiResponse apiResponseLocalVar, long orderId) + private void AfterGetOrderByIdDefaultImplementation(ApiResponse apiResponseLocalVar, long orderId) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetOrderById(apiResponseLocalVar, orderId); } /// /// Processes the server response /// + /// + /// + partial void AfterGetOrderById(ApiResponse apiResponseLocalVar, long orderId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorGetOrderById(Exception exception, string pathFormat, string path, long orderId) + private void OnErrorGetOrderByIdDefaultImplementation(Exception exception, string pathFormat, string path, long orderId) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetOrderById(exception, pathFormat, path, orderId); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetOrderById(Exception exception, string pathFormat, string path, long orderId); + /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions /// @@ -504,13 +546,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/store/order/{order_id}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetOrderById(apiResponseLocalVar, orderId); + AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId); return apiResponseLocalVar; } @@ -518,7 +558,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetOrderById(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + OnErrorGetOrderByIdDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); throw; } } @@ -547,22 +587,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterPlaceOrder(ApiResponse apiResponseLocalVar, Order order) + private void AfterPlaceOrderDefaultImplementation(ApiResponse apiResponseLocalVar, Order order) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterPlaceOrder(apiResponseLocalVar, order); } /// /// Processes the server response /// + /// + /// + partial void AfterPlaceOrder(ApiResponse apiResponseLocalVar, Order order); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorPlaceOrder(Exception exception, string pathFormat, string path, Order order) + private void OnErrorPlaceOrderDefaultImplementation(Exception exception, string pathFormat, string path, Order order) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorPlaceOrder(exception, pathFormat, path, order); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorPlaceOrder(Exception exception, string pathFormat, string path, Order order); + /// /// Place an order for a pet /// @@ -635,13 +694,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/store/order", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); - AfterPlaceOrder(apiResponseLocalVar, order); + AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order); return apiResponseLocalVar; } @@ -649,7 +706,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorPlaceOrder(e, "/store/order", uriBuilderLocalVar.Path, order); + OnErrorPlaceOrderDefaultImplementation(e, "/store/order", uriBuilderLocalVar.Path, order); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/UserApi.cs index f73aa6c522d..8008571a648 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/UserApi.cs @@ -280,15 +280,6 @@ namespace Org.OpenAPITools.Api OauthTokenProvider = oauthTokenProvider; } - /// - /// Logs the api response - /// - /// - protected virtual void OnApiResponded(ApiResponseEventArgs args) - { - Logger.LogInformation("{0,-9} | {1} | {3}", (args.ReceivedAt - args.RequestedAt).TotalSeconds, args.HttpStatus, args.Path); - } - partial void FormatCreateUser(User user); /// @@ -313,22 +304,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterCreateUser(ApiResponse apiResponseLocalVar, User user) + private void AfterCreateUserDefaultImplementation(ApiResponse apiResponseLocalVar, User user) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterCreateUser(apiResponseLocalVar, user); } /// /// Processes the server response /// + /// + /// + partial void AfterCreateUser(ApiResponse apiResponseLocalVar, User user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorCreateUser(Exception exception, string pathFormat, string path, User user) + private void OnErrorCreateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorCreateUser(exception, pathFormat, path, user); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorCreateUser(Exception exception, string pathFormat, string path, User user); + /// /// Create user This can only be done by the logged in user. /// @@ -392,13 +402,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); - AfterCreateUser(apiResponseLocalVar, user); + AfterCreateUserDefaultImplementation(apiResponseLocalVar, user); return apiResponseLocalVar; } @@ -406,7 +414,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorCreateUser(e, "/user", uriBuilderLocalVar.Path, user); + OnErrorCreateUserDefaultImplementation(e, "/user", uriBuilderLocalVar.Path, user); throw; } } @@ -435,22 +443,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterCreateUsersWithArrayInput(ApiResponse apiResponseLocalVar, List user) + private void AfterCreateUsersWithArrayInputDefaultImplementation(ApiResponse apiResponseLocalVar, List user) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterCreateUsersWithArrayInput(apiResponseLocalVar, user); } /// /// Processes the server response /// + /// + /// + partial void AfterCreateUsersWithArrayInput(ApiResponse apiResponseLocalVar, List user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorCreateUsersWithArrayInput(Exception exception, string pathFormat, string path, List user) + private void OnErrorCreateUsersWithArrayInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorCreateUsersWithArrayInput(exception, pathFormat, path, user); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorCreateUsersWithArrayInput(Exception exception, string pathFormat, string path, List user); + /// /// Creates list of users with given input array /// @@ -514,13 +541,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/createWithArray", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); - AfterCreateUsersWithArrayInput(apiResponseLocalVar, user); + AfterCreateUsersWithArrayInputDefaultImplementation(apiResponseLocalVar, user); return apiResponseLocalVar; } @@ -528,7 +553,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorCreateUsersWithArrayInput(e, "/user/createWithArray", uriBuilderLocalVar.Path, user); + OnErrorCreateUsersWithArrayInputDefaultImplementation(e, "/user/createWithArray", uriBuilderLocalVar.Path, user); throw; } } @@ -557,22 +582,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterCreateUsersWithListInput(ApiResponse apiResponseLocalVar, List user) + private void AfterCreateUsersWithListInputDefaultImplementation(ApiResponse apiResponseLocalVar, List user) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterCreateUsersWithListInput(apiResponseLocalVar, user); } /// /// Processes the server response /// + /// + /// + partial void AfterCreateUsersWithListInput(ApiResponse apiResponseLocalVar, List user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorCreateUsersWithListInput(Exception exception, string pathFormat, string path, List user) + private void OnErrorCreateUsersWithListInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorCreateUsersWithListInput(exception, pathFormat, path, user); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorCreateUsersWithListInput(Exception exception, string pathFormat, string path, List user); + /// /// Creates list of users with given input array /// @@ -636,13 +680,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/createWithList", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); - AfterCreateUsersWithListInput(apiResponseLocalVar, user); + AfterCreateUsersWithListInputDefaultImplementation(apiResponseLocalVar, user); return apiResponseLocalVar; } @@ -650,7 +692,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorCreateUsersWithListInput(e, "/user/createWithList", uriBuilderLocalVar.Path, user); + OnErrorCreateUsersWithListInputDefaultImplementation(e, "/user/createWithList", uriBuilderLocalVar.Path, user); throw; } } @@ -679,22 +721,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterDeleteUser(ApiResponse apiResponseLocalVar, string username) + private void AfterDeleteUserDefaultImplementation(ApiResponse apiResponseLocalVar, string username) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterDeleteUser(apiResponseLocalVar, username); } /// /// Processes the server response /// + /// + /// + partial void AfterDeleteUser(ApiResponse apiResponseLocalVar, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorDeleteUser(Exception exception, string pathFormat, string path, string username) + private void OnErrorDeleteUserDefaultImplementation(Exception exception, string pathFormat, string path, string username) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorDeleteUser(exception, pathFormat, path, username); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorDeleteUser(Exception exception, string pathFormat, string path, string username); + /// /// Delete user This can only be done by the logged in user. /// @@ -745,13 +806,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/{username}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); - AfterDeleteUser(apiResponseLocalVar, username); + AfterDeleteUserDefaultImplementation(apiResponseLocalVar, username); return apiResponseLocalVar; } @@ -759,7 +818,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorDeleteUser(e, "/user/{username}", uriBuilderLocalVar.Path, username); + OnErrorDeleteUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); throw; } } @@ -788,22 +847,41 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterGetUserByName(ApiResponse apiResponseLocalVar, string username) + private void AfterGetUserByNameDefaultImplementation(ApiResponse apiResponseLocalVar, string username) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterGetUserByName(apiResponseLocalVar, username); } /// /// Processes the server response /// + /// + /// + partial void AfterGetUserByName(ApiResponse apiResponseLocalVar, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// - protected virtual void OnErrorGetUserByName(Exception exception, string pathFormat, string path, string username) + private void OnErrorGetUserByNameDefaultImplementation(Exception exception, string pathFormat, string path, string username) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorGetUserByName(exception, pathFormat, path, username); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetUserByName(Exception exception, string pathFormat, string path, string username); + /// /// Get user by user name /// @@ -864,13 +942,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/{username}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); - AfterGetUserByName(apiResponseLocalVar, username); + AfterGetUserByNameDefaultImplementation(apiResponseLocalVar, username); return apiResponseLocalVar; } @@ -878,7 +954,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorGetUserByName(e, "/user/{username}", uriBuilderLocalVar.Path, username); + OnErrorGetUserByNameDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); throw; } } @@ -912,23 +988,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterLoginUser(ApiResponse apiResponseLocalVar, string username, string password) + private void AfterLoginUserDefaultImplementation(ApiResponse apiResponseLocalVar, string username, string password) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterLoginUser(apiResponseLocalVar, username, password); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterLoginUser(ApiResponse apiResponseLocalVar, string username, string password); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorLoginUser(Exception exception, string pathFormat, string path, string username, string password) + private void OnErrorLoginUserDefaultImplementation(Exception exception, string pathFormat, string path, string username, string password) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorLoginUser(exception, pathFormat, path, username, password); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorLoginUser(Exception exception, string pathFormat, string path, string username, string password); + /// /// Logs user into the system /// @@ -997,13 +1094,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/login", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); - AfterLoginUser(apiResponseLocalVar, username, password); + AfterLoginUserDefaultImplementation(apiResponseLocalVar, username, password); return apiResponseLocalVar; } @@ -1011,7 +1106,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorLoginUser(e, "/user/login", uriBuilderLocalVar.Path, username, password); + OnErrorLoginUserDefaultImplementation(e, "/user/login", uriBuilderLocalVar.Path, username, password); throw; } } @@ -1020,21 +1115,38 @@ namespace Org.OpenAPITools.Api /// Processes the server response /// /// - protected virtual void AfterLogoutUser(ApiResponse apiResponseLocalVar) + private void AfterLogoutUserDefaultImplementation(ApiResponse apiResponseLocalVar) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterLogoutUser(apiResponseLocalVar); } /// /// Processes the server response /// + /// + partial void AfterLogoutUser(ApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// - protected virtual void OnErrorLogoutUser(Exception exception, string pathFormat, string path) + private void OnErrorLogoutUserDefaultImplementation(Exception exception, string pathFormat, string path) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorLogoutUser(exception, pathFormat, path); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + partial void OnErrorLogoutUser(Exception exception, string pathFormat, string path); + /// /// Logs out current logged in user session /// @@ -1078,13 +1190,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/logout", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); - AfterLogoutUser(apiResponseLocalVar); + AfterLogoutUserDefaultImplementation(apiResponseLocalVar); return apiResponseLocalVar; } @@ -1092,7 +1202,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorLogoutUser(e, "/user/logout", uriBuilderLocalVar.Path); + OnErrorLogoutUserDefaultImplementation(e, "/user/logout", uriBuilderLocalVar.Path); throw; } } @@ -1126,23 +1236,44 @@ namespace Org.OpenAPITools.Api /// /// /// - protected virtual void AfterUpdateUser(ApiResponse apiResponseLocalVar, User user, string username) + private void AfterUpdateUserDefaultImplementation(ApiResponse apiResponseLocalVar, User user, string username) { + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + AfterUpdateUser(apiResponseLocalVar, user, username); } /// /// Processes the server response /// + /// + /// + /// + partial void AfterUpdateUser(ApiResponse apiResponseLocalVar, User user, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// /// /// /// /// /// - protected virtual void OnErrorUpdateUser(Exception exception, string pathFormat, string path, User user, string username) + private void OnErrorUpdateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user, string username) { Logger.LogError(exception, "An error occurred while sending the request to the server."); + OnErrorUpdateUser(exception, pathFormat, path, user, username); } + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorUpdateUser(Exception exception, string pathFormat, string path, User user, string username); + /// /// Updated user This can only be done by the logged in user. /// @@ -1209,13 +1340,11 @@ namespace Org.OpenAPITools.Api using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) { - OnApiResponded(new ApiResponseEventArgs(requestedAtLocalVar, DateTime.UtcNow, httpResponseMessageLocalVar.StatusCode, "/user/{username}", uriBuilderLocalVar.Path)); - string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, _jsonSerializerOptions); + ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); - AfterUpdateUser(apiResponseLocalVar, user, username); + AfterUpdateUserDefaultImplementation(apiResponseLocalVar, user, username); return apiResponseLocalVar; } @@ -1223,7 +1352,7 @@ namespace Org.OpenAPITools.Api } catch(Exception e) { - OnErrorUpdateUser(e, "/user/{username}", uriBuilderLocalVar.Path, user, username); + OnErrorUpdateUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, user, username); throw; } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 256b4e02d8e..4151923257b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -32,7 +32,7 @@ namespace Org.OpenAPITools.Client HttpStatusCode StatusCode { get; } /// - /// The raw content of this response + /// The raw content of this response. /// string RawContent { get; } @@ -40,6 +40,16 @@ namespace Org.OpenAPITools.Client /// The DateTime when the request was retrieved. /// DateTime DownloadedAt { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The Uri used when making the request. + /// + Uri RequestUri { get; } } /// @@ -86,6 +96,21 @@ namespace Org.OpenAPITools.Client /// public DateTime DownloadedAt { get; } = DateTime.UtcNow; + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri RequestUri { get; } + /// /// The JsonSerialzierOptions /// @@ -97,14 +122,19 @@ namespace Org.OpenAPITools.Client /// /// /// + /// + /// /// - public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) { StatusCode = httpResponseMessage.StatusCode; Headers = httpResponseMessage.Headers; IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; ReasonPhrase = httpResponseMessage.ReasonPhrase; RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; _jsonSerializerOptions = jsonSerializerOptions; OnCreated(httpRequestMessage, httpResponseMessage); }