Skip to content

Commit

Permalink
Use JSON string syntax for PATCH op (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
guardrex authored Mar 6, 2025
1 parent 3b52bf2 commit 7f14f50
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
12 changes: 5 additions & 7 deletions 8.0/BlazorWebAppCallWebApi/BlazorApp.slnLaunch.user
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
[
{
"Name": "New Profile",
"Name": "Start Solution",
"Projects": [
{
"Name": "Backend\\Backend.csproj",
"Action": "StartWithoutDebugging",
"DebugTarget": ""
"Path": "Backend\\Backend.csproj",
"Action": "StartWithoutDebugging"
},
{
"Name": "BlazorApp\\BlazorApp\\BlazorApp.csproj",
"Action": "Start",
"DebugTarget": ""
"Path": "BlazorApp\\BlazorApp\\BlazorApp.csproj",
"Action": "Start"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page "/call-todo-web-api-csr-patch"
@rendermode InteractiveWebAssembly
@using System.Diagnostics.CodeAnalysis
@using System.Text.Json
@using System.Text.Json.Serialization
@using Microsoft.AspNetCore.JsonPatch
Expand Down Expand Up @@ -40,6 +41,9 @@ else
private PersistingComponentStateSubscription persistingSubscription;
private HttpClient? client;

[StringSyntax(StringSyntaxAttribute.Json)]
private const string patchOperation = """[{"operationType":2,"path":"/IsComplete","op":"replace","value":true}]""";

protected override async Task OnInitializedAsync()
{
client = ClientFactory.CreateClient("WebAPI");
Expand Down Expand Up @@ -76,7 +80,7 @@ else
{
await client.PatchAsJsonAsync(
$"todoitems/{id}",
"[{\"operationType\":2,\"path\":\"/IsComplete\",\"op\":\"replace\",\"value\":true}]");
patchOperation);
await GetTodoItems();
}
}
Expand Down
12 changes: 5 additions & 7 deletions 9.0/BlazorWebAppCallWebApi/BlazorApp.slnLaunch.user
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
[
{
"Name": "New Profile",
"Name": "Start Solution",
"Projects": [
{
"Name": "Backend\\Backend.csproj",
"Action": "StartWithoutDebugging",
"DebugTarget": ""
"Path": "Backend\\Backend.csproj",
"Action": "StartWithoutDebugging"
},
{
"Name": "BlazorApp\\BlazorApp\\BlazorApp.csproj",
"Action": "Start",
"DebugTarget": ""
"Path": "BlazorApp\\BlazorApp\\BlazorApp.csproj",
"Action": "Start"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page "/call-todo-web-api-csr-patch"
@rendermode InteractiveWebAssembly
@using System.Diagnostics.CodeAnalysis
@using System.Text.Json
@using System.Text.Json.Serialization
@using Microsoft.AspNetCore.JsonPatch
Expand Down Expand Up @@ -40,6 +41,9 @@ else
private PersistingComponentStateSubscription persistingSubscription;
private HttpClient? client;

[StringSyntax(StringSyntaxAttribute.Json)]
private const string patchOperation = """[{"operationType":2,"path":"/IsComplete","op":"replace","value":true}]""";

protected override async Task OnInitializedAsync()
{
client = ClientFactory.CreateClient("WebAPI");
Expand Down Expand Up @@ -76,7 +80,7 @@ else
{
await client.PatchAsJsonAsync(
$"todoitems/{id}",
"[{\"operationType\":2,\"path\":\"/IsComplete\",\"op\":\"replace\",\"value\":true}]");
patchOperation);
await GetTodoItems();
}
}
Expand Down

0 comments on commit 7f14f50

Please sign in to comment.