简体   繁体   English

如何从 Swashbuckle for asp.net 中包含的 Swagger-UI 中删除应用程序/json

[英]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.

相关问题 可以从Swashbuckle / Swagger UI中排除ASP.NET WebAPI操作参数吗? - Can an ASP.NET WebAPI action parameter be excluded from Swashbuckle/Swagger UI? 如何配置Swagger / Swashbuckle自定义序列化程序IControllerConfiguration ASP.NET WebAPI - How to configure Swagger/Swashbuckle custom serializer IControllerConfiguration ASP.NET WebAPI Swagger UI 在 ASP.NET 4.5 应用程序中无法访问 - Swagger UI Not Accessible in ASP.NET 4.5 Application 带有 FromQuery 属性的 HTTP GET 方法的 SwashBuckle Swagger-UI 示例请求 - SwashBuckle Swagger-UI Example Request for HTTP GET Method with FromQuery Attribute Swagger Swashbuckle Asp.NET 核心:显示使用的每个枚举的详细信息 - Swagger Swashbuckle Asp.NET Core: show details about every enum is used 如何在 Swashbuckle 中替换 Swagger UI 标题徽标 - How to replace Swagger UI header logo in Swashbuckle 使用ASP.NET MVC WebApi的Swashbuckle 5.4.0 - 在swagger网页中没有显示任何文档 - Swashbuckle 5.4.0 with ASP.NET MVC WebApi - No documentation is shown inside the swagger webpage 如何在 Swashbuckle 5 for ASP.Net 中调试错误 500 - How to debug error 500 in Swashbuckle 5 for ASP.Net Swagger UI无法显示来自ASP.net Core WebAPI的正确响应 - Swagger UI unable to show proper response from ASP.net Core WebAPI Swagger UI 响应示例 Asp.Net Core Web Api - Swagger UI Response Example Asp.Net Core Web Api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM