This schema defines deterministic, file-based WebSocket request execution used by:
api-websocket callapi-websocket report --runapi-testsuite cases withtype: "websocket"
A request file must be a JSON object.
Supported top-level fields:
url(string, optional): explicit WebSocket target.headers(object, optional): handshake headers.connectTimeoutSeconds(integer/string, optional): reserved timeout input (accepted for contract parity).steps(array, required): ordered scripted session steps.expect(object, optional): assertion against the last received message.
Each steps[i] must include type.
textorjsonorpayload(required)- payload is serialized to text before send.
timeoutSeconds(optional)expect(optional):textContains(string)jq(string, evaluated against JSON-parsed receive text)
- no extra fields required.
Top-level or step-level expect supports:
textContains: substring matchjq: jq expression evaluated against JSON message text
Validation behavior:
- if both are omitted/empty, expect is ignored.
- jq assertions fail when receive text is not valid JSON.
Deterministic schema errors include:
- request file is not valid JSON
- request root is not a JSON object
stepsis missing/empty- unsupported
steps[i].type - missing send payload fields
| Fixture | Purpose | Expected outcome |
|---|---|---|
health.ws.json |
send/receive success (jq true) |
pass |
expect-fail.ws.json |
receive message fails textContains/jq |
failure with assertion message |
invalid-json.ws.json |
malformed JSON file | schema load failure |
missing-steps.ws.json |
no steps field |
schema validation failure |
connect-fail.ws.json |
unreachable target URL | connection failure |
A minimal reusable fixture for both CLI and suite tests:
{
"steps": [
{"type": "send", "text": "ping"},
{"type": "receive", "expect": {"jq": ".ok == true"}},
{"type": "close"}
],
"expect": {"textContains": "ok"}
}