Class BindingFailureMiddleware
Answers request-binding failures (a BadHttpRequestException: a malformed or
incomplete JSON body, limit=abc, a missing required parameter) through the API's
IApiErrorWriter, with the matched ApiOperation so the writer can
answer in the contract's terms. Requires RouteHandlerOptions.ThrowOnBadRequest
(AddTypeSpecApi(IServiceCollection, JsonSerializerContext) sets it) so the failures reach the middleware.
A bare 400 that the endpoint set without writing anything is answered the same way: the request
delegate generator (on under Native AOT) answers a failed parse of an optional parameter that
way instead of throwing.
public static class BindingFailureMiddleware
- Inheritance
-
BindingFailureMiddleware
- Inherited Members
Methods
UseBindingFailures(IApplicationBuilder)
Adds the middleware (reflection-free, so it suits Native AOT).
public static IApplicationBuilder UseBindingFailures(this IApplicationBuilder app)