Skip to content

lazyapi send request ​

Sends one operation and runs its checks: declared status, response contract and the operation's test script.

bash
lazyapi send request <spec.yml> <path> <method> [flags]
lazyapi send request <spec.yml> --op <operationId> [flags]

Flags ​

FlagDescription
--op <id>Operation to send, instead of <path> <method> ("METHOD /path" also works)
--param k=vPath parameter (repeatable). Defaults to the spec's example; a missing value is an error
--query k=v, --header k=vQuery parameter / header (repeatable)
--body <value|@file|@->Request body: literal, read from a file, or from stdin
--form k=vForm field (repeatable): application/x-www-form-urlencoded, or multipart with --file (the operation's declared media type wins)
--file name=pathMultipart file part (repeatable)
--env-name <name>Named environment from .lazyapi/config.yml
--server <url|index>Server URL, or index into the spec's servers (default: first)
--env <file>.env file for {{env.X}}
--timeout <d>Request timeout (default 30s)
--script <file>Test script; overrides the operation's x-lazyapi-tests
--no-contractSkip the response schema check
--output pretty|json|junit|tapjson prints the operation result with full bodies
--output-file <path>, --bodies <failed|all|none>As in run; send defaults to --bodies all
--save-exampleSave the response as an example in the spec
--dry-runResolve the request (URL, headers, body) without sending
--output curlPrint the exact request (after before()) as a curl command instead of sending it
--jq filterShow only this jq slice of the response body (in every output format). Checks still run on the full body
--insecureSkip TLS certificate verification
--ca-cert <pem>Extra trusted CA certificates
--client-cert <pem> / --client-key <pem>Mutual TLS
--proxy <url>http, https or socks5 proxy (default: $HTTPS_PROXY/$HTTP_PROXY)
--no-redirects / --max-redirects <n>Return 3xx responses as-is / limit redirect chains (default 10)
--max-body <size>Maximum response body, e.g. 10MB (default 50MB)
--script-timeout, --offline, --reload, --frozen-lockfile, --allow-importSee Test Scripts

Examples ​

bash
lazyapi send request api.yml /users GET
lazyapi send request api.yml --op getUser --param id=42 --header "X-Trace=abc"
lazyapi send request api.yml --op createUser --body @new-user.json --output json
echo '{"name":"ana"}' | lazyapi send request api.yml --op createUser --body @-
lazyapi send request api.yml --op getUser --param id=1 --save-example
lazyapi send request api.yml --op login --form username=ana --form password=pw
lazyapi send request api.yml --op uploadAvatar --param id=1 --file avatar=./me.png --form caption=hi
lazyapi send request api.yml --op getUser --param id=1 --output curl   # share or debug the exact request
lazyapi send request api.yml --op listUsers --jq '.[] | {id, email}' --output json   # only what you need

Exit status ​

0 when every check passes, 1 when a check fails, 2 for usage errors, and 3 when the request could not be sent (network error, missing path parameter, no server).

Released under the GPLv3 License.

/ search•[ ] prev/next•j/k scroll•h home•t theme•cli/send