Web API Help Page for method with Enum parameters

4k Views Asked by At

I'm generating my API documentation with Web API Help Page generator. But the problems is that the Help Page generator can't generate the documentation for methods with Enum parameters. This also occur with parameters of object and dynamic type.

Here is my method:

public HttpResponseMessage Get(Status status, DateTime? date = null)
{
    ...
}

enum Status
{
    Avaliable,
    Busy,
    Canceled,
    Failed,
    Sent
}

And here is the generate documentation:

GET api/StatusCheck?date={date}

But the correct form is:

GET api/StatusCheck?status={status}&date={date}

When I go to API model documentation the parameter is there, but there's no descriptions.

It's like this:

GET api/StatusCheck?date={date}

Unavaliable.

Request
Parameters

Name            Description
status          Unavaliable.
date            Unavaliable.

Is this a BUG in Help Page generator? How can I fix my page examples?

2

There are 2 best solutions below

4
On BEST ANSWER

This was actually a bug which was fixed in April this year. Following is the issue related to that.

http://aspnetwebstack.codeplex.com/workitem/312

2
On

I had a similar issue at my end which was simply resolved by adding the following code to XmlDocumentationProvider.cs inside the GetTypeName(Type type) method.

if (type.IsEnum) { return type.FullName.Replace("+", "."); }

my enums are all under one big Enum Class, and the problem was that this function returned Enums+MyEnum which was not found in the Xml file. off course, the value that should be looked for is Enums.MyEnum.