-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
GetItemsQuery
properties are not visible in OpenApi spec when I have BindAsync method
Expected Behavior
Properties should be in open api spec
Steps To Reproduce
public sealed record GetItemsQuery(
string? SearchTerms,
Category? Category,
IEnumerable<ItemState> ItemStates
) : PagedQuery<ItemDto>
{
public static ValueTask<GetItemsQuery?> BindAsync(
HttpContext ctx,
ParameterInfo param
)
{
const string searchTermsKey = "searchTerms";
const string categoryKey = "category";
const string itemStatesKey = "itemStates";
var searchTerms = ctx.Request.Query[searchTermsKey]
.ToString()
.Trim();
Category.TryFromName(
ctx.Request.Query[categoryKey],
ignoreCase: true,
out var category
);
IEnumerable<ItemState> itemStates = Enumerable.Empty<ItemState>();
var itemStatesParam = ctx.Request.Query[itemStatesKey].ToString();
if (!string.IsNullOrEmpty(itemStatesParam))
{
itemStates = itemStatesParam
.Split(',')
.Select(state => Enum.TryParse(state, out ItemState itemState) ? itemState : (ItemState?)null)
.Where(state => state.HasValue)
.Select(state => state.Value)
.ToList();
}
return ValueTask.FromResult<GetItemsQuery?>(new(
searchTerms,
category,
itemStates
));
}
}
group
.MapGet(
"/",
async (
ISender sender,
CancellationToken ct,
GetItemsQuery qry
) => OperationResults.Ok(await sender.Send(
qry,
ct
))
)
.WithName("GetListings")
.WithSummary("Items get operation")
.WithDescription("")
.ProducesOperationResult<Paged<ItemDto>>()
.ProducesOperationResult(StatusCodes.Status400BadRequest);
Exceptions (if any)
No response
.NET Version
9.0
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi