Class PostmanCollectionImporter

java.lang.Object
org.mockserver.imports.PostmanCollectionImporter

public class PostmanCollectionImporter extends Object
Imports expectations from Postman Collection v2.x (v2.0 and v2.1) JSON files.

Walks the item[] array recursively (folders contain nested item[]). For each request that has saved example responses (response[]), one expectation is created per example. Requests without saved examples are skipped with a logged count.

Handles Postman url being either a plain string or an object with raw, path[], and query[].

  • Constructor Details

    • PostmanCollectionImporter

      public PostmanCollectionImporter()
  • Method Details

    • importExpectations

      public List<Expectation> importExpectations(String collectionJson)
      Parses a Postman Collection v2.x JSON string and returns one expectation per saved example response.
      Parameters:
      collectionJson - the Postman collection as a JSON string
      Returns:
      the generated expectations (may be empty if no examples are present)
      Throws:
      IllegalArgumentException - if the JSON is null, blank, or not a valid Postman collection