如果希望接口是每次通过配置文件生成的,这样设计一些低代码的方式来获得接口。
系统目录结构:
启动配置代码:
using Microsoft.AspNetCore.Hosting;
using System.Configuration;
using System.Data.Entity;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Reflection;
using AutoMapDBCreateApi.Models;
using AutoMapDBCreateApi.Filters;
var builder = WebApplication.CreateBuilder(args);
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.Build();
var endpointsConfig = configuration.GetSection("Endpoints").Get<List<EndpointConfig>>();
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo {
Title = "动态接口管理Swagger平台", Version = "v1" });
// 为 Swagger 设置xml文档注释路径
var xmlFile = $"{