github.com/jormaechea/open-api-mocker ↗
A mock server based in OpenAPI Specification
Open this visualization on its own page →
Contributors
4
Lines of Code
318
From
2019-06-22
To
2021-02-13
About jormaechea/open-api-mocker
OpenAPI Mocker is a mock API server that generates realistic responses based on OpenAPI 3.0 specification files. It reads both YAML and JSON schema definitions and automatically starts an HTTP server that validates incoming requests against the schema and returns appropriate responses with generated data. The tool can be installed via npm or run as a Docker container, making it accessible for various deployment scenarios.
The mocker supports comprehensive request and response handling including parameter validation, request body validation, and response generation from examples or schemas defined in the OpenAPI spec. Developers can select specific responses using the Prefer header to request particular status codes or named examples. Request and response logging is built in, and the server respects basepath configurations from OpenAPI server definitions.
OpenAPI Mocker includes two custom extensions for enhanced response generation: x-faker allows properties to use methods from the Faker library to generate randomized realistic data, with support for simple method calls, parametrized methods, and mustache templating; x-count lets array properties specify how many items to include in responses. The tool caches up to ten responses per endpoint to avoid regenerating fake data on repeated calls, and it binds to a configurable port. Authentication support is currently not implemented.