Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Commit d13a56d

Browse files
committed
refactor: rename default property from RequestBody to Payload
BREAKING CHANGE: Rename default property from `RequestBody` to `Payload`
1 parent cf42e26 commit d13a56d

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/ModelStateExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace PowerUtils.AspNetCore.ErrorHandler
77
{
88
internal static class ModelStateExtensions
99
{
10-
private const string BODY_PROPERTY_NAME = "RequestBody";
10+
private const string PAYLOAD_PROPERTY_NAME = "Payload";
1111

1212
public static IDictionary<string, string> MappingModelState(this ModelStateDictionary modelState)
1313
{
@@ -51,7 +51,7 @@ public static IDictionary<string, string> CheckPayloadTooLargeAndReturnError(thi
5151

5252
return new Dictionary<string, string>()
5353
{
54-
{ BODY_PROPERTY_NAME, "MAX:" + maxSize }
54+
{ PAYLOAD_PROPERTY_NAME, "MAX:" + maxSize }
5555
};
5656
}
5757

@@ -81,12 +81,12 @@ private static (string Property, string Error) _mappingError(string property, st
8181
{
8282
if(property == "$")
8383
{
84-
return (BODY_PROPERTY_NAME, "INVALID");
84+
return (PAYLOAD_PROPERTY_NAME, "INVALID");
8585
}
8686

8787
if("A non-empty request body is required.".Equals(error, StringComparison.InvariantCultureIgnoreCase))
8888
{
89-
return (BODY_PROPERTY_NAME, "REQUIRED");
89+
return (PAYLOAD_PROPERTY_NAME, "REQUIRED");
9090
}
9191

9292
return (property, error);

tests/PowerUtils.AspNetCore.ErrorHandler.Tests/Tests/Controllers/FilesControllerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public async Task FileLarge_Send_413()
4848
"POST: " + requestUri,
4949
new Dictionary<string, string>()
5050
{
51-
{ "request_body", "MAX:1048576" }
51+
{ "payload", "MAX:1048576" }
5252
}
5353
);
5454
}

tests/PowerUtils.AspNetCore.ErrorHandler.Tests/Tests/Controllers/ModelStateControllerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public async void PostInvalid_Request_400()
4040
"POST: " + requestUri,
4141
new Dictionary<string, string>()
4242
{
43-
{ "request_body", "INVALID" }
43+
{ "payload", "INVALID" }
4444
}
4545
);
4646
}
@@ -67,7 +67,7 @@ public async void PostWithoutBody_Request_400()
6767
"POST: " + requestUri,
6868
new Dictionary<string, string>()
6969
{
70-
{ "request_body", "REQUIRED" }
70+
{ "payload", "REQUIRED" }
7171
}
7272
);
7373
}

0 commit comments

Comments
 (0)