I have an action:
[HttpGet]
[Route("foo")]
public ActionResult Foo([FromQuery] MyClass request)
{
var image = ToImage(WidgetType.MedianSalesPriceSqft, request);
return File(image.ToByteArray(), "image/png");
}
below MyClass is defined:
public class MyClass {
[DefaultValue("90210")]
public string Zip { get; set; }
[DefaultValue("5361 Doverton Dr")]
public string StreetAddress { get; set; }
}
When I hit /swagger/index.html and want to try out this API, I always have to enter the StreetAddress and Zip values, even though I have default values defined.
Swagger currently provides a schema filter that let's you provide default values for object properties as long as they are not set to be [FromQuery]. Am I missing something simple?