Skip to content

Commit 0e31663

Browse files
committed
Fixed readme
1 parent 13c465d commit 0e31663

File tree

1 file changed

+51
-25
lines changed

1 file changed

+51
-25
lines changed

README.md

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ To generate fake API responses, you must create a configuration file in JSON for
3232
"endpoints": [
3333
{
3434
"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,
3737
"response": [
3838
{
3939
"id": "uuid",
@@ -44,8 +44,7 @@ To generate fake API responses, you must create a configuration file in JSON for
4444
},
4545
{
4646
"url": "/products",
47-
"cache": 10, // different cache size for this endpoint
48-
// single object response when response is an object
47+
"cache": 10,
4948
"response": {
5049
"id": "uuid",
5150
"name": "word",
@@ -54,7 +53,7 @@ To generate fake API responses, you must create a configuration file in JSON for
5453
},
5554
{
5655
"url": "/products/{id}",
57-
"cache": 3, // smaller cache for individual product
56+
"cache": 3,
5857
"response": {
5958
"id": "uuid",
6059
"tags": [{
@@ -71,21 +70,19 @@ To generate fake API responses, you must create a configuration file in JSON for
7170
},
7271
{
7372
"url": "/list",
74-
// no cache field - this endpoint won't be cached
7573
"response": {
7674
"names": ["name", "name", "name"]
7775
}
7876
},
7977
{
8078
"url": "/submit",
8179
"type": "POST",
82-
// POST endpoints typically don't need caching
8380
"response": {"status": "word"}
8481
},
8582
{
8683
"url": "/update/{id}",
8784
"type": "PATCH",
88-
"cache": 1, // cache only 1 response for updates
85+
"cache": 1,
8986
"response": {"updated": "word"}
9087
},
9188
{
@@ -101,7 +98,17 @@ To generate fake API responses, you must create a configuration file in JSON for
10198
]
10299
}
103100
```
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`.
105112

106113
## Caching
107114

@@ -162,34 +169,53 @@ You can specify arrays or objects inside `response`. A top-level object means a
162169

163170
### Type Usage Examples
164171

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+
165191
```json
166192
{
167193
"endpoints": [
168194
{
169195
"url": "/user-profile",
170196
"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",
175201
"location": {
176-
"city": "city", // City name
177-
"country": "country" // Country name
202+
"city": "city",
203+
"country": "country"
178204
},
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"
182208
}
183209
},
184210
{
185211
"url": "/product",
186212
"response": {
187213
"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"
193219
}
194220
}
195221
]
@@ -227,12 +253,12 @@ If you're upgrading from a version with global cache, here's how to migrate:
227253
"endpoints": [
228254
{
229255
"url": "/users",
230-
"cache": 5, // Move cache setting to each endpoint
256+
"cache": 5,
231257
"response": {...}
232258
},
233259
{
234260
"url": "/products",
235-
"cache": 5, // Apply same cache to all endpoints
261+
"cache": 5,
236262
"response": {...}
237263
}
238264
]

0 commit comments

Comments
 (0)