liveBook · Manning

Prism

As explained in Automating API Delivery

Prism is an open-source proxy and mock server for validating and simulating APIs described by OpenAPI definitions or Postman collections.

Prism is a validating proxy and mock server for OpenAPI definitions and Postman collections. Place it between an end-to-end test and an API gateway so responses are checked against the API definition before the test evaluates them. section 7.5 section 7.0

A practical conformance workflow is:

  • Start an end-to-end test against the API gateway and log the response body. section 7.5
  • Start Prism with the OpenAPI definition, the gateway URL, and the --errors flag; Prism runs on port 4010 by default. section 7.5
  • Change the test base URI from the gateway at port 8000 to Prism at port 4010. section 7.5
  • Use the failure response and Prism logs to locate the schema violation and decide whether the definition or implementation should change. section 7.5

Detecting undocumented response fields

A Product Catalog API returns HTTP 200, but its response includes reviewRating and numberOfReviews that are absent from the OpenAPI definition. With --errors enabled, Prism returns HTTP 500 using RFC7807 Problem Details, identifies a VIOLATION, and reports additionalProperties errors at response.body. The test therefore fails even though the gateway itself returned 200.

How Automating API Delivery covers it

How deep it goes
Walks through proxy startup, test rerouting, error interpretation, and logs, but does not detail Prism internals.
Examples
Demonstrates a Product Catalog response whose undocumented reviewRating and numberOfReviews fields trigger validation errors.
What it assumes
Assumes an OpenAPI definition, an API gateway, an existing end-to-end test, and installed tooling; Java knowledge is needed to write the tests.
What you can do after
Apply it via Prism to diagnose API-definition mismatches inside an end-to-end test pipeline.
How it connects
Connects OpenAPI, Postman collections, schema testing, end-to-end testing, API gateways, contract testing, and RFC7807 Problem Details.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Automating API Delivery. The section links point to the parts of the book it draws on.