2017-09-27 43 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。