File tree Expand file tree Collapse file tree 4 files changed +32
-25
lines changed Expand file tree Collapse file tree 4 files changed +32
-25
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public CitiesData PatchCities(Patch<CitiesData> input)
39
39
[ HttpGet ( "ReadJsonPatchAsync" ) ]
40
40
public async Task < WeatherForecast > GetReadJsonPatchAsync ( )
41
41
{
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 } ;
43
43
var httpClient = _clientFactory . CreateClient ( ) ;
44
44
var response = await httpClient . GetAsync ( "https://localhost:5001/Sample/Weather" , HttpCompletionOption . ResponseHeadersRead ) . ConfigureAwait ( false ) ;
45
45
var responseData = await response . Content . ReadJsonPatchAsync < WeatherForecast > ( new JsonSerializerOptions ( ) { PropertyNameCaseInsensitive = true } ) . ConfigureAwait ( false ) ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"$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
- },
11
3
"profiles" : {
12
4
"AspNetCoreMinimal" : {
13
5
"commandName" : " Project" ,
14
6
"dotnetRunMessages" : true ,
15
- "launchBrowser" : true ,
16
- "launchUrl" : " swagger" ,
17
7
"applicationUrl" : " https://localhost:5001;http://localhost:5000" ,
18
8
"environmentVariables" : {
19
9
"ASPNETCORE_ENVIRONMENT" : " Development"
20
10
}
21
- },
22
- "IIS Express" : {
23
- "commandName" : " IISExpress" ,
24
- "launchBrowser" : true ,
25
- "launchUrl" : " swagger" ,
26
- "environmentVariables" : {
27
- "ASPNETCORE_ENVIRONMENT" : " Development"
28
- }
29
11
}
30
12
}
31
13
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change 1
- using ConsoleAppLibrary ;
2
- using LaDeak . JsonMergePatch . Abstractions ;
1
+ using LaDeak . JsonMergePatch . Abstractions ;
3
2
using LaDeak . JsonMergePatch . Http ;
4
3
5
4
namespace ReadJsonPatchAsync ;
@@ -25,11 +24,8 @@ public static async Task ReadAsJsonMergePatchAsync()
25
24
var httpClient = new HttpClient ( ) ;
26
25
var response = await httpClient . GetAsync ( "https://localhost:5001/Sample/Weather" , HttpCompletionOption . ResponseHeadersRead ) . ConfigureAwait ( false ) ;
27
26
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 } ;
29
28
var result = responseData . ApplyPatch ( target ) ;
30
29
Console . WriteLine ( $ "Patched: Date={ result . Date } , Summary={ result . Summary } , Temp={ result . Temp } ") ;
31
-
32
- var client = new Client ( ) ;
33
- await client . ReadAsJsonMergePatchAsync ( ) ;
34
30
}
35
31
}
You can’t perform that action at this time.
0 commit comments