ASP.Net Web API Swashbuckle如何忽略HttpRequestMessage [英] ASP.Net Web API Swashbuckle how to ignore HttpRequestMessage

查看:74
本文介绍了ASP.Net Web API Swashbuckle如何忽略HttpRequestMessage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Swashbuckle生成API文档.我的控制器方法如下:

I'm using Swashbuckle to generate docs for an API. My controller methods looks like this:

[ResponseType(typeof(CategoryCollectionModel))]
        public HttpResponseMessage Get(HttpRequestMessage request, [FromUri]Paging paging)
        {
            var input = new CategoriesListQuery.Input { Page = paging.Page, Size = paging.Size };
            var result = this.queryInvoker.Execute<CategoriesListQuery.Input, CategoriesListQuery.Result>(input);
            var items = Mapper.Map<CategoryCollectionModel>(result);

            return request.CreateResponse(HttpStatusCode.OK, items);
        }

Swashbuckle在生成的文档中将HttpRequestMessage视为参数.有一种方法可以将Swashbuckle配置为忽略HttpRequestMessage,因为它仅出于测试目的而包含在签名中?

Swashbuckle treats HttpRequestMessage as a parameter in the generated docs. Is there a way to configure Swashbuckle to ignore HttpRequestMessage since it is only included in the signature for testing purposes?

推荐答案

请在此处.简而言之,不要像输入参数那样传递HttpRequestMessage,而是模拟{controller}.Request属性.

Please refer to the discussion here. In short do not pass in HttpRequestMessage as in input parameter, rather mock the {controller}.Request property.

这篇关于ASP.Net Web API Swashbuckle如何忽略HttpRequestMessage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