簡體   English   中英

可能用於 swagger 文檔的 XML 標簽/函數?

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

例如,我記得讀過您可以通過編寫類似於以下內容的 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 和 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()

這是在 UI 中的樣子:
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)

表格在 UI 上有點拉長:
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