diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-11-14 07:56:56 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-11-14 08:05:36 +0100 |
| commit | 4b5597b3fe6e02f1655e6a731e83bdcdf1017d63 (patch) | |
| tree | 818580507641787380b58bdcfa7d0ed7026f4e82 /code/api/src/Utilities | |
| parent | 99b0c09a6bb984d811b63788015cfad1855b5f3c (diff) | |
| download | greatoffice-4b5597b3fe6e02f1655e6a731e83bdcdf1017d63.tar.xz greatoffice-4b5597b3fe6e02f1655e6a731e83bdcdf1017d63.zip | |
refactor: Api files always returns Response
Diffstat (limited to 'code/api/src/Utilities')
| -rw-r--r-- | code/api/src/Utilities/SwaggerGenOptionsExtensions.cs | 58 |
1 files changed, 29 insertions, 29 deletions
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 { - /// <summary> - /// Updates Swagger document to support ApiEndpoints.<br/><br/> - /// For controllers inherited from <see cref="EndpointBase"/>:<br/> - /// - Replaces action Tag with <c>[namespace]</c><br/> - /// </summary> - public static void UseApiEndpoints(this SwaggerGenOptions options) { - options.TagActionsBy(EndpointNamespaceOrDefault); - } + /// <summary> + /// Updates Swagger document to support ApiEndpoints.<br/><br/> + /// For controllers inherited from <see cref="EndpointBase"/>:<br/> + /// - Replaces action Tag with <c>[namespace]</c><br/> + /// </summary> + public static void UseApiEndpoints(this SwaggerGenOptions options) { + options.TagActionsBy(EndpointNamespaceOrDefault); + } - private static IList<string?> 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<string?> 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<Type> GetBaseTypesAndThis(this Type type) { - var current = type; - while (current != null) { - yield return current; - current = current.BaseType; - } - } -} + private static IEnumerable<Type> GetBaseTypesAndThis(this Type type) { + var current = type; + while (current != null) { + yield return current; + current = current.BaseType; + } + } +}
\ No newline at end of file |
