简体   繁体   中英

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.

I have also added Swashbuckle examples .

I want to use the SwaggerResponseExample to show example return data, but in the Swagger UI always has the results nested under 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).

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.

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM