[英]How to remove application/json from Swagger-UI included in Swashbuckle for asp.net
I have an asp.net .net framework (not core) where I am using Swashbuckle
to auto generate the Swagger documentation for my API.我有一个 asp.net .net 框架(不是核心),我在其中使用
Swashbuckle
为我的 API 自动生成 Swagger 文档。
I have also added Swashbuckle examples .我还添加了Swashbuckle 示例。
I want to use the SwaggerResponseExample
to show example return data, but in the Swagger UI always has the results nested under application/json
我想使用
SwaggerResponseExample
来显示示例返回数据,但在 Swagger UI 中总是将结果嵌套在application/json
There is an old issue on this here , but no workaround.有一个古老的问题,在这个位置,但没有解决方法。
Does anyone have any sort of workaround for this?有没有人对此有任何解决方法? I see no further updates of Swashbuckle (and hence any embedded Swagger UI).
我没有看到 Swashbuckle 的进一步更新(以及任何嵌入式 Swagger UI)。
As a workaround, I discovered you can at least change what appears in the body text area for a parameter.作为一种解决方法,我发现您至少可以更改参数正文区域中显示的内容。
Within the IOperation filter that sets your example, you can search through your Operation, find your operations body data parameter that holds the model and set the parameter's "default" property value to a JSON object.在设置示例的 IOperation 过滤器中,您可以搜索操作,找到保存模型的操作主体数据参数,并将参数的“默认”属性值设置为 JSON 对象。
While this won't fix your example value on the right, this will at least provide a way to get an example in your request data.虽然这不会修复右侧的示例值,但这至少会提供一种在请求数据中获取示例的方法。
Hopefully this helps someone stuck in .Net Framework with Swashbuckle.希望这可以帮助那些被 Swashbuckle 困在 .Net Framework 中的人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.