简体   繁体   English

可能用于 swagger 文档的 XML 标签/函数?

[英]Possible XML tags/functions for use in swagger documentations?

For example, I remember reading that you could make a table in XML by writing something similar to the following:例如,我记得读过您可以通过编写类似于以下内容的 XML 来制作表格:

||__Column__||                              
||    row   ||

Sadly, I can't remember the source, or what it was called.可悲的是,我不记得来源,或者它叫什么。 Is there a place that has documented all these neat little things, if not, could someone shine some light on them?有没有一个地方记录了所有这些整洁的小东西,如果没有,有人可以对它们有所了解吗?

I'm not entirely sure if the above was exclusive to swashbuckle, or general XML.我不完全确定以上是否是 swashbuckle 或一般 XML 独有的。 Please edit this question if it's about XML in general.如果是关于 XML 的一般问题,请编辑此问题。 If you can't - let me know.如果你不能 - 让我知道。

Basic XML documentation looks like this:基本的 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)

Worth pointing out you do have to enable that:值得指出的是,您必须启用:
https://github.com/domaindrivendev/Swashbuckle.AspNetCore#include-descriptions-from-xml-comments https://github.com/domaindrivendev/Swashbuckle.AspNetCore#include-descriptions-from-xml-comments

The table you show looks like markup maybe what you trying to do is add that in the documentation...您显示的表格看起来像标记,也许您想要做的是在文档中添加它...
You can include more in the <remarks> , HTML and Markup is valid syntax您可以在<remarks>包含更多内容,HTML 和 Markup 是有效语法

    /// <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()

Here is how that looks like in the UI:这是在 UI 中的样子:
http://swagger-net-test.azurewebsites.net/swagger/ui/index?filter=ApiExplorer#/ApiExplorer/ApiExplorer_Get http://swagger-net-test.azurewebsites.net/swagger/ui/index?filter=ApiExplorer#/ApiExplorer/ApiExplorer_Get


Here is a markup table这是一个标记表

    ///<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)

The table is a bit stretched out on the UI:表格在 UI 上有点拉长:
http://swagger-net-test.azurewebsites.net/swagger/ui/index?filter=ArrayTest#/ArrayTest/ArrayTest_Post http://swagger-net-test.azurewebsites.net/swagger/ui/index?filter=ArrayTest#/ArrayTest/ArrayTest_Post

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM