Skip to content

Create mocks servers with its schemas from OpenAPI 3.0.0 spec files

License

Notifications You must be signed in to change notification settings

sngular/api-mock-runner

Repository files navigation

Welcome to api-mock-runner 👋

Run multiple mock servers from one or more OpenAPI Specification.

Schemas can be provided from a remote origin (https:// or git@) or a local path.

Remote and circular references are allowed.

📘 Usage

You can use api-mock-runner in a three different ways. All of them starts a CLI guided journey:

1. NPX (No installation needed)

npx @sngular/api-mock-runner

2. Globally

sudo npm install --global @sngular/api-mock-runner

To use: type api-mock-runner in the terminal.

3. Current project dev dependency

npm i --save-dev @sngular/api-mock-runner

Manual options

You could avoid CLI interaction by using api-mock-runner with flags. To explore manual options, use -h flag:

npx @sngular/api-mock-runner -h
Usage: api-mock-runner [options]

Options:
  -o, --origin <origin>          path or repo containing schemas
  -s, --schema [schemaPaths...]  path to schemas
  -p, --port [ports...]          port to serve each schema
  -r, --run-config               use saved config
  -h, --help                     display help for command

Response selection

The application will return the first response found in the schema by default. To use another existing response, use prefer header with the content statusCode=XXX in the request.

prefer: statusCode=500

Architectural Decision Record (ADR)

Here you can find architectural decisions records

❤️ Special thanks

We would like to express our special thanks to open-api-mocker, which is used to set up a mock server.