Swashbuckle.AspNetCore icon indicating copy to clipboard operation
Swashbuckle.AspNetCore copied to clipboard

`Bind(Prefix = "someprefix")` ignored on query parameter of complex type

Open mauve opened this issue 3 years ago • 3 comments

Hi,

I have the following complex type which I would like to bind to as a query parameter. According to the ASP.NET docs complex types get flattened, however if I understand the documentation correctly using [Bind(Prefix = "someprefix")] should allow me to force a someprefix. prefix.

My code:

public class DateTimeRange
{
  public DateTime? Start { get; set; }
  public DateTime? End { get; set; }
}

In my controller:

[HttpGet]
public ActionResult MyMethod(
  [Bind(Prefix = "someprefix")]
  [FromQuery]
  DateTimeRange? created)
{
  return Ok();
}

Results in the following swagger def:

image

Is there a way to get it to set the parameter names to created.start and created.end instead of just plain start and end.

mauve avatar Jan 11 '22 14:01 mauve