【发布时间】:2018-01-02 19:54:15
【问题描述】:
我有我们都在工作中使用的 Asp.net Core Swagger 框架。它只是用 Swagger 包装了所有 PITA 的东西。它被设计为 json in / json out。现在有一个小组只想将它与 XML in / XML out 一起使用。
这是我到目前为止所做的:
1) 将 startup.cs 更改为:
services.AddMvc().AddXmlSerializerFormatters();
2) 在控制器方法上,改为:
[Consumes("application/xml")]
[Produces("application/xml")]
3) 在操作过滤器中,添加:
operation.Produces.Add("application/xml");
现在,在测试 UI 中,我只获得用于输入和输出下拉菜单的 application/xml。当我点击测试按钮时,我的请求被正确反序列化,但测试页面产生 406 错误。
我还需要改变什么?
【问题讨论】:
标签: c# asp.net-core swagger swagger-ui