aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/src/Utilities
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-11-14 07:56:56 +0100
committerivarlovlie <git@ivarlovlie.no>2022-11-14 08:05:36 +0100
commit4b5597b3fe6e02f1655e6a731e83bdcdf1017d63 (patch)
tree818580507641787380b58bdcfa7d0ed7026f4e82 /code/api/src/Utilities
parent99b0c09a6bb984d811b63788015cfad1855b5f3c (diff)
downloadgreatoffice-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.cs58
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