dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.

Home Page:https://asp.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RFC9110 - UnprocessableContent

khellang opened this issue · comments

Background and Motivation

Now that RFC 9110 - HTTP Semantics 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

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<TValue> UnprocessableEntity<TValue>(TValue? error) { throw null; }
+    public static UnprocessableContent<TValue> UnprocessableContent<TValue>(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<TValue> : IResult, IEndpointMetadataProvider { }
+public sealed class UnprocessableContent<TValue> : 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.

BTW, this is what the changes would look like (inside Microsoft.AspNetCore.Http only): main...khellang:unprocessable-content

Yeah, or MVC needs the same treatment?

In this case, it's still not too late to rename some of the APIs. In MVC's case, it'll all have to live side by side.

@rafikiassumani-msft If this ships in .NET 7, it would be a breaking change to do anything with it in .NET 8. Is it too late to change this in .NET 7?