我已经创建了一个帮助区域文档来自我的web api 2项目(基于owin/katana)。我打开了配置中的所有设置并安装了Microsoft.AspNet.WebApi.OData
。目前我有以下设置:生成的WEB API帮助区域文档不显示响应正文格式/示例
config.SetSampleObjects(new Dictionary<Type, object>
{
{typeof(string), "sample string"},
{typeof(IEnumerable<string>), new string[]{"sample 1", "sample 2"}}
});
config.SetSampleForMediaType(
new TextSample("Binary JSON content. See http://bsonspec.org for details."),
new MediaTypeHeaderValue("application/bson"));
config.SetSampleForType("[0]=foo&[1]=bar", new MediaTypeHeaderValue("application/x-www-form-urlencoded"), typeof(IEnumerable<string>));
config.SetSampleRequest("1234", new MediaTypeHeaderValue("text/plain"), "Values", "Put");
config.SetSampleResponse(new ImageSample("../images/aspNetHome.png"), new MediaTypeHeaderValue("image/png"), "Values", "Get", "id");
config.SetActualRequestType(typeof(string), "Values", "Get");
config.SetActualResponseType(typeof(string), "Values", "Post");
但是,我没有任何响应示例正在生成。我的页面应该是这个样子,因为我看到了网络
上,但它也洛斯这个样子。如何显示第一张图片中显示的样本响应格式,如JSON?