Prism

Hero image for Prism

When

An API mock server with Prism is best suited when the API is NOT being developed concurrently with the client applications. Prism is a best-in-class Mock Server and Validation Proxy for OpenAPI documents and Postman Collections. It provides:

  • Mock Servers: Life-like mock servers from any API specification document.
  • Validation Proxy: Contract Testing for API consumers and developers.
  • Comprehensive API Specification Support: OpenAPI v3.1, OpenAPI v3.0, OpenAPI v2.0 (formerly Swagger) and Postman Collections.

Prerequisites

Setting up a group email address (e.g., {project.name}@nimblehq.co) is preferred. Launching a small application is free at the beginning.
Otherwise, using the company account ([email protected]) is another option.

Instructions

Developers can use the api-mock-templates or web templates (e.g., rails-templates, elixir-templates, gin-templates) directly to create an API mock server or follow the steps below to create one from scratch:

  1. Create an OpenAPI specification file or generate one from Postman Collection.
  2. Create an API Mock Server with Prism.
  3. Deploy the mock server to a host server.
  4. Set up the Continuous Deployment with GitHub Actions.

Prism Usages

After setting up the mock server, the client side can call all APIs as usual with the mock server base URL.

One of Prism’s features is supporting different responses with an API:

  • With defined response examples, developers can call the API with the Prefer header example=name-of-example to get the expected response.

  • Dynamic response by specifying the Prefer header with the dynamic key set to true.

For instance, with the Nimble Survey API project, developers can call the API with:

  • The Prefer header example=bangkok to get the response with the bangkok example: Example Bangkok

  • The Prefer header example=riverside to get the response with the riverside example: Example Riverside

  • The Prefer header dynamic=true to get the dynamic response: Dynamic Response