You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51-4Lines changed: 51 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,8 @@ FakeApi is for you!
19
19
# v1.2.0 Release note
20
20
21
21
- Improvement of configuration files reading
22
-
- Adding the capability to split the api configurations files into several files
22
+
- Adding the capability to split the api configurations files into multilpe files. Please read 'Organize your configurations files' section
23
+
- Adding a default implementation of IHttpRequester
23
24
24
25
# How to use FakeApi?
25
26
@@ -81,6 +82,28 @@ For each web api you can set several actives responses. One per pair url/method.
81
82
Note that you can use template segment in your url configuration (/{idUser}).
82
83
You can also override all default values defined at the root path in each apis configuration.
83
84
85
+
- #### Organize your configurations files
86
+
87
+
You can configure FakeApi in a single file. But you can now split your Apis configurations files into multiple files. To do that, just provide all directories where FakeApi can find api configurations files by this way :
88
+
89
+
```json
90
+
{
91
+
"defaultDelay": 250,
92
+
"defaultHttpCode": 200,
93
+
"defaultMethod": "GET",
94
+
"apisDirectories": [
95
+
"Config/Api/User"
96
+
]
97
+
}
98
+
```
99
+
100
+
In summary, I advise you as in the example below :
101
+
- declare a main file (api.cfg.json) with all default values that you need and all api configurations files directories
102
+
- create one configuration file per api type (usersApi.cfg.json, ordersApi.cfg.json etc...)
103
+
- and create one json response file per request (getUserById.json, postUser1.json etc...)
Simply set the "file" property into your api configuration:
@@ -216,8 +239,7 @@ using (var stream = new StreamReader(getUserResponse.GetResponseStream()))
216
239
````
217
240
- #### IHttpRequester
218
241
219
-
In production, replace the FakeHttpRequester implemention of FakeApi by your own implementation.
220
-
FakeHttpRequester implements IHttpRequester to provide method to send HttpWebRequest synchronous or asynchronous.
242
+
In production, replace the FakeHttpRequester implementation by DefaultHttpRequester provided by FakeApi. Or you can also write your own implementation of IHttpRequester interface.
221
243
222
244
```csharp
223
245
@@ -237,6 +259,31 @@ public interface IHttpRequester
0 commit comments