.net core 如何在方法描述中使用html和Swagger UI?
我正在使用Swashback.AspNetCore来可视化我的.NET核心API资源并与之交互。我正试图用html格式化Swagger上的API方法描述,以便用户知道最近添加了这个方法 但我还没有找到如何做到这一点。我在摘要的XML文档注释中添加了html字符串,但作为字符串返回。同时,我能够让它在回应上起作用 我如何才能让它工作起来,或者使用一些“浮华”的方式来提供新方法,以便用户注意到它们是新的或更新的?这是我在控制器中的方法代码.net core 如何在方法描述中使用html和Swagger UI?,.net-core,swagger,swagger-ui,.net Core,Swagger,Swagger Ui,我正在使用Swashback.AspNetCore来可视化我的.NET核心API资源并与之交互。我正试图用html格式化Swagger上的API方法描述,以便用户知道最近添加了这个方法 但我还没有找到如何做到这一点。我在摘要的XML文档注释中添加了html字符串,但作为字符串返回。同时,我能够让它在回应上起作用 我如何才能让它工作起来,或者使用一些“浮华”的方式来提供新方法,以便用户注意到它们是新的或更新的?这是我在控制器中的方法代码 /// <summary> //
/// <summary>
/// <span style="font-size: 20px;color: red;">☆New method!</span>
/// </summary>
/// <returns>Gets the user commerce data</returns>
/// <response code="200"><div><span style="font-size: 20px;color: red;">Returns user commerce data</span></div></response>
/// <response code="401">User not authenticated</response>
/// <response code="404">Error: Not Found</response>
[HttpGet]
[SwaggerResponse(200, Type = typeof(CommerceUserProfile))]
[ProducesResponseType(401, Type = typeof(UnauthorizedResult))]
[ProducesResponseType(404, Type = typeof(NotFoundResult))]
public async Task<ActionResult<CommerceUserProfile>> Get()
这就是正在生成的内容。我想像在响应中一样,使用html格式化get描述。斯威格故意转义摘要内容 我认为这真的不可能实现你想要的 也不支持降价,以便能够在摘要中使用它。但斯威格在其他一些场景中也支持它
services.AddSwaggerGen(swagger =>
{
swagger.SwaggerDoc("v1", new Info { Title = "API", Version = "v1" });
var xmlPath = Path.Combine(AppContext.BaseDirectory, "CommerceWebAPI.xml");
swagger.IncludeXmlComments(xmlPath);
}