After defining the endpoint
app.MapGet($"{baseRoute}/GetProducts", GetProductsAsync)
.WithName("GetProducts")
.Produces<ProductResponseDto>()
.WithTags(Tag);
With this async method to call implementation.
private static async Task<IResult> GetProductsAsync(ProductsDto getProducts, IUserService userService)
{
ProductResponseDto getProductsResponse = await userService.GetProductsAsync(getProducts);
return Results.Ok(getProductsResponse);
}
I defined a basic BindAsync method for bind values. I just want to add all fields contained in ProductsDto into swagger UI. Is it possible? If I use [FromQuery] annotation the Dto is null for every call. I am using .net core 6.
public class ProductsDto
{
/// <summary>
/// clientId
/// </summary>
public int clientId { get; set; }
/// <summary>
/// Test
/// </summary>
public int test { get; set; }
public static ValueTask<ProductsDto> BindAsync(HttpContext context, ParameterInfo parameter)
{
int.TryParse(context.Request.Query["clientId"], out var in_clientId);
int.TryParse(context.Request.Query["test"], out var in_test);
var result = new ProductsDto
{
clientId = in_clientId,
test = in_test
};
return ValueTask.FromResult<ProductsDto?>(result);
}
}



ProductsDtoand desired url to be hit.