Skip to content

Commit 304ea93

Browse files
author
ladeak
committed
Samples updated
1 parent eccb116 commit 304ea93

File tree

4 files changed

+32
-25
lines changed

4 files changed

+32
-25
lines changed

sample/AspNetCoreMinimal/Controllers/SampleController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public CitiesData PatchCities(Patch<CitiesData> input)
3939
[HttpGet("ReadJsonPatchAsync")]
4040
public async Task<WeatherForecast> GetReadJsonPatchAsync()
4141
{
42-
var target = new WeatherForecast() { Date = DateTime.UtcNow, Summary = "Sample weather forecast", TemperatureC = 24 };
42+
var target = new WeatherForecast() { Date = DateTime.UtcNow, Summary = "Sample weather forecast", TemperatureC = 22 };
4343
var httpClient = _clientFactory.CreateClient();
4444
var response = await httpClient.GetAsync("https://localhost:5001/Sample/Weather", HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
4545
var responseData = await response.Content.ReadJsonPatchAsync<WeatherForecast>(new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }).ConfigureAwait(false);
Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,13 @@
11
{
22
"$schema": "https://json.schemastore.org/launchsettings.json",
3-
"iisSettings": {
4-
"windowsAuthentication": false,
5-
"anonymousAuthentication": true,
6-
"iisExpress": {
7-
"applicationUrl": "http://localhost:42816",
8-
"sslPort": 44364
9-
}
10-
},
113
"profiles": {
124
"AspNetCoreMinimal": {
135
"commandName": "Project",
146
"dotnetRunMessages": true,
15-
"launchBrowser": true,
16-
"launchUrl": "swagger",
177
"applicationUrl": "https://localhost:5001;http://localhost:5000",
188
"environmentVariables": {
199
"ASPNETCORE_ENVIRONMENT": "Development"
2010
}
21-
},
22-
"IIS Express": {
23-
"commandName": "IISExpress",
24-
"launchBrowser": true,
25-
"launchUrl": "swagger",
26-
"environmentVariables": {
27-
"ASPNETCORE_ENVIRONMENT": "Development"
28-
}
2911
}
3012
}
3113
}

sample/AspNetCoreMinimal/sample.http

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
###
2+
3+
GET https://localhost:5001/Sample/Weather
4+
5+
###
6+
7+
PATCH https://localhost:5001/Sample/PatchWeather
8+
Content-Type: application/merge-patch+json
9+
10+
{
11+
"temp":23,
12+
"summary":null
13+
}
14+
###
15+
16+
PATCH https://localhost:5001/Sample/PatchCities
17+
Content-Type: application/merge-patch+json
18+
19+
{
20+
"cities":
21+
{
22+
"Dublin":"Ireland",
23+
"London":"GB",
24+
"New York":null
25+
}
26+
}
27+
###
28+
29+
GET https://localhost:5001/Sample/ReadJsonPatchAsync

sample/ConsoleApp/Program.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using ConsoleAppLibrary;
2-
using LaDeak.JsonMergePatch.Abstractions;
1+
using LaDeak.JsonMergePatch.Abstractions;
32
using LaDeak.JsonMergePatch.Http;
43

54
namespace ReadJsonPatchAsync;
@@ -25,11 +24,8 @@ public static async Task ReadAsJsonMergePatchAsync()
2524
var httpClient = new HttpClient();
2625
var response = await httpClient.GetAsync("https://localhost:5001/Sample/Weather", HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
2726
var responseData = await response.Content.ReadJsonPatchAsync<WeatherForecast>().ConfigureAwait(false);
28-
var target = new WeatherForecast() { Date = DateTime.UtcNow, Summary = "Sample weather forecast", Temp = 24 };
27+
var target = new WeatherForecast() { Date = DateTime.UtcNow, Summary = "Sample weather forecast", Temp = 22 };
2928
var result = responseData.ApplyPatch(target);
3029
Console.WriteLine($"Patched: Date={result.Date}, Summary={result.Summary}, Temp={result.Temp}");
31-
32-
var client = new Client();
33-
await client.ReadAsJsonMergePatchAsync();
3430
}
3531
}

0 commit comments

Comments
 (0)