mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-18 09:44:28 +08:00
🐛fix:修复正式环境没有关闭SWAGGER
This commit is contained in:
@@ -38,6 +38,7 @@ OpenAuth.Net是一个基于.NET 9的企业级权限管理和快速开发框架
|
||||
- 私有字段使用_camelCase,公共属性使用PascalCase
|
||||
- 常量使用UPPER_CASE
|
||||
- 异步方法必须添加Async后缀
|
||||
- 修改完代码后不需要编译
|
||||
|
||||
### 命名规范
|
||||
- **Controller**: 以Controller结尾,如`UsersController`
|
||||
|
@@ -28,6 +28,11 @@ RUN dotnet publish -c Release -o /app/publish/identity
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
|
||||
# 设置 Production 环境变量
|
||||
ENV ASPNETCORE_ENVIRONMENT=Production
|
||||
ENV DOTNET_ENVIRONMENT=Production
|
||||
|
||||
# 复制 WebApi 发布文件
|
||||
COPY --from=build /app/publish/webapi ./webapi
|
||||
|
||||
|
@@ -275,29 +275,31 @@ namespace OpenAuth.WebApi
|
||||
app.UseMiniProfiler();
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseSwagger();
|
||||
|
||||
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
|
||||
// specifying the Swagger JSON endpoint.
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.IndexStream = () =>
|
||||
IntrospectionExtensions.GetTypeInfo(GetType()).Assembly
|
||||
.GetManifestResourceStream("OpenAuth.WebApi.index.html");
|
||||
|
||||
foreach (var controller in GetControllers())
|
||||
{
|
||||
var groupname = GetSwaggerGroupName(controller);
|
||||
|
||||
c.SwaggerEndpoint($"/swagger/{groupname}/swagger.json", groupname);
|
||||
}
|
||||
|
||||
c.DocExpansion(DocExpansion.List); //默认展开列表
|
||||
c.OAuthClientId("OpenAuth.WebApi"); //oauth客户端名称
|
||||
c.OAuthAppName("开源版webapi认证"); // 描述
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
|
||||
// specifying the Swagger JSON endpoint.
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.IndexStream = () =>
|
||||
IntrospectionExtensions.GetTypeInfo(GetType()).Assembly
|
||||
.GetManifestResourceStream("OpenAuth.WebApi.index.html");
|
||||
|
||||
foreach (var controller in GetControllers())
|
||||
{
|
||||
var groupname = GetSwaggerGroupName(controller);
|
||||
|
||||
c.SwaggerEndpoint($"/swagger/{groupname}/swagger.json", groupname);
|
||||
}
|
||||
|
||||
c.DocExpansion(DocExpansion.List); //默认展开列表
|
||||
c.OAuthClientId("OpenAuth.WebApi"); //oauth客户端名称
|
||||
c.OAuthAppName("开源版webapi认证"); // 描述
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user