簡體   English   中英

Swagger 3.0 ASP.NET 核心 - 如何在請求正文和響應中添加 Model 架構的文檔

[英]Swagger 3.0 ASP.NET Core - How to add documentation for Model Schema in request Body and Response

我有 REST API 主體的 model 架構並作為響應。 The XML comments have been defined but I cannot figure out a way to include the XML documentation for the model schema in Swagger UI 3.0 both in API body and in response ?

在此處輸入圖像描述

我錯過了這個,它現在可以工作了。 我將架構分布在不同的 asp.net 核心組件上,而 Swagger UI 3.0 確實支持添加多個 XML 源。

要包含 controller 評論本身,我們必須設置 includeControllerXmlComments: true

c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "test1.xml"), includeControllerXmlComments: true);
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "test2.xml"), includeControllerXmlComments: true);
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "test3.xml"), includeControllerXmlComments: true);

您可以參考此鏈接Similar question以獲得您所需的解決方案。

或者

您還可以查看官方文檔以啟用 XML 對數據 model 的注釋。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM