From 4b5597b3fe6e02f1655e6a731e83bdcdf1017d63 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Mon, 14 Nov 2022 13:56:56 +0700 Subject: refactor: Api files always returns Response --- .../src/Utilities/SwaggerGenOptionsExtensions.cs | 58 +++++++++++----------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'code/api/src/Utilities/SwaggerGenOptionsExtensions.cs') diff --git a/code/api/src/Utilities/SwaggerGenOptionsExtensions.cs b/code/api/src/Utilities/SwaggerGenOptionsExtensions.cs index 9b70194..a3d9036 100644 --- a/code/api/src/Utilities/SwaggerGenOptionsExtensions.cs +++ b/code/api/src/Utilities/SwaggerGenOptionsExtensions.cs @@ -8,36 +8,36 @@ namespace IOL.GreatOffice.Api.Utilities; public static class SwaggerGenOptionsExtensions { - /// - /// Updates Swagger document to support ApiEndpoints.

- /// For controllers inherited from :
- /// - Replaces action Tag with [namespace]
- ///
- public static void UseApiEndpoints(this SwaggerGenOptions options) { - options.TagActionsBy(EndpointNamespaceOrDefault); - } + /// + /// Updates Swagger document to support ApiEndpoints.

+ /// For controllers inherited from :
+ /// - Replaces action Tag with [namespace]
+ ///
+ public static void UseApiEndpoints(this SwaggerGenOptions options) { + options.TagActionsBy(EndpointNamespaceOrDefault); + } - private static IList EndpointNamespaceOrDefault(ApiDescription api) { - if (api.ActionDescriptor is not ControllerActionDescriptor actionDescriptor) { - throw new InvalidOperationException($"Unable to determine tag for endpoint: {api.ActionDescriptor.DisplayName}"); - } + private static IList EndpointNamespaceOrDefault(ApiDescription api) { + if (api.ActionDescriptor is not ControllerActionDescriptor actionDescriptor) { + throw new InvalidOperationException($"Unable to determine tag for endpoint: {api.ActionDescriptor.DisplayName}"); + } - if (actionDescriptor.ControllerTypeInfo.GetBaseTypesAndThis().Any(t => t == typeof(EndpointBase))) { - return new[] { - actionDescriptor.ControllerTypeInfo.Namespace?.Split('.').Last() - }; - } + if (actionDescriptor.ControllerTypeInfo.GetBaseTypesAndThis().Any(t => t == typeof(EndpointBase))) { + return new[] { + actionDescriptor.ControllerTypeInfo.Namespace?.Split('.').Last() + }; + } - return new[] { - actionDescriptor.ControllerName - }; - } + return new[] { + actionDescriptor.ControllerName + }; + } - public static IEnumerable GetBaseTypesAndThis(this Type type) { - var current = type; - while (current != null) { - yield return current; - current = current.BaseType; - } - } -} + private static IEnumerable GetBaseTypesAndThis(this Type type) { + var current = type; + while (current != null) { + yield return current; + current = current.BaseType; + } + } +} \ No newline at end of file -- cgit v1.3