可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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