首页 新闻 会员 周边

web api2.0 问题

0
悬赏园豆:20 [已解决问题] 解决于 2014-09-25 17:22

生成帮助文档,参数的描述取不出来....

 if (api.ParameterDescriptions.Count > 0)
            {
                var parameters = new List<APIEndPointParameter>();
                foreach (var parameter in api.ParameterDescriptions)
                {
                    parameters.
                    Add(new APIEndPointParameter(parameter.Name, parameter.Documentation, parameter.Source.ToString()));
                }
                return new APIEndPointDetail(api.RelativePath, api.Documentation, api.HttpMethod.Method, parameters);
            }
            else
            {
                return new APIEndPointDetail(api.RelativePath, api.Documentation, api.HttpMethod.Method);
            }

取出来的参数描述都是 

ocumentation for 参数名...

web api 2.0以上版本应该没问题吧
雪中独舞的主页 雪中独舞 | 初学一级 | 园豆:36
提问于:2014-09-25 15:30
< >
分享
最佳答案
0

你的参数注释类似这样吗:

  /// <summary>
  /// This is a test action
  /// </summary>
  /// <param name="model">this is the model</param>

修改代码可以看这个:http://stackoverflow.com/questions/18606715/asp-net-web-api-generate-all-parameters-from-model-help-pages

有可能是这个问题,需要配置:http://diaosbook.com/Post/2013/10/28/auto-generate-help-document-aspnet-webapi

收获园豆:20
悟行 | 专家六级 |园豆:12559 | 2014-09-25 17:15

谢了

mvc4/web api2.0 好像没有帮助文档模块,需要自己用ApiExplorer实现吧

参考上面的代码,改下看 

雪中独舞 | 园豆:36 (初学一级) | 2014-09-25 17:24
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册