Skip to content

Commit b49e84d

Browse files
committed
Merge branch 'release/2.0'
2 parents 3947b64 + 272c490 commit b49e84d

19 files changed

+321
-16
lines changed

.vscode/launch.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "TesterApp Launch",
6+
"type": "coreclr",
7+
"request": "launch",
8+
"preLaunchTask": "Build",
9+
"program": "${workspaceFolder}/src/TesterApp/bin/Debug/netcoreapp3.0/TesterApp.dll",
10+
"cwd": "${workspaceFolder}/src/TesterApp",
11+
"internalConsoleOptions": "openOnSessionStart",
12+
"env":
13+
{
14+
"ASPNETCORE_ENVIRONMENT": "Development"
15+
}
16+
}]
17+
}

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type": "process",
88
"args": [
99
"build",
10-
"${workspaceFolder}/Simplify.Web.Json.sln"
10+
"${workspaceFolder}/src/Simplify.Web.Json.sln"
1111
],
1212
"problemMatcher": "$msCompile",
1313
"group":
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
"info": {
3+
"_postman_id": "cddfc51b-17d2-4e4b-b3a4-a6a9037ee3db",
4+
"name": "Simplify.Web.Json.Tester",
5+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
6+
},
7+
"item": [
8+
{
9+
"name": "TestIn",
10+
"event": [
11+
{
12+
"listen": "test",
13+
"script": {
14+
"id": "0f7d2763-acbf-4799-9fdc-58386f9503bf",
15+
"exec": [
16+
"tests[\"HTTP Code Test\"] = responseCode.code === 204;",
17+
""
18+
],
19+
"type": "text/javascript"
20+
}
21+
}
22+
],
23+
"request": {
24+
"auth": {
25+
"type": "noauth"
26+
},
27+
"method": "POST",
28+
"header": [
29+
{
30+
"key": "Content-Type",
31+
"name": "Content-Type",
32+
"value": "application/json",
33+
"type": "text"
34+
}
35+
],
36+
"body": {
37+
"mode": "raw",
38+
"raw": "{\n\t\"Prop1\": \"Hello!\"\n}"
39+
},
40+
"url": {
41+
"raw": "http://localhost:5000/api/v1/testIn",
42+
"protocol": "http",
43+
"host": [
44+
"localhost"
45+
],
46+
"port": "5000",
47+
"path": [
48+
"api",
49+
"v1",
50+
"testIn"
51+
]
52+
}
53+
},
54+
"response": []
55+
},
56+
{
57+
"name": "TestOut",
58+
"event": [
59+
{
60+
"listen": "test",
61+
"script": {
62+
"id": "ea67aa25-0f40-4700-b356-fc58ef45b32f",
63+
"exec": [
64+
"// Tests",
65+
"tests[\"Get Access Token\"] = responseCode.code === 200;",
66+
"",
67+
"var jsonReply = JSON.parse(responseBody);",
68+
"",
69+
"// Tests",
70+
"",
71+
"tests[\"Prop1 Exist\"] = jsonReply.Prop1 == \"Hello\";"
72+
],
73+
"type": "text/javascript"
74+
}
75+
}
76+
],
77+
"request": {
78+
"auth": {
79+
"type": "noauth"
80+
},
81+
"method": "GET",
82+
"header": [
83+
{
84+
"key": "Content-Type",
85+
"name": "Content-Type",
86+
"type": "text",
87+
"value": "application/json"
88+
}
89+
],
90+
"url": {
91+
"raw": "http://localhost:5000/api/v1/testOut",
92+
"protocol": "http",
93+
"host": [
94+
"localhost"
95+
],
96+
"port": "5000",
97+
"path": [
98+
"api",
99+
"v1",
100+
"testOut"
101+
]
102+
}
103+
},
104+
"response": []
105+
}
106+
],
107+
"protocolProfileBehavior": {}
108+
}

appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ configuration: Release
99
platform: Any CPU
1010

1111
before_build:
12-
- nuget restore
12+
- nuget restore src/Simplify.Web.Json.sln
1313

