[英]XML inline comments are not included in the generated swagger.json
The generated swagger.json file do not include XML inline comments for methods that I have override. 生成的swagger.json文件不包含我已重写的方法的XML内联注释。 For all other methods the inline comments are included in the generated swagger.json. 对于所有其他方法,行内注释包含在生成的swagger.json中。 The xml file include all comments so that file seems to be correct. xml文件包含所有注释,因此该文件似乎是正确的。 All the routes are working as they should. 所有路线都按预期运行。
Why aren't all XML comments included in the generated swagger.json? 为什么未在生成的swagger.json中包含所有XML注释?
PetsApi.cs
public abstract class PetsApiController : Controller
{
/// <summary>
/// Create a pet. 27th of Sept
/// </summary>
/// <response code="201">Null response</response>
/// <response code="0">unexpected error</response>
[HttpPost]
[Route("/v1/pets")]
[SwaggerOperation("CreatePets")]
public virtual void CreatePets()
{
throw new NotImplementedException();
}
/// <summary>
/// List all pets. 27th of Sept
/// </summary>
/// <param name="limit">How many items to return at one time (max 100)</param>
/// <response code="200">An paged array of pets</response>
/// <response code="0">unexpected error</response>
[HttpGet]
[Route("/v1/pets")]
[SwaggerOperation("ListPets")]
[SwaggerResponse(200, type: typeof(Pets))]
public virtual IActionResult ListPets([FromQuery]int? limit)
{
string exampleJson = null;
And then I override CreatePets by: 然后通过以下方法覆盖CreatePets:
public class TestOfPets : Controllers.PetsApiController
{
public override void CreatePets()
{
int testing;
The outcome in Swagger UI will then be like this, Swagger UI Swagger UI中的结果将是这样, Swagger UI
As you can see the POST operation don't have any comments, why? 如您所见,POST操作没有任何注释,为什么?
The startUp.cs include this configuration: startUp.cs包含以下配置:
var basePath = PlatformServices.Default.Application.ApplicationBasePath;
var xmlPath = Path.Combine(basePath, "controllapi.xml");
myData.IncludeXmlComments(xmlPath)
The controllapi.xml don't include anything related to TestOfPets. controllapi.xml不包含与TestOfPets相关的任何内容。 It only include PetsApiController.CreatePets. 它仅包含PetsApiController.CreatePets。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.