dotnet / dotnet/aspnetcore

RFC9110 - UnprocessableContent

Open
#42,302 5 comments 1 reaction 0 assignees View on GitHub
api-suggestion area-minimal
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

## Background and Motivation

Now that [RFC 9110 - HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110.html) is official, with the inclusion of the `422 Unprocessable Content` status code, I'd like to propose the following changes to ASP.NET Core APIs.

Existing (shipped) members containing UnprocessableEntity is kept, but will simply forward to its UnprocessableContent counterpart.

## Proposed API

```diff
namespace Microsoft.AspNetCore.Http;

public static class StatusCodes
{
+ public const int Status422UnprocessableContent = 422;
}

public static partial class Results
{
+ public static IResult UnprocessableContent(object? error = null) { throw null; }
}

public static class TypedResults {
- public static UnprocessableEntity UnprocessableEntity();
+ public static UnprocessableContent UnprocessableContent();
- public static UnprocessableEntity UnprocessableEntity(TValue? error) { throw null; }
+ public static UnprocessableContent UnprocessableContent(TValue? error) { throw null; }
}

namespace Microsoft.AspNetCore.Http.HttpResults;

-public sealed class UnprocessableEntity : IResult, IEndpointMetadataProvider { }
+public sealed class UnprocessableContent : IResult, IEndpointMetadataProvider { }

-public sealed class UnprocessableEntity : IResult, IEndpointMetadataProvider { }
+public sealed class UnprocessableContent : IResult, IEndpointMetadataProvider { }
```

## Alternative Designs

Keeping the old name as-is? Should the existing `UnprocessableEntity` APIs be marked as `[Obsolete]`?

## Risks

I'm not sure there are any.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.