Skip to content

By default every call is answered on its own: a POST returns a made-up record, and the next GET doesn’t know about it. With --stateful the mock keeps data, like the real server would:

npx rapidoc mock openapi.yaml --stateful
  • It works out the data model from the spec. Paths such as /pets and /pets/{petId} that share a schema become one resource, with its key and its links to other resources. How it works has the details.
  • It starts with data. Each resource gets 10 records (--rows). See Seed data.
  • Writes are kept. A create stores a record, an update or delete changes it, and reads and lists return what is stored.
  • Lists filter and page. Query parameters that match a field filter the list; limit, offset and page page it, and a count beside the records gets the real total.
  • Records stay under their parent. A comment created at /articles/{slug}/comments is listed and found under that article only, whether or not it has a field for the article.
  • Responses keep the spec’s shape. A record goes where the response schema puts it, such as inside data next to a request_id.
  • Everything else answers as before. An operation that fits no resource (a login, a search, a file upload) gets its example or generated data.

The data lives in memory and starts fresh on every run.

Fields the caller can’t send, or left out, are filled the way a server would: an id, timestamps set to now, lists empty, counts at zero. A key the path expects as a number is a number.

A read, update or delete of a record that isn’t there returns the spec’s own 404 response when it documents one.