Skip to content

Commit 81fbe94

Browse files
committed
Accepting a random JasonaPatchDocument
1 parent 1787177 commit 81fbe94

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Program.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using com.sun.tools.javac.util;
2+
using com.sun.xml.@internal.xsom.impl.parser;
23
using edu.stanford.nlp.ie.crf;
34
using edu.stanford.nlp.ling;
45
using edu.stanford.nlp.parser.lexparser;
@@ -10,6 +11,8 @@
1011
using edu.stanford.nlp.util;
1112
using java.util;
1213
using Microsoft.AspNetCore.Authentication.JwtBearer;
14+
using Microsoft.AspNetCore.JsonPatch;
15+
using Microsoft.AspNetCore.JsonPatch.Adapters;
1316
using Microsoft.AspNetCore.Mvc;
1417
using Microsoft.Extensions.Options;
1518
using Microsoft.IdentityModel.Tokens;
@@ -299,6 +302,19 @@
299302
.Produces<bool>(StatusCodes.Status200OK)
300303
.WithTags("Exposed");
301304

305+
app.MapPatch("/api/Patch", ([FromBody] JsonPatchDocument patchDoc) =>
306+
{
307+
//patchDoc.ApplyTo(new object(), adapter);
308+
// Handle the patch document
309+
patchDoc.Operations.ForEach(op =>
310+
{
311+
Console.WriteLine($"Operation: {op.op}, Path: {op.path}, Value: {op.value}");
312+
});
313+
return Results.Accepted();
314+
})
315+
.Produces(StatusCodes.Status202Accepted)
316+
.WithTags("JsonPatch");
317+
302318
app.MapControllers().RequireCors("MyPolicy");
303319

304320
app.Run();

RandomAPIApp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
<ItemGroup>
4949
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.15" />
50+
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="8.0.22" />
5051
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.0.12" />
5152
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.15" />
5253
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.7.1" />

0 commit comments

Comments
 (0)