简体   繁体   English

具有Enum参数的方法的Web API帮助页面

[英]Web API Help Page for method with Enum parameters

I'm generating my API documentation with Web API Help Page generator. 我正在使用Web API帮助页面生成器生成我的API文档。 But the problems is that the Help Page generator can't generate the documentation for methods with Enum parameters. 但问题是帮助页面生成器无法为具有Enum参数的方法生成文档。 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. 当我转到API模型文档时,参数就在那里,但是没有描述。

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? 这是帮助页面生成器中的BUG吗? How can I fix my page examples? 如何修复我的页面示例?

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. 我在我的最后有一个类似的问题,只需通过将以下代码添加到GetTypeName(Type type)方法中的XmlDocumentationProvider.cs来解决。

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. 我的枚举都在一个大的枚举类下,问题是这个函数返回了在Xml文件中找不到的Enums + MyEnum。 off course, the value that should be looked for is Enums.MyEnum. 当然,应该寻找的值是Enums.MyEnum。

This was actually a bug which was fixed in April this year. 这实际上是一个在今年4月修复的错误。 Following is the issue related to that. 以下是与此相关的问题。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM