You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
1010 B

using Microsoft.AspNetCore.Mvc.ApiExplorer;
using System.Collections.Generic;
namespace Znyc.Cloudcar.Admin.Commons.Extensions
{
/// <summary>
/// API描述器扩展
/// </summary>
public static class ApiDescriptionExtension
{
/// <summary>
/// 获取区域名称
/// </summary>
/// <param name="description"></param>
/// <returns></returns>
public static List<string> GetAreaName(this ApiDescription description)
{
string areaName = description.ActionDescriptor.RouteValues["area"];
string controlName = description.ActionDescriptor.RouteValues["controller"];
List<string> areaList = new List<string>
{
controlName
};
if (!string.IsNullOrEmpty(areaName))
{
description.RelativePath = $"api/{areaName}/{controlName}/{description.RelativePath}";
}
return areaList;
}
}
}