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
FakeApi provides the ability to send HttpWebRequest and get HttpWebResponses without a server.
@@ -19,7 +21,8 @@ FakeApi is for you!
19
21
# v1.2.0 Release note
20
22
21
23
- Improvement of configuration files reading
22
-
- Adding the capability to split the api configurations files into several files
24
+
- Adding the capability to split the api configurations files into multilpe files. Please read 'Organize your configurations files' section
25
+
- Adding a default implementation of IHttpRequester
23
26
24
27
# How to use FakeApi?
25
28
@@ -81,6 +84,30 @@ For each web api you can set several actives responses. One per pair url/method.
81
84
Note that you can use template segment in your url configuration (/{idUser}).
82
85
You can also override all default values defined at the root path in each apis configuration.
83
86
87
+
- #### Organize your configurations files
88
+
89
+
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 :
90
+
91
+
```json
92
+
{
93
+
"defaultDelay": 250,
94
+
"defaultHttpCode": 200,
95
+
"defaultMethod": "GET",
96
+
"apisDirectories": [
97
+
"Config/Api/User"
98
+
]
99
+
}
100
+
```
101
+
102
+
In summary, I advise you as in the example below :
103
+
- declare a main file (api.cfg.json) with all default values that you need and all api configurations files directories
104
+
- create one configuration file per api type (usersApi.cfg.json, ordersApi.cfg.json etc...)
105
+
- and create one json response file per request (getUserById.json, postUser1.json etc...)
/!\ Be careful, directories containing api configuration files (such as usersApi.cfg) must not contain any other files! Otherwise FakeApi will try to deserialize them and an exception will be thrown.
110
+
84
111
- #### How to return data from file?
85
112
86
113
Simply set the "file" property into your api configuration:
@@ -216,8 +243,7 @@ using (var stream = new StreamReader(getUserResponse.GetResponseStream()))
216
243
````
217
244
- #### IHttpRequester
218
245
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.
246
+
In production, replace the FakeHttpRequester implementation by DefaultHttpRequester provided by FakeApi. Or you can also write your own implementation of IHttpRequester interface.
221
247
222
248
```csharp
223
249
@@ -237,6 +263,31 @@ public interface IHttpRequester
0 commit comments