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
description: Mokapi generates random realistic test data or lets you customize responses with JavaScript to match your specific use case and scenarios.
4
+
subtitle: Mokapi automatically generates realistic test data from your API specifications. Customize responses with JavaScript or use declarative formats to match your exact testing needs.
5
+
cards:
6
+
items:
7
+
- title: Dashboard Guide
8
+
href: docs/get-started/dashboard
9
+
description: Learn how to validate and visualize your mock data
10
+
- title: Write Scripts
11
+
href: /docs/javascript-api/overview
12
+
description: Add dynamic behavior to your mocks with JavaScript
13
+
- title: Configure Mokapi
14
+
href: /docs/configuration/overview
15
+
description: Customize ports, providers, and other settings
16
+
- title: Explore Tutorials
17
+
href: /resources
18
+
description: Follow step-by-step guides for REST, Kafka, LDAP, and SMTP
4
19
---
5
20
6
-
# Mocking APIs with Realistic Test Data
21
+
# Generate Realistic Test Data
7
22
8
23
Creating reliable test data is essential for accurate API testing and development.
9
24
Mokapi provides a powerful data generation engine that creates realistic test data
10
-
based on API specifications. You can customize and control the generated data using
11
-
JavaScript scripts or declarative configurations to adapt it to real-world scenarios.
25
+
based on your API specifications.
26
+
27
+
You have multiple options for controlling generated data:
28
+
29
+
-**Automatic Generation**
30
+
Mokapi analyzes your schema and generates context-aware, realistic data automatically
31
+
-**Declarative Formats**
32
+
Use standard formats like `date`, `email`, `uuid` in your schema
33
+
-**JavaScript Customization**
34
+
Extend the generator with custom logic for specific fields or patterns
35
+
-**Full Response Control**
36
+
Write complete response handlers with conditional logic and dynamic behavior
12
37
13
38
## Automatic Test Data Generation
14
39
15
-
By default, Mokapi analyzes your API’s data structure and types to generate meaningful responses.
16
-
Additionally, Mokapi tailors responses based on request parameters, ensuring relevant data is returned.
17
-
For example, if a request filters for available pets, the response will include only pets with the status *available*.
40
+
By default, Mokapi analyzes your API's data structure and types to generate
41
+
meaningful responses. It also tailors responses based on request parameters,
42
+
ensuring relevant data is returned.
43
+
44
+
### Context-Aware Generation
45
+
46
+
For example, if a request filters for available pets, the response includes
47
+
only pets with `status: "available":
18
48
19
-
```bash tab=/pet/4
49
+
```bash tab=Single Pet
20
50
GET http://localhost/api/v3/pet/4
21
51
HTTP/1.1 200 OK
22
52
Content-Type: application/json
@@ -39,7 +69,7 @@ Content-Type: application/json
39
69
"status": "pending"
40
70
}
41
71
```
42
-
```bash tab=/pet/findByStatus
72
+
```bash tab=Filtered List
43
73
GET http://localhost/api/v3/pet/findByStatus?status=available
0 commit comments