Swagger - customize request body

1.6k Views Asked by At

I would like to customize request body in swagger-ui generated with SwashBuckle for .Net Core.

I need that when user click on "Try it Out" in swagger-ui, the request body to be different from the [FromBody] model in my Controller API.

The reason for this is because my [FromBody] Model is an "object" type. So, the request body appears {} on Swagger-Ui.

I am using .Net Core 2.1 and SwashBuckle 4.0.1.

Thanks

1

There are 1 best solutions below

1
HectorTinajero On

In the model you have to put the set; characteristic in the model request since that way swagger grabs the object and sets it into the request.

Model describer

Swagger describer

Swagger