@stdy/cli 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +137 -9
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -157,15 +157,17 @@ validation errors are logged but responses are still returned.
157
157
 
158
158
  Override server behavior for individual requests:
159
159
 
160
- | Header | Description |
161
- | ------------------------------ | ------------------------------------------------- |
162
- | `X-Steady-Mode` | Override validation mode: `strict` or `relaxed` |
163
- | `X-Steady-Query-Array-Format` | Override array query param serialization format |
164
- | `X-Steady-Query-Object-Format` | Override object query param serialization format |
165
- | `X-Steady-Array-Size` | Override array size (sets both min and max) |
166
- | `X-Steady-Array-Min` | Override minimum array size |
167
- | `X-Steady-Array-Max` | Override maximum array size |
168
- | `X-Steady-Seed` | Override random seed (`-1` for non-deterministic) |
160
+ | Header | Description |
161
+ | ------------------------------ | ---------------------------------------------------- |
162
+ | `X-Steady-Mode` | Override validation mode: `strict` or `relaxed` |
163
+ | `X-Steady-Query-Array-Format` | Override array query param serialization format |
164
+ | `X-Steady-Query-Object-Format` | Override object query param serialization format |
165
+ | `X-Steady-Array-Size` | Override array size (sets both min and max) |
166
+ | `X-Steady-Array-Min` | Override minimum array size |
167
+ | `X-Steady-Array-Max` | Override maximum array size |
168
+ | `X-Steady-Seed` | Override random seed (`-1` for non-deterministic) |
169
+ | `X-Steady-Stream-Count` | Number of items to stream (default: 5) |
170
+ | `X-Steady-Stream-Interval-Ms` | Interval between streamed items in ms (default: 100) |
169
171
 
170
172
  ```bash
171
173
  # Force strict validation
@@ -190,6 +192,132 @@ Informational headers returned by the server:
190
192
  | `X-Steady-Mode` | The validation mode used for this request |
191
193
  | `X-Steady-Matched-Path` | The OpenAPI path pattern that matched |
192
194
  | `X-Steady-Example-Source` | How the response was generated: `generated` or `none` |
195
+ | `X-Steady-Streaming` | Set to `true` for streaming responses |
196
+
197
+ ## Streaming Responses
198
+
199
+ Steady supports streaming responses for NDJSON and Server-Sent Events (SSE):
200
+
201
+ | Content Type | Format | Description |
202
+ | ---------------------- | ------ | ---------------------- |
203
+ | `application/x-ndjson` | NDJSON | Newline-delimited JSON |
204
+ | `application/jsonl` | NDJSON | JSON Lines |
205
+ | `application/json-seq` | NDJSON | JSON Sequence |
206
+ | `text/event-stream` | SSE | Server-Sent Events |
207
+
208
+ ### Streaming Headers
209
+
210
+ | Header | Description |
211
+ | ----------------------------- | ------------------------------------------- |
212
+ | `X-Steady-Stream-Count` | Number of items to stream (default: 5) |
213
+ | `X-Steady-Stream-Interval-Ms` | Interval between items in ms (default: 100) |
214
+
215
+ ```bash
216
+ # Stream 10 items with 50ms delay
217
+ curl -H "X-Steady-Stream-Count: 10" \
218
+ -H "X-Steady-Stream-Interval-Ms: 50" \
219
+ http://localhost:3000/events
220
+ ```
221
+
222
+ ### NDJSON Example
223
+
224
+ ```yaml
225
+ /metrics:
226
+ get:
227
+ responses:
228
+ "200":
229
+ content:
230
+ application/x-ndjson:
231
+ schema:
232
+ type: object
233
+ properties:
234
+ id: { type: integer }
235
+ value: { type: number }
236
+ ```
237
+
238
+ Output:
239
+
240
+ ```
241
+ {"id":1,"value":42.5,"_stream":{"index":0,"total":5,"timestamp":"..."}}
242
+ {"id":2,"value":43.1,"_stream":{"index":1,"total":5,"timestamp":"..."}}
243
+ ...
244
+ ```
245
+
246
+ ### SSE with Event Sequences
247
+
248
+ Define realistic SSE flows with different event types using array examples:
249
+
250
+ ```yaml
251
+ /events:
252
+ get:
253
+ responses:
254
+ "200":
255
+ content:
256
+ text/event-stream:
257
+ example:
258
+ - event: start
259
+ data: { status: "processing" }
260
+ - event: progress
261
+ data: { percent: 50 }
262
+ - event: progress
263
+ data: { percent: 100 }
264
+ - event: complete
265
+ data: { result: "success" }
266
+ ```
267
+
268
+ Output:
269
+
270
+ ```
271
+ id: 0
272
+ event: start
273
+ data: {"status":"processing"}
274
+
275
+ id: 1
276
+ event: progress
277
+ data: {"percent":50}
278
+
279
+ id: 2
280
+ event: progress
281
+ data: {"percent":100}
282
+
283
+ id: 3
284
+ event: complete
285
+ data: {"result":"success"}
286
+ ```
287
+
288
+ SSE events support these fields:
289
+
290
+ - `event` - Event type name (default: "message"; set to `null` or `""` to omit)
291
+ - `data` - Event payload (required; strings output as-is, objects JSON-encoded)
292
+ - `id` - Custom event ID (auto-generated if omitted; set to `null` to omit)
293
+ - `retry` - Reconnection timeout in milliseconds
294
+
295
+ If the last event isn't `done`, `complete`, or `end`, Steady automatically
296
+ appends a `done` event to signal stream completion.
297
+
298
+ ### OpenAI-Style SSE
299
+
300
+ For APIs like OpenAI that use data-only terminal events, set `event` and `id` to
301
+ `null`:
302
+
303
+ ```yaml
304
+ example:
305
+ - event: message
306
+ data: { delta: { content: "Hello" } }
307
+ - event: null
308
+ id: null
309
+ data: "[DONE]"
310
+ ```
311
+
312
+ Output:
313
+
314
+ ```
315
+ id: 0
316
+ event: message
317
+ data: {"delta":{"content":"Hello"}}
318
+
319
+ data: [DONE]
320
+ ```
193
321
 
194
322
  ## Special Endpoints
195
323
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdy/cli",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "description": "OpenAPI 3 mock server. Validates SDKs against OpenAPI specs with clear error attribution.",
5
5
  "license": "Elastic-2.0",
6
6
  "repository": {
@@ -29,10 +29,10 @@
29
29
  "node": ">=14.0.0"
30
30
  },
31
31
  "optionalDependencies": {
32
- "@stdy/cli-linux-x64": "0.5.1",
33
- "@stdy/cli-linux-arm64": "0.5.1",
34
- "@stdy/cli-darwin-x64": "0.5.1",
35
- "@stdy/cli-darwin-arm64": "0.5.1",
36
- "@stdy/cli-win32-x64": "0.5.1"
32
+ "@stdy/cli-linux-x64": "0.7.0",
33
+ "@stdy/cli-linux-arm64": "0.7.0",
34
+ "@stdy/cli-darwin-x64": "0.7.0",
35
+ "@stdy/cli-darwin-arm64": "0.7.0",
36
+ "@stdy/cli-win32-x64": "0.7.0"
37
37
  }
38
38
  }