How to create mock server from OpenAPI spec? (CDD)

Archived topic — some details may be out of date.
Mock servers built from saved collection examples are still supported. Postman now also has code-based mocks: JavaScript request handlers plus a config.yaml, stored as files in your Git repository, which you can run locally or deploy. Create one in the app, or use the Postman CLI to generate one from an OpenAPI spec, collection or dataset (postman mock generate) and run it (postman mock run). See About mocks and Create a mock.
Working with an AI coding agent? The Postman plugin can build and run mocks for you.
For current help, see the Postman docs, try the free Postman tools (no account needed), or join us on Discord.

TLDR:
Im able to import OpenAPI spec as API in Postman. Im able to generate mock server from collections. But i dont see a way to connect these two - create mock server from API spec like for example in SoapUI, ReadyAPI, Traffic Parrot etc do.

FULL:
Im testing various tools in context of CDD (Contract Driven Development). Thats a methodology when contract (api spec) is created/edited first, and then code (api server and api client) has to be adjusted to it. In this concept API client will not be developed and tested (CI phase) against real servers but mocked servers created from api spec.

If you’re using the latest version of Postman, you can copy the generated collection over to Collections, and then add a mock. It’s a bit different than earlier versions. In more detail:

  • Import the API spec with Collection
  • Under the collection (still under the APIs tab) > Copy to collections
  • Now you will see the collection under the Collections tab > Mock collection

There’s also a recent session on API contract testing that doesn’t address this particular workflow of CDD, but may give you some ideas: API Contract Testing | Postman Intergalactic