asp.net-core - 如何在 ASP.NET Core API 的 Swagger 中将注释显示为描述段落
问题描述
我在 asp.net-core 中有一个 web api,我想知道如何将段落作为描述放在端点上?我试过
\n \n ,没有任何效果。我将描述放在“备注”xml 中。
谢谢
解决方案
首先,您必须配置 Swashbuckle 以使用文档 XML。
然后,使用<summary>
和<remarks>
标记进行操作摘要和描述。
/// <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>
推荐阅读
- json - Elasticsearch API 从路径插入数据
- php - 如何向 FancyBox 添加删除按钮
- swift - 缺少带有默认参数的声明
- postgresql - Corda 企业节点上的 PostgreSQL 引发关系错误
- codeigniter - CodeIgniter:将 index.php 保留在 url 中并隐藏其余部分
- debugging - 缺少 Nsight 菜单 Visual Studio 2015
- c# - 数据绑定 Pivot 控件,同时在每个 Pivot 项数据模板内进行数据绑定
- python - PyTorch - 被覆盖的变量是否留在图中?
- erlang - mnesia 表的大小(以 MB 为单位)
- ubuntu - 如何从特定目录中选择日志并在 Kibana 上显示