Skip to content

Commit 88f5eee

Browse files
author
Bart Koelman
committed
Change patch to post
1 parent 6d8aa36 commit 88f5eee

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

src/JsonApiDotNetCore/Controllers/JsonApiAtomicOperationsController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public JsonApiAtomicOperationsController(IAtomicOperationsProcessor atomicOperat
3131
/// <param name="cancellationToken">Propagates notification that request handling should be canceled.</param>
3232
/// <example>
3333
/// <code>
34-
/// PATCH /api/v1/operations HTTP/1.1
34+
/// POST /api/v1/operations HTTP/1.1
3535
/// Content-Type: application/vnd.api+json
3636
///
3737
/// {
@@ -50,8 +50,8 @@ public JsonApiAtomicOperationsController(IAtomicOperationsProcessor atomicOperat
5050
/// }
5151
/// </code>
5252
/// </example>
53-
[HttpPatch]
54-
public virtual async Task<IActionResult> PatchOperationsAsync([FromBody] AtomicOperationsDocument doc, CancellationToken cancellationToken)
53+
[HttpPost]
54+
public virtual async Task<IActionResult> PostOperationsAsync([FromBody] AtomicOperationsDocument doc, CancellationToken cancellationToken)
5555
{
5656
if (doc == null) return new StatusCodeResult(422);
5757

src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public async Task Invoke(HttpContext httpContext,
7272
private static bool PathIsBulk(RouteValueDictionary routeValues)
7373
{
7474
var actionName = (string)routeValues["action"];
75-
return actionName == "PatchOperations";
75+
return actionName == "PostOperations";
7676
}
7777

7878
private static ResourceContext CreatePrimaryResourceContext(RouteValueDictionary routeValues,

test/OperationsExampleTests/Add/AddTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public async Task Can_Create_Author()
4343
};
4444

4545
// act
46-
var (response, data) = await _fixture.PatchAsync<AtomicOperationsDocument>("api/v1/operations", content);
46+
var (response, data) = await _fixture.PostAsync<AtomicOperationsDocument>("api/v1/operations", content);
4747

4848
// assert
4949
Assert.NotNull(response);
@@ -84,7 +84,7 @@ public async Task Can_Create_Authors()
8484
}
8585

8686
// act
87-
var (response, data) = await _fixture.PatchAsync<AtomicOperationsDocument>("api/v1/operations", content);
87+
var (response, data) = await _fixture.PostAsync<AtomicOperationsDocument>("api/v1/operations", content);
8888

8989
// assert
9090
Assert.NotNull(response);
@@ -137,7 +137,7 @@ public async Task Can_Create_Article_With_Existing_Author()
137137
};
138138

139139
// act
140-
var (response, data) = await _fixture.PatchAsync<AtomicOperationsDocument>("api/v1/operations", content);
140+
var (response, data) = await _fixture.PostAsync<AtomicOperationsDocument>("api/v1/operations", content);
141141

142142
// assert
143143
Assert.NotNull(response);
@@ -205,7 +205,7 @@ public async Task Can_Create_Articles_With_Existing_Author()
205205
}
206206

207207
// act
208-
var (response, data) = await _fixture.PatchAsync<AtomicOperationsDocument>("api/v1/operations", content);
208+
var (response, data) = await _fixture.PostAsync<AtomicOperationsDocument>("api/v1/operations", content);
209209

210210
// assert
211211
Assert.NotNull(response);
@@ -268,7 +268,7 @@ public async Task Can_Create_Author_With_Article_Using_LocalId()
268268
};
269269

270270
// act
271-
var (response, data) = await _fixture.PatchAsync<AtomicOperationsDocument>("api/v1/operations", content);
271+
var (response, data) = await _fixture.PostAsync<AtomicOperationsDocument>("api/v1/operations", content);
272272

273273
// assert
274274
Assert.NotNull(response);

test/OperationsExampleTests/Remove/RemoveTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public async Task Can_Remove_Author()
4040
};
4141

4242
// act
43-
var (response, data) = await _fixture.PatchAsync<AtomicOperationsDocument>("api/v1/operations", content);
43+
var (response, data) = await _fixture.PostAsync<AtomicOperationsDocument>("api/v1/operations", content);
4444

4545
// assert
4646
Assert.NotNull(response);
@@ -74,7 +74,7 @@ public async Task Can_Remove_Authors()
7474
);
7575

7676
// act
77-
var (response, data) = await _fixture.PatchAsync<AtomicOperationsDocument>("api/v1/operations", content);
77+
var (response, data) = await _fixture.PostAsync<AtomicOperationsDocument>("api/v1/operations", content);
7878

7979
// assert
8080
Assert.NotNull(response);

test/OperationsExampleTests/TestFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ public void Dispose()
5252
}
5353
}
5454

55-
public async Task<(HttpResponseMessage response, T data)> PatchAsync<T>(string route, object data)
55+
public async Task<(HttpResponseMessage response, T data)> PostAsync<T>(string route, object data)
5656
{
57-
var response = await PatchAsync(route, data);
57+
var response = await PostAsync(route, data);
5858
var json = await response.Content.ReadAsStringAsync();
5959
var obj = JsonConvert.DeserializeObject<T>(json);
6060
return (response, obj);
6161
}
6262

63-
private async Task<HttpResponseMessage> PatchAsync(string route, object data)
63+
private async Task<HttpResponseMessage> PostAsync(string route, object data)
6464
{
65-
var httpMethod = new HttpMethod("PATCH");
65+
var httpMethod = HttpMethod.Post;
6666
var request = new HttpRequestMessage(httpMethod, route);
6767
request.Content = new StringContent(JsonConvert.SerializeObject(data));
6868
request.Content.Headers.ContentLength = 1;

test/OperationsExampleTests/Transactions/TransactionFailureTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public async Task Cannot_Create_Author_If_Article_Creation_Fails()
6666
};
6767

6868
// act
69-
var (response, data) = await _fixture.PatchAsync<ErrorDocument>("api/v1/operations", content);
69+
var (response, data) = await _fixture.PostAsync<ErrorDocument>("api/v1/operations", content);
7070

7171
// assert
7272
Assert.NotNull(response);

test/OperationsExampleTests/Update/UpdateTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public async Task Can_Update_Author()
5252
};
5353

5454
// act
55-
var (response, data) = await _fixture.PatchAsync<AtomicOperationsDocument>("api/v1/operations", content);
55+
var (response, data) = await _fixture.PostAsync<AtomicOperationsDocument>("api/v1/operations", content);
5656

5757
// assert
5858
Assert.NotNull(response);
@@ -99,7 +99,7 @@ public async Task Can_Update_Authors()
9999
});
100100

101101
// act
102-
var (response, data) = await _fixture.PatchAsync<AtomicOperationsDocument>("api/v1/operations", content);
102+
var (response, data) = await _fixture.PostAsync<AtomicOperationsDocument>("api/v1/operations", content);
103103

104104
// assert
105105
Assert.NotNull(response);

0 commit comments

Comments
 (0)