What it answers
- Examples first. An operation’s response example is returned when the spec has one; otherwise data is generated from the schema, respecting formats, patterns, enums and ranges. Generated data is the same on every run (change it with
--seed). - Requests are validated. Parameters and JSON, form and multipart bodies are checked against the spec. A bad request gets
400with the list of problems (422when the operation documents422and not400). - OpenAPI 3.2 methods.
QUERYoperations and those underadditionalOperations(PURGE,COPY,LINK, …) are served and validated like the others, and pass CORS preflight. A method Node’s HTTP server doesn’t accept can’t be called; the mock warns about it when it starts. - Streams. A response whose media type has an OpenAPI 3.2
itemSchema(Server-Sent Events, JSON Lines,application/json-seq) is sent one item at a time,--stream-intervalapart (default 300 ms). A JSON Lines request body is checked line by line against itsitemSchema. - CORS is allowed for any origin.
- A delay, with
--delay <ms>: every API response waits that long, to see loading states in a client.
An example written the wrong way
Section titled “An example written the wrong way”Some specs put a named example under example, where it belongs under examples:
example: Calendar example: id: 1 name: TeamThe mock returns the value under the name, not the wrapper, when the response schema confirms it. rapidoc lint reports it as example-named-map.
With --stateful, operations that fit a resource are answered from stored records. See Keeping state.