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:
Open your Collection
Click
...(three dots)Export β Collection v2.1
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:
In Postman, select Environment
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
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
Export Postman Collection
Read JSON and rewrite in YAML
Option 2: Script (create one)
Best Practices
β
Do
Use response examples
Organize with folders
Document requests
Versioning in name
β Avoid
Collections without examples
Hardcoded absolute URLs
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:
Make request in Postman
Click "Save Response" β "Save as Example"
Re-export Collection
"Path variables not working"
Cause: Incorrect syntax.
Solution: Use :paramName in Postman
Next Steps
OpenAPI Format - Import OpenAPI specs
YAML Format - Native moclojer syntax
Path Parameters - Dynamic parameters
Your First Mock - Initial tutorial
See Also
Configuration Spec - moclojer reference
Last updated
Was this helpful?