A mock server generated from one or more arbitrary Swagger files. Supports seeding, timeouts, response picking, entity memory, semantic action inference, etc.
Syntax: pokemock <swagger-urls-or-files> ... [-h] [-v] [-w] [-p <port>] Options: -h, --help Show help -v, --version Show version -p, --port <port> Set server port, default is 8000 -w, --watch Watch mode: Restart on Swagger changes -k, --killable Publish /kill endpoint to stop the service --memory Enable memory module (experimental)
The mock server listens to the specified port and
mocks endpoints defined in the provided Swagger document.
Additionally, it publishes a Swagger UI under
the Swagger API under
/api-docs and a
/kill endpoint for shutdown.
Using optional headers, clients can control the server's behavior:
<data>is arbitrary JSON
--memory switch to enable the memory module.
When enabled, entities containing an ID are remembered by the server.
If the entity is requested again, the remembered data is returned.
This also applies to sub-entities across endpoints.
Additionally, the server tries to infer semantic actions from requests, such as:
These actions are applied to known entities in memory. For example, requesting a deleted entity will result in a 404 response.
Pokemock provides a set of Express middlewares
which you can use independently.
The default app defined in
createDefaultApp.js is an opinionated stack of
middlewares which you're encouraged to hack on.
By re-arranging and adding middlewares (especially generators)
you can tailor Pokemock to fit your APIs.