asp.net-core - 如何在 ASP.NET Core API 中的 Swagger 中将注释显示为描述段落

标签 asp.net-core swagger

我在 asp.net-core 中有一个 Web api,我想知道如何将段落作为端点的描述?我尝试了

\n\n ,没有任何效果。我将描述放在“备注”xml 中。

谢谢

最佳答案

首先,您必须configure Swashbuckle to use the documentation XML .

然后,使用 <summary> and <remarks> tags操作摘要和说明。

/// <summary>
/// Summary for ActionWithSummaryAndRemarksTags
/// </summary>
/// <remarks>
/// Remarks for ActionWithSummaryAndRemarksTags
/// </remarks>
public ActionResult ActionWithSummaryAndRemarksTags()

您可以使用 Markdown 构建更复杂的文档:

/// <summary>
/// This is a short summary
/// </summary>
/// <remarks>
/// ## Usage
/// ...
/// ```
/// <![CDATA[
/// {
///   "html": "<h1>escape HTML with CDATA blocks</h1><img src=\"https://unsplash.it/400/200\" />"
/// }
/// ]]>
/// ```
///
/// ### A title
/// A paragrapth with [a link](https://example.com).
/// 
/// ```html
/// <h1>hello world, this is a code block</h1>
/// <img src="data:image/jpg,base64;..." />
/// ```
/// This is an inline code `https://unsplash.it/200/100`.
///
/// This is a separate paragraph
/// </remarks>

关于asp.net-core - 如何在 ASP.NET Core API 中的 Swagger 中将注释显示为描述段落,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68582366/

相关文章:

asp.net-core - 将选项迁移到 ASPNET Core RC2

c# - 从主体生成泛型参数的 swagger 模型

ruby-on-rails - 我在哪里可以将 Swagger-UI 放在带有 Grape 的 Rails 应用程序中?

javascript - Swagger参数多态性

go - 如何在 Swagger 中创建前缀路由

asp.net-core - 如何在不访问请求的情况下获取基本网址

c# - 当@Model 是任务时访问@Model

c# - Asp.Net 5. Jwt token 撤销

c# - Swagger 无法在自托管的 ServiceStack 服务上工作

swagger - Springfox 类参数已弃用