Examples
Get started with these practical examples to understand how Chimera works and how you can tailor it for your development workflows.
Basic Example
Section titled “Basic Example”Create a simple data.json mock:
{ "/api/products": [ { "id": 1, "name": "Laptop", "price": 1200 }, { "id": 2, "name": "Keyboard", "price": 100 } ]}Directoryproject/
- data.json
Run Chimera:
chimera-cli.exe --path data.jsonVisit http://localhost:8080/api/products to see the mock response.
Run a HTTP mock server
Section titled “Run a HTTP mock server”chimera-cli.exe --path data.json httpThis runs a mock http server
Run a Websocket mock server
Section titled “Run a Websocket mock server”chimera-cli.exe --path data.json websocketThis runs a mock websocket server
Simulate Latency
Section titled “Simulate Latency”chimera-cli.exe --path data.json http --latency 300This adds a 300ms delay to all responses.
Paginate Results
Section titled “Paginate Results”chimera-cli.exe --path data.json http --page 2Returns 2 results per page.
Sorted Responses
Section titled “Sorted Responses”chimera-cli.exe --path data.json http --sort api/products desc idSorts the /api/products endpoint in descending order by attribute id.
Using a Schema for Data AutoGeneration
Section titled “Using a Schema for Data AutoGeneration”chimera-cli.exe --path schema.json http -XExample schema.json:
{ "routes": [ { "path": "api/v2/comment", "no_of_entries": 5, "schema": { "id": "id", "user": "name", "message": "lorem" }, "null_percentage": 0 } ]}This generates 5 random comments.
Combine Flags
Section titled “Combine Flags”chimera-cli.exe --path schema.json http -X --port 4000 --latency 150 --sort api/data asc idCombines data auto-generation, sorting, and latency as a http mock server on on port 4000.