1414
build:
15+
project: src/Simplify.Web.Json.sln
1516
publish_nuget: true
1617
parallel: true
1718
verbosity: minimal
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.29215.179
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Simplify.Web.Json", "Simplify.Web.Json\Simplify.Web.Json.csproj", "{1834BEA8-2331-4A44-86C9-CC764BCA0761}"
77
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TesterApp", "TesterApp\TesterApp.csproj", "{857E0A47-2D7B-478A-BEEF-6CB3CF9EC5B3}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{1834BEA8-2331-4A44-86C9-CC764BCA0761}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{1834BEA8-2331-4A44-86C9-CC764BCA0761}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{1834BEA8-2331-4A44-86C9-CC764BCA0761}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{857E0A47-2D7B-478A-BEEF-6CB3CF9EC5B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{857E0A47-2D7B-478A-BEEF-6CB3CF9EC5B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{857E0A47-2D7B-478A-BEEF-6CB3CF9EC5B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{857E0A47-2D7B-478A-BEEF-6CB3CF9EC5B3}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

Simplify.Web.Json/ModelBinding/Binders/JsonModelBinder.cs renamed to src/Simplify.Web.Json/Model/Binding/JsonModelBinder.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
1-
using Newtonsoft.Json;
1+
using System.Threading.Tasks;
2+
using Newtonsoft.Json;
23
using Simplify.Web.Model.Binding;
34
using Simplify.Web.Model.Validation;
45

5-
namespace Simplify.Web.Json.ModelBinding.Binders
6+
namespace Simplify.Web.Json.Model.Binding
67
{
78
/// <summary>
89
/// Provides HTTP request JSON data to object binding
910
/// </summary>
1011
public class JsonModelBinder : IModelBinder
1112
{
1213
/// <summary>
13-
/// Binds the specified JSON data to object.
14+
/// Binds the model asynchronously.
1415
/// </summary>
1516
/// <typeparam name="T">Model type</typeparam>
16-
/// <param name="args">The <see cref="ModelBinderEventArgs{T}"/> instance containing the event data.</param>
17-
public void Bind<T>(ModelBinderEventArgs<T> args)
17+
/// <param name="args">The <see cref="T:Simplify.Web.Model.Binding.ModelBinderEventArgs`1" /> instance containing the event data.</param>
18+
/// <returns></returns>
19+
/// <exception cref="ModelValidationException">JSON request body is null or empty</exception>
20+
public async Task BindAsync<T>(ModelBinderEventArgs<T> args)
1821
{
1922
if (!args.Context.Request.ContentType.Contains("application/json"))
2023
return;
2124

2225
if (string.IsNullOrEmpty(args.Context.RequestBody))
2326
throw new ModelValidationException("JSON request body is null or empty");
2427

28+
await args.Context.ReadRequestBodyAsync();
29+
2530
args.SetModel(JsonConvert.DeserializeObject<T>(args.Context.RequestBody));
2631
}
2732
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Newtonsoft.Json;
1+
using System.Threading.Tasks;
2+
using Newtonsoft.Json;
23

34
namespace Simplify.Web.Json.Responses
45
{
@@ -32,12 +33,12 @@ public Json(object objectToConvert, int statusCode = 200)
3233
/// Processes this response
3334
/// </summary>
3435
/// <returns></returns>
35-
public override ControllerResponseResult Process()
36+
public override async Task<ControllerResponseResult> Process()
3637
{
3738
Context.Response.ContentType = "application/json";
3839
Context.Response.StatusCode = _statusCode;
3940

40-
ResponseWriter.Write(JsonConvert.SerializeObject(_objectToConvert), Context.Response);
41+
await ResponseWriter.WriteAsync(JsonConvert.SerializeObject(_objectToConvert), Context.Response);
4142

4243
return ControllerResponseResult.RawOutput;
4344
}

Simplify.Web.Json/Simplify.Web.Json.csproj renamed to src/Simplify.Web.Json/Simplify.Web.Json.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
<Product>Simplify</Product>
88
<Description>Simplify.Web JSON controller response and model binder</Description>
99
<Copyright>Licensed under LGPL</Copyright>
10-
<Version>1.4</Version>
10+
<Version>2.0</Version>
1111
<PackageProjectUrl>https://github.com/SimplifyNet/Simplify.Web.Json</PackageProjectUrl>
1212
<PackageIconUrl>https://raw.githubusercontent.com/SimplifyNet/Images/master/LogoWeb32x32.png</PackageIconUrl>
1313
<RepositoryUrl>https://github.com/SimplifyNet/Simplify.Web.Json</RepositoryUrl>
1414
<RepositoryType>GIT</RepositoryType>
1515
<PackageTags>Simplify.Web JSON</PackageTags>
1616
<PackageReleaseNotes>
17-
New
18-
* JsonModelBinder container registration method added (#5)
17+
Breaking Changes
18+
* Upgrade to Simplify.Web 4 (#8)
1919
</PackageReleaseNotes>
2020
<OutputPath>bin\Any CPU\$(Configuration)\</OutputPath>
2121
<DocumentationFile>bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.Web.Json.xml</DocumentationFile>
2222
</PropertyGroup>
2323
<ItemGroup>
24-
<PackageReference Include="Simplify.Web" Version="3.0.0" />
25-
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
24+
<PackageReference Include="Simplify.Web" Version="4.0.0" />
25+
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
2626
</ItemGroup>
2727
</Project>

Simplify.Web.Json/SimplifyDIRegistratorExtensions.cs renamed to src/Simplify.Web.Json/SimplifyDIRegistratorExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Simplify.DI;
2-
using Simplify.Web.Json.ModelBinding.Binders;
2+
using Simplify.Web.Json.Model.Binding;
33

44
namespace Simplify.Web.Json
55
{

0 commit comments

Comments
 (0)