You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a request that takes a JSON body as a parameter. When I start up the service and pull up the UI, and look at the request, I notice that in the body some default values are imposed on the fields in the JSON body:
I want to take advantage of being able to click that UI element and auto-populating the "payload" text field, but those default parameters make me wary of exposing this feature to the users. Is there a way to set those default values for the fields in the JSON payload? Or maybe could I pass in an instance of that class to an attribute of the controller, something like:
[SwaggerDefaultValue(payload, new ExamplePayload)]
public IHttpActionResult ExampleAction(string id, ExamplePayload payload)
{
...
}
Where I set the default value of the parameter by it's name with a value I pass in? I apologize if this issue has been raised already before, but I didn't see anything like it already.
The text was updated successfully, but these errors were encountered:
Checkout #283 - it details a solution to this problem via per-schema filters. In summary, you would create a schema filter specific to the type in question, which assigns the "default" property accordingly, and then wire it up as follows:
[SwaggerSchemaFilter(typeof(CustomerPayloadExamples))]
public class CustomerPayload
{
....
I have a request that takes a JSON body as a parameter. When I start up the service and pull up the UI, and look at the request, I notice that in the body some default values are imposed on the fields in the JSON body:
I want to take advantage of being able to click that UI element and auto-populating the "payload" text field, but those default parameters make me wary of exposing this feature to the users. Is there a way to set those default values for the fields in the JSON payload? Or maybe could I pass in an instance of that class to an attribute of the controller, something like:
Where I set the default value of the parameter by it's name with a value I pass in? I apologize if this issue has been raised already before, but I didn't see anything like it already.
The text was updated successfully, but these errors were encountered: