Prism

Command-line HTTP server that mocks APIs from OpenAPI v2/v3.x and Postman Collections, and proxies traffic to validate it against the spec.

installยท npm

Prism is an open-source, command-line HTTP server for API mocking and contract testing. It reads an API description document (OpenAPI v2.0, formerly Swagger, OpenAPI v3.0, OpenAPI v3.1, or a Postman Collection) and serves HTTP responses based on it. It also provides request validation and content negotiation, and can run standalone or in continuous integration.

The prism mock command starts a mock server from a local file or a URL, for example prism mock https://raw.githack.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml. This lets API consumers call an API before a backend exists. The prism proxy command runs in front of a real service, for example prism proxy examples/petstore.oas2.yaml https://petstore.swagger.io/v2. It forwards HTTP traffic and reports discrepancies between the implementation and the OpenAPI document, which supports contract testing.

Some behaviors are documented in the FAQ. Prism listens on localhost by default, so inside Docker you need -h 0.0.0.0 to reach the mock server from outside the container. Prism v3 treats OAS2 host + basePath the same as OAS3 server.url, so the base path is not included in request URLs. Prism requires Node.js 18.20.1 or later. It is aimed at API developers, front-end and integration developers consuming an API, and teams adding contract checks to CI.

Installation

# via npm
npm install -g @stoplight/prism-cli

Alternatives & related tools

add a badge to your README

Maintain Prism? Show that it's featured on trmn. The badge links back to this page.

Featured on trmn
Markdown
[![Featured on trmn](https://www.trmn.sh/badge/prism.svg)](https://www.trmn.sh/tools/prism?utm_source=badge)
HTML
<a href="https://www.trmn.sh/tools/prism?utm_source=badge"><img src="https://www.trmn.sh/badge/prism.svg" alt="Featured on trmn" height="20"></a>