Skip to content

Commit

Permalink
[add] JsonModeTestController
Browse files Browse the repository at this point in the history
[r] to raw strings
  • Loading branch information
i4004 committed May 30, 2024
1 parent 2ac8b7e commit 467fdfe
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 10 deletions.
31 changes: 31 additions & 0 deletions postman/SampleApp.Api.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,37 @@
}
},
"response": []
},
{
"name": "Json Mode Test V2",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"StringParam\": \"Foo\",\r\n \"IntParam\": 1,\r\n \"BoolParam\": true,\r\n \"StringListParam\": \r\n [\r\n \"Foo\",\r\n \"Bar\"\r\n ]\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BaseUrl}}/api/v2/json-model-test",
"host": [
"{{BaseUrl}}"
],
"path": [
"api",
"v2",
"json-model-test"
]
}
},
"response": []
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ namespace SampleApp.Api.Controllers.V1;
public class DifferentRouteParametersController : Controller
{
public override ControllerResponse Invoke() =>
Content($@"
String param: {RouteParameters.StringParam}
Integer param: {RouteParameters.IntParam}
bool param: {RouteParameters.BoolParam},
String array param: {string.Join(", ", RouteParameters.StringArrayParam)}");
Content($"""
String param: {RouteParameters.StringParam}
Integer param: {RouteParameters.IntParam}
bool param: {RouteParameters.BoolParam},
String array param: {string.Join(", ", RouteParameters.StringArrayParam)}
""");
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ namespace SampleApp.Api.Controllers.V2;
public class DifferentRouteParametersController : Controller2
{
public ControllerResponse Invoke(string stringParam, int intParam, bool boolParam, string[] stringArrayParam) =>
Content($@"
String param: {stringParam}
Integer param: {intParam}
bool param: {boolParam},
String array param: {string.Join(", ", stringArrayParam)}");
Content($"""
String param: {stringParam}
Integer param: {intParam}
bool param: {boolParam},
String array param: {string.Join(", ", stringArrayParam)}
""");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using SampleApp.Api.ViewModels;
using Simplify.Web;
using Simplify.Web.Attributes;

namespace SampleApp.Api.Controllers.V2;

[Get("api/v2/json-model-test")]
public class JsonModeTestController : Controller2<TestModel>
{
public ControllerResponse Invoke() =>
Content($"""
String param: {Model.StringParam}
Integer param: {Model.IntParam}
bool param: {Model.BoolParam}
String list param: {string.Join(", ", Model.StringListParam!)}
""");
}
9 changes: 9 additions & 0 deletions src/SampleApps/SampleApp.Api/ViewModels/TestModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SampleApp.Api.ViewModels;

public class TestModel
{
public string? StringParam { get; set; }
public int IntParam { get; set; }
public bool BoolParam { get; set; }
public IList<string>? StringListParam { get; set; }
}

0 comments on commit 467fdfe

Please sign in to comment.