WebAPI help page for complex type in URI

匿名 (未验证) 提交于 2019-12-03 08:54:24

问题:

I'm using WebAPI help page to provide a documentation. Documentation is generated fine (from xml comments) except when I use complex model in the uri. So, I get the following doc

GET service/Tst2    No documentation available. 

for the method:

    /// <summary>     /// description     /// </summary>     [HttpGet]     public string Tst([FromUri] TstModel filter)     {         return null;     }      public class TstModel     {         public int Id { get; set; }     } 

for other methods with simple int/string parameters it works as expected. If I remove [FromUri] attribute it also works, but then

So the question is: how can I show documentation for such methods? How can I provide documentation for complex types taken from the URI?

回答1:

Regarding your original question about help not being generated for Complex Type decorated with [FromUri] attribute, its a known issue on which we would be working on.



回答2:

The reason why it outputted "No documentation available." is because my TstModel class was a nested class (defined inside the controller), which made the WebAPI help generate wrong XPath for finding xml-comments. Moving TstModel out of controller helped.

P.S. The fix in HelpPage code is easy, I just don't know where to report the bug&fix (wrote in NuGet at the moment) :)

It's: XmlDocumentationProvider.GetTypeName

line 109: return type.FullName.Replace("+", "."); //was: return type.FullName

and line 101: string typeName = genericType.FullName.Replace("+", "."); //was: string typeName = genericType.FullName



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!