Postman Collection Format

Use your Postman Collections directly with moclojer. Import Collections v2.1, leverage response examples and create mocks without rewriting anything.

moclojer supports Postman Collection v2.1, allowing you to use your existing collections to generate mocks automatically. No need to rewrite anything!

What Are Postman Collections?

Postman Collections are JSON files that group HTTP requests, widely used for:

  • API documentation

  • API testing

  • Team sharing

  • Mock servers (like moclojer!)

Why Use Postman Collections?

βœ… Reusability: Use existing Postman collections βœ… Zero config: moclojer converts automatically βœ… Ready examples: Responses already documented βœ… Easy export: Direct export from Postman App βœ… Popular standard: Whole team already uses Postman


Support in moclojer

Supported Versions

  • βœ… Postman Collection v2.1 (recommended)

  • ⚠️ Postman Collection v2.0 (partial support)

Accepted Formats

  • βœ… JSON (.json)


Quick Start

1. Export from Postman

In Postman App:

  1. Open your Collection

  2. Click ... (three dots)

  3. Export β†’ Collection v2.1

  4. Save as postman_collection.json

2. Run with moclojer

3. Test

πŸŽ‰ It worked! Without writing YAML!


How moclojer Converts Postman Collections

Basic Structure

Postman Collection:

moclojer converts to:

Path Variables

Postman:

Converted to: /users/:id

Query Parameters

Postman:

moclojer accepts: /products?category=electronics&limit=10

Request Body

Postman:

moclojer uses the response example:


Complete Example

Postman Collection

Run

Test


Nested Folders

Postman Collections support nested folders:

moclojer processes recursively all folder levels.


Variables

Collection Variables

moclojer resolves variables automatically:

  • {{baseUrl}} β†’ ignores (uses moclojer host)

  • {{apiVersion}} β†’ /v1/users

Environment Variables

Postman Environments are not directly supported.

Workaround: Export collection with values already resolved:

  1. In Postman, select Environment

  2. Export Collection (values will be inline)


Headers

Request Headers

moclojer: Request headers are informational (not validated).

Response Headers

moclojer adds these headers to the response.


Multiple Responses (Examples)

Postman allows multiple examples per request:

moclojer uses the first example (usually 200 OK).

To simulate errors: Create separate requests


Scripts and Tests

Postman Collections can have Pre-request and Test scripts:

moclojer ignores scripts. They are for execution in Postman, not mock.


Authentication

Bearer Token

moclojer: Auth is informational (doesn't validate tokens).

API Key


Limitations and Workarounds

1. Multiple Responses

Limitation: moclojer uses only the first response.

Workaround: Create separate requests for each scenario:

2. Scripts Not Executed

Limitation: Pre-request and Test scripts are ignored.

Workaround: Use scripts only in Postman, not for mock logic.

3. Environment Variables

Limitation: Environments are not loaded.

Workaround: Export collection with inline values.

4. Request Validation

Limitation: moclojer does not validate if request body is correct.

Workaround: Use tools like Postman Runner or Newman for validation.


Postman vs Native YAML

Aspect
Postman Collection
moclojer YAML

Reusability

Existing collections

Need to create from scratch

Tools

Complete Postman App

Text editor

Verbosity

Verbose JSON

Concise YAML

Dynamic

Static examples

Dynamic templates

Learning curve

Higher (Postman)

Lower (YAML)

Sharing

Easy (workspace)

Git files

When to use Postman:

  • Already have ready collections

  • Team uses Postman daily

  • Want visual interface

  • Need rich documentation

When to use YAML:

  • Want dynamic templates ({{path-params.id}})

  • Need minimalist config

  • Version with Git

  • CI/CD automation


Converting Postman β†’ moclojer YAML

If you want to convert permanently:

Option 1: Manual

  1. Export Postman Collection

  2. Read JSON and rewrite in YAML

Option 2: Script (create one)


Best Practices

βœ… Do

  1. Use response examples

  2. Organize with folders

  3. Document requests

  4. Versioning in name

❌ Avoid

  1. Collections without examples

  2. Hardcoded absolute URLs

  3. Script dependency


Troubleshooting

"Invalid Postman Collection format"

Cause: Unsupported version or invalid JSON.

Solution:

"No responses found"

Cause: Requests without response examples.

Solution: Add examples in Postman:

  1. Make request in Postman

  2. Click "Save Response" β†’ "Save as Example"

  3. Re-export Collection

"Path variables not working"

Cause: Incorrect syntax.

Solution: Use :paramName in Postman


Next Steps

See Also

Last updated

Was this helpful?