formats / transforms
formats — list supported export formats
bash
request-mock formats
# {"formats":["curl","wget","python","postman","xml","yaml","har","json","jsonl","csv","markdown","html","text"],"ok":true}
request-mock formats --raw
# curl
# wget
# python
# ...Format table
| Format | Description | Multi-entry |
|---|---|---|
curl | curl command(s) | one per entry |
wget | wget command(s) | one per entry |
python | Python requests code | one per entry |
postman | Postman collection v2.1 | single collection |
xml | HAR XML | single doc |
yaml | HAR YAML | single doc |
har / json | HAR JSON | single doc |
jsonl | JSON Lines (one entry per line) | one per entry |
csv | Tabular CSV (method,url,status,...) | one per entry |
markdown | Human-readable markdown table | single doc |
html | HTML table | single doc |
text | Plain text summary | single doc |
transforms — list built-in transforms
bash
request-mock transforms
# {"ok":true,"transforms":["body_noise","connection","header","host","index","path","port","priority","query_noise","resource_type","resp_cookie","seq_status","server_ip","status","timings","user_agent"]}
request-mock transforms --raw
# body_noise
# connection
# ...Transform descriptions
| Name | Mutates | Description |
|---|---|---|
server_ip | ServerIP | Random IPv4 address |
user_agent | Headers["User-Agent"] | Random UA from pool |
path | URL path | Random suffix segment |
query_noise | Query params | Add random noise params |
status | ResponseStatus | Random HTTP status (200/4xx/5xx) |
timings | Timings | Random timing values |
index | URL | Append /_idx=<i> query param |
port | URL port | Replace port with random from pool |
host | URL host | Random subdomain prefix |
resp_cookie | ResponseCookies | Random response cookie |
header | Headers | Random request header |
body_noise | PostText | Inject noise into JSON body |
seq_status | ResponseStatus | Sequential status codes (200→201→...→500→loop) |
priority | Priority | Random Chrome priority |
resource_type | ResourceType | Random Chrome resource type |
connection | Connection | Random connection ID |
Transform pipeline
mermaid
flowchart LR
Base["Base spec"] --> T1["server_ip"]
T1 --> T2["user_agent"]
T2 --> T3["path"]
T3 --> T4["query_noise"]
T4 --> T5["status"]
T5 --> T6["timings"]
T6 --> T7["index"]
T7 --> Out["Derived spec"]
style Base fill:#e1f5ff
style Out fill:#e8f5e9Transforms are applied in the order specified by --transform. If no --transform is given, the default set is used (defined in mock.DefaultTransforms). Pass --transform none to disable all transforms.
Custom transforms (SDK)
In Go, implement the mock.Transform function signature:
go
type Transform func(spec *RequestSpec, index int, r *rand.Rand)
func MyTransform(spec *RequestSpec, i int, r *rand.Rand) {
spec.Headers["X-Custom"] = fmt.Sprintf("val-%d", r.Intn(1000))
}
specs := g.GenerateSpecs(base, 100, MyTransform, mock.RandomServerIP)