-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Consider a nicer API for configuring JsonOptions for minimal actions / route-to-code #39226
Copy link
Copy link
Closed
Labels
DocsThis issue tracks updating documentationThis issue tracks updating documentationapi-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-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
Milestone
Metadata
Metadata
Assignees
Labels
DocsThis issue tracks updating documentationThis issue tracks updating documentationapi-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-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.
Background and Motivation
The current way to configure JsonOptions for minimal is by configuring the
Microsoft.AspNetCore.Http.Json.JsonOptionsinstance. From our docs, here's what this looks like:Note that
a) You have to include a not too well-known namespace
b) There's also a
Microsoft.AspNetCore.Mvc.JsonOptionstype in the framework, so if you had previously imported the Mvc namespace, you'd be configuring the wrongJsonOptionstype.This makes it ripe for failure. We could consider adding a first class helper API to allow configuring this
Proposed API
Usage Examples
Alternative Designs
Risks
Users might be confused why configuring this option does not affect controller actions since this is API is much more accessible. I feel a documentation page that describes all the different JSON things that can be configured in ASP.NET Core might help mitigate this.