Web API Help Page for method with Enum parameters
Asked Answered
C

2

6

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?

Car answered 29/8, 2013 at 12:45 Comment(0)
C
2

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

Correlation answered 29/8, 2013 at 17:24 Comment(4)
RC(release candidate) has been released today. You can try upgrading your nuget packages to see if your issue is fixed.Correlation
Isn't working yet. I updated all AspNet packages to the avaliable version 4.0.30506.0.Car
Did you select "Prerelease" when you tried to update the packages?Correlation
I will wait until stable version.Car
M
3

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.

Maneating answered 20/12, 2013 at 22:46 Comment(2)
This is what worked for me - and I was running the latest nuget for Web APIExtraterritorial
Fixed my issue too. The description wasn't showing up for me b/c they type names didn't match (+ vs .). Thanks!Gwyn
C
2

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

Correlation answered 29/8, 2013 at 17:24 Comment(4)
RC(release candidate) has been released today. You can try upgrading your nuget packages to see if your issue is fixed.Correlation
Isn't working yet. I updated all AspNet packages to the avaliable version 4.0.30506.0.Car
Did you select "Prerelease" when you tried to update the packages?Correlation
I will wait until stable version.Car

© 2022 - 2024 — McMap. All rights reserved.