aspnetcore
aspnetcore copied to clipboard
Add SkipStatusCodePages property to ApiBehaviorOptions
Add SkipStatusCodePages property to ApiBehaviorOptions
Description
This PR implements the approved API proposal to add the SkipStatusCodePages property to ApiBehaviorOptions.
What was done:
- API Extension: Added the
SkipStatusCodePagesboolean property toApiBehaviorOptions. - Application Model Provider: Updated
ApiBehaviorApplicationModelProviderto check ifSkipStatusCodePagesis set totrue. When enabled and targeting an API Controller (ApiControllerAttribute), it automatically injectsSkipStatusCodePagesMetadata.Instanceinto the action's route selectors. - Public API: Updated
PublicAPI.Unshipped.txtto include the new property.
Tests Added:
Added unit tests in ApiBehaviorApplicationModelProviderTest.cs covering the following scenarios:
- Verifying metadata is added when
SkipStatusCodePages = trueon an API Controller. - Verifying metadata is not added when
SkipStatusCodePages = trueon a non-API Controller. - Verifying metadata is not added by default when
SkipStatusCodePages = false.
Fixes #45369
Thanks for your PR, @aw0lid. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.
Friendly ping Re-requesting review on this PR. All CI checks are green. Could someone from the team take a look when you have a moment? Thanks!
Hi @aw0lid
We'll consider this for .NET 12 once main branch becomes .NET 12 (after .NET 11 RC1 is released).