-
Notifications
You must be signed in to change notification settings - Fork 227
Description
Problem Description
When using openapi-to-postmanv2 with schemaFaker: false, the library still generates random property names and values for certain schema patterns, making the output non-deterministic across runs.
Expected Behavior
With schemaFaker: false, all generated examples should be deterministic and use schema placeholders like <string>, <number>, etc., without any random property names or values.
Actual Behavior
The library still generates random property names and values for schemas with additionalProperties and complex structures, even when schemaFaker: false is set.
Minimal Reproducible Example
OpenAPI Schema
openapi: 3.0.3
info:
title: Test API
version: 1.0.0
paths:
/test:
post:
requestBody:
content:
application/json:
schema:
type: object
properties:
publicKey:
type: object
additionalProperties:
type: string
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
properties:
data:
type: object
additionalProperties: trueTest Code
const { convert } = require('openapi-to-postmanv2');
const openapiSpec = {
// ... OpenAPI spec from above
};
// Convert with schemaFaker disabled
convert(
{ type: 'string', data: JSON.stringify(openapiSpec) },
{
schemaFaker: false,
exampleParametersResolution: 'Schema',
requestParametersResolution: 'Schema'
},
(err, result) => {
if (err) {
console.error(err);
return;
}
// Run this multiple times - you'll see different property names
console.log(JSON.stringify(result.collection, null, 2));
}
);Output Examples
Run 1:
{
"body": {
"mode": "raw",
"raw": "{\n \"publicKey\": {\n \"amet_04\": \"<string>\"\n }\n}"
}
}Run 2:
{
"body": {
"mode": "raw",
"raw": "{\n \"publicKey\": {\n \"sit_2\": \"<string>\"\n }\n}"
}
}Run 3:
{
"body": {
"mode": "raw",
"raw": "{\n \"publicKey\": {\n \"fugiatd5\": \"<string>\"\n }\n}"
}
}Root Cause
The issue occurs when schemas contain:
additionalProperties: trueoradditionalProperties: { type: "string" }- Complex
anyOf/oneOfstructures - Objects without explicit property definitions
Even with schemaFaker: false, the library generates random property names like "amet_04", "sit_2", "fugiatd5" for these schema patterns.
Impact
This makes it impossible to generate deterministic Postman collections, causing:
- Unnecessary git diffs on each generation
- Build instability in CI/CD pipelines
- Difficulty in version control tracking
Environment
openapi-to-postmanv2version: (latest)- Node.js version: (varies)
- Operating System: (any)
Suggested Fix
When schemaFaker: false is set, the library should:
- Use consistent placeholder property names for
additionalProperties(e.g.,"<property>": "<string>") - Avoid generating any random strings or property names
- Provide a deterministic fallback for all schema patterns
Workaround
Currently, there's no complete workaround. Users can post-process the generated collection to normalize property names, but this is complex and error-prone.