mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:23:25 +08:00
添加项目文件。
This commit is contained in:
13
CoreCms.Net.Swagger/CoreCms.Net.Swagger.csproj
Normal file
13
CoreCms.Net.Swagger/CoreCms.Net.Swagger.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.2.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
41
CoreCms.Net.Swagger/CustomApiVersion.cs
Normal file
41
CoreCms.Net.Swagger/CustomApiVersion.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms.Net *
|
||||
* Web: https://CoreCms.Net *
|
||||
* ProjectName: 核心内容管理系统 *
|
||||
* Author: 大灰灰 *
|
||||
* Email: JianWeie@163.com *
|
||||
* Versions: 1.0 *
|
||||
* CreateTime: 2020-02-02 18:53:03
|
||||
* NameSpace: CoreCms.Net.Framework.Swagger
|
||||
* FileName: CustomApiVersion
|
||||
* ClassDescription:
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CoreCms.Net.Swagger
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义版本
|
||||
/// </summary>
|
||||
public class CustomApiVersion
|
||||
{
|
||||
/// <summary>
|
||||
/// Api接口版本 自定义
|
||||
/// </summary>
|
||||
public enum ApiVersions
|
||||
{
|
||||
/// <summary>
|
||||
/// V1 版本
|
||||
/// </summary>
|
||||
V1 = 1,
|
||||
/// <summary>
|
||||
/// V2 版本
|
||||
/// </summary>
|
||||
V2 = 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
52
CoreCms.Net.Swagger/CustomRouteAttribute.cs
Normal file
52
CoreCms.Net.Swagger/CustomRouteAttribute.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms.Net *
|
||||
* Web: https://CoreCms.Net *
|
||||
* ProjectName: 核心内容管理系统 *
|
||||
* Author: 大灰灰 *
|
||||
* Email: JianWeie@163.com *
|
||||
* Versions: 1.0 *
|
||||
* CreateTime: 2020-02-02 18:53:27
|
||||
* NameSpace: CoreCms.Net.Framework.Swagger
|
||||
* FileName: CustomRouteAttribute
|
||||
* ClassDescription:
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
|
||||
namespace CoreCms.Net.Swagger
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义路由 /api/{version}/[controler]/[action]
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
|
||||
public class CustomRouteAttribute : RouteAttribute, IApiDescriptionGroupNameProvider
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 分组名称,是来实现接口 IApiDescriptionGroupNameProvider
|
||||
/// </summary>
|
||||
public string GroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义路由构造函数,继承基类路由
|
||||
/// </summary>
|
||||
/// <param name="actionName"></param>
|
||||
public CustomRouteAttribute(string actionName = "[action]") : base("/api/{version}/[controller]/" + actionName)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// 自定义版本+路由构造函数,继承基类路由
|
||||
/// </summary>
|
||||
/// <param name="actionName"></param>
|
||||
/// <param name="version"></param>
|
||||
public CustomRouteAttribute(CustomApiVersion.ApiVersions version, string actionName = "") : base($"/api/{version.ToString()}/[controller]/{actionName}")
|
||||
{
|
||||
GroupName = version.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user