I have my web api and I added the web api help pages to auto-generate my documentation. It's working great for methods where my parameters are listed out, but I have a method like this:
public SessionResult PostLogin(CreateSessionCommand request)
And, on my help page, it is only listing the command parameter in the properties section. However, in the sample request section, it lists out all of the properties of my CreateSessionCommand
class.
Parameters
Name | Description | Additional information
request | No documentation available. | Define this parameter in the request body.
I would like it instead to list all of the properties in my CreateSessionCommand
class. Is there an easy way to do this?
This is currently not supported out of the box. Following bug is kind of related to that: http://aspnetwebstack.codeplex.com/workitem/877
this should go as an addition to @Josh answer. If you want not only to list properties from the model class, but also include documentation for each property, Areas/HelpPage/XmlDocumentationProvider.cs file should be modified as follows:
and CustomParameterInfo class should keep property info as well:
So, I managed to devise a workaround for this problem, in case anyone is interested.
In HelpPageConfigurationExtensions.cs I added the following extension method:
And here is the Parameter info instanced class I use
Then, we call the extension in another method inside the extensions class
The comments that are used for this must be added to the controller method and not the properties of the class object. This might be because my object is part of an outside library