3

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?

Shaddix
  • 5,901
  • 8
  • 45
  • 86
  • the first part of the problem is solved, the second one is - how to add documentation for such complex class parameters? – Shaddix Mar 14 '13 at 14:31

2 Answers2

3

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

Shaddix
  • 5,901
  • 8
  • 45
  • 86
  • you can report the bug over here: http://aspnetwebstack.codeplex.com/workitem/list/basic – Kiran Mar 14 '13 at 16:05
3

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.

Kiran
  • 56,921
  • 15
  • 176
  • 161
  • Has this been fixed now? I'm running into what looks like the same problem (on Web API 2.x) four years after your comment. Putting in a model binder doesn't seem to help. Using a type converter works around the problem, though. Do you have the bug ID for this? – Guillaume LaHaye Oct 17 '17 at 01:48