我在 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/