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-25Lines changed: 51 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,8 +32,8 @@ To generate fake API responses, you must create a configuration file in JSON for
32
32
"endpoints": [
33
33
{
34
34
"url": "/users",
35
-
"type": "GET",// default is GET if omitted
36
-
"cache": 5,// individual cache for this endpoint (5 requests)
35
+
"type": "GET",
36
+
"cache": 5,
37
37
"response": [
38
38
{
39
39
"id": "uuid",
@@ -44,8 +44,7 @@ To generate fake API responses, you must create a configuration file in JSON for
44
44
},
45
45
{
46
46
"url": "/products",
47
-
"cache": 10, // different cache size for this endpoint
48
-
// single object response when response is an object
47
+
"cache": 10,
49
48
"response": {
50
49
"id": "uuid",
51
50
"name": "word",
@@ -54,7 +53,7 @@ To generate fake API responses, you must create a configuration file in JSON for
54
53
},
55
54
{
56
55
"url": "/products/{id}",
57
-
"cache": 3,// smaller cache for individual product
56
+
"cache": 3,
58
57
"response": {
59
58
"id": "uuid",
60
59
"tags": [{
@@ -71,21 +70,19 @@ To generate fake API responses, you must create a configuration file in JSON for
71
70
},
72
71
{
73
72
"url": "/list",
74
-
// no cache field - this endpoint won't be cached
75
73
"response": {
76
74
"names": ["name", "name", "name"]
77
75
}
78
76
},
79
77
{
80
78
"url": "/submit",
81
79
"type": "POST",
82
-
// POST endpoints typically don't need caching
83
80
"response": {"status": "word"}
84
81
},
85
82
{
86
83
"url": "/update/{id}",
87
84
"type": "PATCH",
88
-
"cache": 1,// cache only 1 response for updates
85
+
"cache": 1,
89
86
"response": {"updated": "word"}
90
87
},
91
88
{
@@ -101,7 +98,17 @@ To generate fake API responses, you must create a configuration file in JSON for
101
98
]
102
99
}
103
100
```
104
-
This configuration file defines several endpoints. The `/users` endpoint returns a list (top-level array in `response`) with pagination (by default `page=1` and `per_page=10`). The `/products` endpoint returns a single object (when `response` is an object). Endpoints may specify an HTTP method using `type` and support: `GET` (default), `POST`, `PATCH`, `PUT`, `DELETE`.
101
+
**Configuration explanation:**
102
+
-`/users` - Returns a list (top-level array in `response`) with pagination (by default `page=1` and `per_page=10`), cached for 5 requests
103
+
-`/products` - Returns a single object (when `response` is an object), cached for 10 requests
104
+
-`/products/{id}` - Individual product endpoint, cached for 3 requests
105
+
-`/list` - No caching, generates new data on every request
106
+
-`/submit` - POST endpoint, typically doesn't need caching
107
+
-`/update/{id}` - PATCH endpoint, cached for 1 request
108
+
-`/replace/{id}` - PUT endpoint, no caching
109
+
-`/remove/{id}` - DELETE endpoint, no caching
110
+
111
+
Endpoints may specify an HTTP method using `type` and support: `GET` (default), `POST`, `PATCH`, `PUT`, `DELETE`.
105
112
106
113
## Caching
107
114
@@ -162,34 +169,53 @@ You can specify arrays or objects inside `response`. A top-level object means a
162
169
163
170
### Type Usage Examples
164
171
172
+
**User Profile Example:**
173
+
-`id: "uuid"` - Unique identifier
174
+
-`name: "name"` - Full name
175
+
-`email: "email"` - Email address
176
+
-`phone: "phone"` - Phone number
177
+
-`location.city: "city"` - City name
178
+
-`location.country: "country"` - Country name
179
+
-`created_at: "date"` - Creation date
180
+
-`age: "int"` - Age as integer
181
+
-`bio: "paragraph"` - Biography text
182
+
183
+
**Product Example:**
184
+
-`id: "uuid"` - Unique identifier
185
+
-`title: "word"` - Product title
186
+
-`description: "sentence"` - Product description
187
+
-`price: "float"` - Price as decimal
188
+
-`tags: ["word", "word"]` - Array of tags
189
+
-`website: "url"` - Product website
190
+
165
191
```json
166
192
{
167
193
"endpoints": [
168
194
{
169
195
"url": "/user-profile",
170
196
"response": {
171
-
"id": "uuid",// Unique identifier
172
-
"name": "name",// Full name
173
-
"email": "email",// Email address
174
-
"phone": "phone",// Phone number
197
+
"id": "uuid",
198
+
"name": "name",
199
+
"email": "email",
200
+
"phone": "phone",
175
201
"location": {
176
-
"city": "city",// City name
177
-
"country": "country"// Country name
202
+
"city": "city",
203
+
"country": "country"
178
204
},
179
-
"created_at": "date",// Creation date
180
-
"age": "int",// Age as integer
181
-
"bio": "paragraph"// Biography text
205
+
"created_at": "date",
206
+
"age": "int",
207
+
"bio": "paragraph"
182
208
}
183
209
},
184
210
{
185
211
"url": "/product",
186
212
"response": {
187
213
"id": "uuid",
188
-
"title": "word",// Product title
189
-
"description": "sentence",// Product description
190
-
"price": "float",// Price as decimal
191
-
"tags": ["word", "word"],// Array of tags
192
-
"website": "url"// Product website
214
+
"title": "word",
215
+
"description": "sentence",
216
+
"price": "float",
217
+
"tags": ["word", "word"],
218
+
"website": "url"
193
219
}
194
220
}
195
221
]
@@ -227,12 +253,12 @@ If you're upgrading from a version with global cache, here's how to migrate:
0 commit comments