2017-09-27 40 views
0

生成swagger.json文件不包括我有重写方法XML内部注释。对于所有其他方法,内联注释都包含在生成的swagger.json中。 xml文件包含所有注释,以便文件看起来是正确的。所有的路线都按照他们应有的方式工作。XML内嵌注释不包括在生成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; 

然后我会覆盖CreatePets:

public class TestOfPets : Controllers.PetsApiController 
{ 
    public override void CreatePets() 
    { 
     int testing; 

在扬鞭UI结果将随后是这样的, Swagger UI

正如你可以看到POST操作没有任何评论,为什么?

的XML文件,包括他们虽然XML file

+0

从StartUp.cs安置自己扬鞭配置。你必须实际告诉Swagger使用XML文件,你可能不这么做。 –

+0

来自从父TestOfPets.CreatePets不是你的情况的意见,检查生成的XML文件,以确认 – HelderSepu

回答

0

的startUp.cs包括以下配置:

  var basePath = PlatformServices.Default.Application.ApplicationBasePath; 
      var xmlPath = Path.Combine(basePath, "controllapi.xml"); 
      myData.IncludeXmlComments(xmlPath) 

的controllapi.xml不包括与TestOfPets什么。它只包含PetsApiController.CreatePets。