|
|
@ -1,21 +1,17 @@
|
|
|
|
using Durkee.Mes.Api.Config;
|
|
|
|
using Durkee.Mes.Api.Config;
|
|
|
|
using Durkee.Mes.Api.Model;
|
|
|
|
|
|
|
|
using Durkee.Mes.Api.Repository;
|
|
|
|
using Durkee.Mes.Api.Repository;
|
|
|
|
using Durkee.Mes.Api.Repository.service;
|
|
|
|
|
|
|
|
using Durkee.Mes.Api.Repository.service.Impl;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
using Microsoft.IdentityModel.Logging;
|
|
|
|
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
using Serilog;
|
|
|
|
using Serilog;
|
|
|
|
using Serilog.Events;
|
|
|
|
using Serilog.Events;
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Durkee.Mes.Api
|
|
|
|
namespace Durkee.Mes.Api
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -36,7 +32,27 @@ namespace Durkee.Mes.Api
|
|
|
|
//配置Swagger
|
|
|
|
//配置Swagger
|
|
|
|
services.AddSwaggerGen(swagger =>
|
|
|
|
services.AddSwaggerGen(swagger =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
swagger.SwaggerDoc("v1", new OpenApiInfo { Title = "杜肯MES Web Api", Version = "v1" });
|
|
|
|
//自定义接口信息
|
|
|
|
|
|
|
|
swagger.SwaggerDoc("V1.0", new OpenApiInfo {
|
|
|
|
|
|
|
|
Title = "杜肯MES Web Api",
|
|
|
|
|
|
|
|
Version = "V1.0",
|
|
|
|
|
|
|
|
Description = $"API版本V1.0",
|
|
|
|
|
|
|
|
Contact = new OpenApiContact
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Name = "MES Web Api",
|
|
|
|
|
|
|
|
Email = "wenjy@mesnac.com"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//自定义实体别名
|
|
|
|
|
|
|
|
swagger.CustomSchemaIds(type => type.GetCustomAttributes(typeof(DataContractAttribute), true)
|
|
|
|
|
|
|
|
.Cast<DataContractAttribute>()
|
|
|
|
|
|
|
|
.FirstOrDefault()?.Name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//配置Action名称
|
|
|
|
|
|
|
|
var path = Path.Combine(AppContext.BaseDirectory, "Durkee.Mes.Api.xml");
|
|
|
|
|
|
|
|
swagger.IncludeXmlComments(path, true); // true : 显示控制器层注释
|
|
|
|
|
|
|
|
swagger.OrderActionsBy(o => o.RelativePath); // 对action的名称进行排序,如果有多个,就可以看见效果了。
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//注册配置类
|
|
|
|
//注册配置类
|
|
|
@ -65,10 +81,8 @@ namespace Durkee.Mes.Api
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI(c =>
|
|
|
|
app.UseSwaggerUI(c =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "杜肯MES Web Api");
|
|
|
|
c.SwaggerEndpoint("/swagger/V1.0/swagger.json", "杜肯MES Web Api V1.0");
|
|
|
|
c.RoutePrefix = "";
|
|
|
|
c.RoutePrefix = "";
|
|
|
|
//c.DefaultModelRendering(ModelRendering.Example); // 设置默认的模型渲染方式(可选)
|
|
|
|
|
|
|
|
//c.DisplayRequestDuration(); // 显示请求持续时间(可选)
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//启用Serilog中间件
|
|
|
|
//启用Serilog中间件
|
|
|
|