【发布时间】:2015-08-01 18:14:36
【问题描述】:
我有一个 ASP.NET Web Api 2 应用程序。我在其中添加了 Swashbuckle(Swagger for .NET)。它显示我的端点没有问题,但为了发送请求,我需要将 Authorization 标头附加到该请求。如果我理解正确,我需要修改 index.html 文件 (https://github.com/swagger-api/swagger-ui#how-to-use-it),所以我 git 克隆了 Swashbuckle 项目以修改 index.html 并添加一些标题。
这是在 Swashbuckle 中随请求发送 Authorization 标头的唯一方法吗?
【问题讨论】:
-
@AlbertoPellizzon - 我将在哪里添加该代码?什么文件?
-
在 swaggerUi 初始化后尝试搜索初始化位置,例如 var swaggerUi = new SwaggerUi({});
-
我的代码中没有类似的东西。我有: GlobalConfiguration.Configuration .EnableSwagger(c => { c.SingleApiVersion("v1", "MyApplication"); }) .EnableSwaggerUi(c => {}));在 SwaggerConfig.cs 中
-
对,看来我必须修改包含一些 javascript 的 index.html。当我把它完全排序后,我会回答这个问题。
标签: swagger swagger-ui swashbuckle swagger-2.0