Reputation: 20384
I've set up a web API with ASP.NET Core and Swashbuckle. All my controllers and actions show up correctly and I can try them out. For simple action parameters like a string, a form is displayed and I can enter each parameter value in that form before sending the request.
but if the action expects a class instance (data structure) as parameter, I'm left completely alone with the JSON request body. There's no form for the class properties, just a textbox where I can edit my JSON body to send. The operation is described as having no parameters (which is wrong) and the used class is described below in the Schemas section with description texts and all properties.
What do I need to change to make swagger-ui pick up that action parameter and show me a form with all its type properties before sending a request?
Upvotes: 0
Views: 1763
Reputation: 97807
but if the action expects a class instance (data structure) as parameter, I'm left completely alone with the JSON request body. There's no form for the class properties, just a textbox where I can edit my JSON body to send. The operation is described as having no parameters (which is wrong) and the used class is described below in the Schemas section with description texts and all properties.
Yep, that's how Swagger UI handles JSON requests.
What do I need to change to make swagger-ui pick up that action parameter and show me a form with all its type properties before sending a request?
You can either change your controllers to accept form data (application/x-www-form-urlencoded
or multipart/form-data
) instead of JSON, or wait until Swagger UI implements a form-style editor for JSON requests (refer to this feature request).
Upvotes: 1