mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-28 04:36:38 +08:00
@@ -1,73 +1,17 @@
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.Swashbuckle;
|
||||
using Yi.Framework.Application;
|
||||
using Yi.Framework.Sqlsugar;
|
||||
using StartupModules;
|
||||
|
||||
namespace Yi.Framework.Web
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(AbpSwashbuckleModule),
|
||||
typeof(YiFrameworkApplicationModule),
|
||||
typeof(YiFrameworkSqlsugarModule),
|
||||
typeof(AbpAspNetCoreMvcModule)
|
||||
|
||||
)]
|
||||
public class YiFrameworkWebModule : AbpModule
|
||||
public class YiFrameworkWebModule : IStartupModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||
{
|
||||
|
||||
ConfigureAutoApiControllers();
|
||||
|
||||
|
||||
ConfigureSwaggerServices(context.Services);
|
||||
|
||||
}
|
||||
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
||||
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||
{
|
||||
var app = context.GetApplicationBuilder();
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseAbpSwaggerUI(options =>
|
||||
{
|
||||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "YiFramework API");
|
||||
});
|
||||
app.UseConfiguredEndpoints();
|
||||
}
|
||||
|
||||
private void ConfigureAutoApiControllers()
|
||||
{
|
||||
Configure<AbpAspNetCoreMvcOptions>(options =>
|
||||
{
|
||||
options.ConventionalControllers.Create(typeof(YiFrameworkApplicationModule).Assembly);
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureSwaggerServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSwaggerGen(
|
||||
options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new OpenApiInfo { Title = "YiFramework API", Version = "v1" });
|
||||
options.DocInclusionPredicate((docName, description) => true);
|
||||
options.CustomSchemaIds(type => type.FullName);
|
||||
var basePath = Path.GetDirectoryName(this.GetType().Assembly.Location);
|
||||
if (basePath is not null)
|
||||
{
|
||||
foreach (var item in Directory.GetFiles(basePath, "*.xml"))
|
||||
{
|
||||
options.IncludeXmlComments(item, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
Console.WriteLine("还有谁");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user