-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Minimal API query & route parameter mapping to an object #35304
Copy link
Copy link
Closed
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcdesign-proposalThis issue represents a design proposal for a different issue, linked in the descriptionThis issue represents a design proposal for a different issue, linked in the descriptionfeature-minimal-actionsController-like actions for endpoint routingController-like actions for endpoint routingold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
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 etcdesign-proposalThis issue represents a design proposal for a different issue, linked in the descriptionThis issue represents a design proposal for a different issue, linked in the descriptionfeature-minimal-actionsController-like actions for endpoint routingController-like actions for endpoint routingold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
The minimal API's currently look for a
public static bool TryParse(...)method to map parameters from query or route parameters to an object. It would be great to have this look at the properties on an object to match route and/or route parameters.Motivation and goals
A get request on a minimal API route that takes a set of parameters where it may be nicer to map these to an object rather than a set of arguments on a delegate.
In scope
Out of scope
Risks / unknowns
Examples
Query String Match
The above route would map from a query string such as this
http://localhost:5001/api/todo?page=1&pageSize=10Route Match
The above route would map from a query string such as this
http://localhost:5001/api/todo/1/10Implicit vs Explicit
I would expect the choice of which method to use could always be overriden using the attributes
[FromRoute]&[FromQuery].Detailed design
I am pretty sure this is already supported in controllers for aspnet core when using the
[FromQuery]attribute it will build up a dictionary of values from the query string and map these where possible to properties on an object.I would expect this to work the same.