例如,我记得阅读过您可以通过编写类似于以下内容的内容来以XML形式创建表:
||__Column__||
|| row ||
可悲的是,我不记得来源或它的名字了。是否有一个地方记录了所有这些整洁的小东西,如果没有,有人可以照亮它们吗?
我不完全确定上述内容是否是swashbuckle或通用XML所独有的。如果是关于XML的,请编辑此问题。如果不能,请告诉我。
基本XML文档看起来像这样:
/// <summary>
/// Retrieves a specific product by unique id
/// </summary>
/// <remarks>Awesomeness!</remarks>
/// <response code="200">Product created</response>
/// <response code="400">Product has missing/invalid values</response>
/// <response code="500">Oops! Can't create your product right now</response>
[HttpGet("{id}")]
[ProducesResponseType(typeof(Product), 200)]
[ProducesResponseType(typeof(IDictionary<string, string>), 400)]
[ProducesResponseType(500)]
public Product GetById(int id)
值得指出的是,您必须启用以下功能:https://github.com/domaindrivendev/Swashbuckle.AspNetCore#include-descriptions-from-xml-comments
您显示的表看起来像是标记,也许您想做的就是在文档中添加它...您可以在<remarks>
中包含更多内容,HTML和标记是有效语法
/// <summary>
/// Testing the summary on the ApiExplorerController
/// </summary>
///
/// <remarks>
/// Testing the description on the ApiExplorerController
/// This is a second line
/// Here is a link to <a href="https://github.com/heldersepu">my GitHub profile</a>
/// <br/>
/// Some HTML styling: <b>BOLD</b> <i>italics</i>
/// <ul>
/// <li>Item one</li>
/// <li>Item two</li>
/// </ul>
/// <pre>Text in a pre element</pre>
///
/// <h1>Header1</h1>
/// <h2>Header2</h2>
/// <h3>Header3</h3>
/// </remarks>
public IEnumerable<string> Get()
以下是用户界面中的外观:http://swagger-net-test.azurewebsites.net/swagger/ui/index?filter=ApiExplorer#/ApiExplorer/ApiExplorer_Get
这里是标记表
///<summary>Post</summary>
/// <remarks>
/// Testing Markdown table
/// | a | b | c | d | e |
/// |---|---|---|---|---|
/// | 3 | 0 | 7 | 4 | 1 |
/// | 4 | 1 | 8 | 5 | 2 |
/// | 5 | 2 | 9 | 6 | 3 |
/// </remarks>
[Route("Post Arrays")]
public Arrays Post(Arrays arrays)