-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApiDescriptionExtension.cs
More file actions
31 lines (30 loc) · 963 Bytes
/
ApiDescriptionExtension.cs
File metadata and controls
31 lines (30 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace System.Web.Http.Description
{
/// <summary>
/// API Descriptor Extension
/// </summary>
public static class ApiDescriptionExtension
{
/// <summary>
/// Get the region name
/// </summary>
/// <param name="description"></param>
/// <returns></returns>
public static List<string> GetAreaName(this ApiDescription description)
{
string areaName = description.ActionDescriptor.RouteValues["path"];
string controlName = description.ActionDescriptor.RouteValues["controller"];
List<string> areaList = new List<string>();
areaList.Add(controlName);
if (!string.IsNullOrEmpty(areaName))
{
description.RelativePath = $"{areaName}/{controlName}/{description.RelativePath}";
}
return areaList;
}
}
}