简体   繁体   English

XML内联注释不包含在生成的swagger.json中

[英]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 XML file include them though, XML file XML文件包括它们, XML文件

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.

相关问题 Swagger 不生成 swagger.json - Swagger is not generating swagger.json 显示 Swagger.json 但 UI 不显示 - Swagger.json is displayed but the UI not 使用在 Swashbuckle 的后期构建操作中生成的 swagger.json 文件,而不是在运行时生成的文件 - Use swagger.json file generated in post build actions in Swashbuckle instead of the file generated at runtime 当本地主机提供 swagger.json 时,Autorest 无法针对文件解析 swagger.json - Autorest Failed resolving swagger.json against file when swagger.json is served by localhost 使用 GenerateSchema 添加的类出现在 Swagger UI 中,但不在 swagger.json 中 - Classes Added Using GenerateSchema Appear in the Swagger UI But Not in swagger.json .DLL中包含.DLL注释 - .DLL comments included in the .XML 为什么我的与 DTO 相关的 Swagger.JSON 不会根据正在更新的 API.Z3501BB7103D3693ED31B8 文件中的定义进行更新? - Why would my Swagger.JSON related to a DTO not update based upon the definition in the API.XML file being update? Swagger 'swagger.json' 加载,但在 AspNet 项目中的 swagger UI '{localhost}/swagger' 上出现 404 错误 - Swagger 'swagger.json' loads, but 404 error on swagger UI '{localhost}/swagger' in AspNet project 如何修复 .net core 2.2 应用程序中未找到的 swagger.json - How to fix swagger.json not found in .net core 2.2 app swagger.json 路径和定义为空。 规范中没有定义操作 - swagger.json paths and definitions are empty. No operations defined in spec
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM