简体   繁体   中英

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. For all other methods the inline comments are included in the generated swagger.json. The xml file include all comments so that file seems to be correct. All the routes are working as they should.

Why aren't all XML comments included in the generated swagger.json?

    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:

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

The outcome in Swagger UI will then be like this, Swagger UI

As you can see the POST operation don't have any comments, why?

The XML file include them though, XML file

The startUp.cs include this configuration:

            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. It only include PetsApiController.CreatePets.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM