Skip to content

Commit 77bfe7e

Browse files
github-actions[bot]barshan23AyushShri
authored
Release version v5.4.1 (#905)
* fixed path para values in example req * fixed bug * removed comments and extra test * removed assertion * fixed tests * Refactor schema handling to preserve order of required properties (#903) * Refactor schema handling to preserve order of required properties and improve handling of schemas without required properties * Remove redundant comment about defaulting to empty required array in request body validation * Enhance schema processing in tests to ensure properties are preserved and required arrays are handled correctly * Prepare release v5.4.1 --------- Co-authored-by: Avishek Saha <[email protected]> Co-authored-by: Ayush Shrivastav <[email protected]>
1 parent 3044fb8 commit 77bfe7e

File tree

6 files changed

+262
-84
lines changed

6 files changed

+262
-84
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [Unreleased]
44

5+
## [v5.4.1] - 2025-11-17
6+
57
## [v5.4.0] - 2025-11-13
68

79
## [v5.3.5] - 2025-11-10
@@ -677,7 +679,9 @@ Newer releases follow the [Keep a Changelog](https://keepachangelog.com/en/1.0.0
677679

678680
- Base release
679681

680-
[Unreleased]: https://github.com/postmanlabs/openapi-to-postman/compare/v5.4.0...HEAD
682+
[Unreleased]: https://github.com/postmanlabs/openapi-to-postman/compare/v5.4.1...HEAD
683+
684+
[v5.4.1]: https://github.com/postmanlabs/openapi-to-postman/compare/v5.4.0...v5.4.1
681685

682686
[v5.4.0]: https://github.com/postmanlabs/openapi-to-postman/compare/v5.3.5...v5.4.0
683687

libV2/schemaUtils.js

Lines changed: 80 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -691,33 +691,37 @@ let QUERYPARAM = 'query',
691691
let resolvedSchemaProps = {},
692692
{ includeDeprecated } = context.computedOptions;
693693

694-
_.forOwn(schema.properties, (property, propertyName) => {
695-
// Skip property resolution if it's not schema object
696-
if (!_.isObject(property)) {
697-
return;
698-
}
694+
// Only process properties if the schema has a properties field
695+
if (schema.hasOwnProperty('properties')) {
696+
_.forOwn(schema.properties, (property, propertyName) => {
697+
// Skip property resolution if it's not schema object
698+
if (!_.isObject(property)) {
699+
return;
700+
}
699701

700-
if (
701-
property.format === 'decimal' ||
702-
property.format === 'byte' ||
703-
property.format === 'password' ||
704-
property.format === 'unix-time'
705-
) {
706-
delete property.format;
707-
}
702+
if (
703+
property.format === 'decimal' ||
704+
property.format === 'byte' ||
705+
property.format === 'password' ||
706+
property.format === 'unix-time'
707+
) {
708+
delete property.format;
709+
}
708710

709-
// Skip addition of deprecated properties based on provided options
710-
if (!includeDeprecated && property.deprecated) {
711-
return;
712-
}
711+
// Skip addition of deprecated properties based on provided options
712+
if (!includeDeprecated && property.deprecated) {
713+
return;
714+
}
713715

714-
const currentPropPath = utils.addToJsonPath(currentPath, ['properties', propertyName]);
716+
const currentPropPath = utils.addToJsonPath(currentPath, ['properties', propertyName]);
715717

716-
resolvedSchemaProps[propertyName] = _resolveSchema(context, property, stack, resolveFor,
717-
_.cloneDeep(seenRef), currentPropPath);
718-
});
718+
resolvedSchemaProps[propertyName] = _resolveSchema(context, property, stack, resolveFor,
719+
_.cloneDeep(seenRef), currentPropPath);
720+
});
719721

720-
schema.properties = resolvedSchemaProps;
722+
schema.properties = resolvedSchemaProps;
723+
}
724+
721725
schema.type = schema.type || SCHEMA_TYPES.object;
722726
}
723727
// If schema is of type array
@@ -827,73 +831,70 @@ let QUERYPARAM = 'query',
827831
};
828832
}
829833

830-
if (resolvedSchema.type === 'object' && resolvedSchema.properties) {
834+
if (resolvedSchema.type === 'object') {
831835
const schemaDetails = {
832836
description: resolvedSchema.description,
833837
title: resolvedSchema.title,
834-
type: resolvedSchema.type,
835-
properties: {},
836-
required: []
837-
},
838-
requiredProperties = new Set(resolvedSchema.required || []);
839-
840-
for (let [propName, propValue] of Object.entries(resolvedSchema.properties)) {
841-
if (!propValue.type && !propValue.anyOf && !propValue.oneOf && !propValue.allOf) {
842-
continue;
843-
}
844-
const propertyDetails = {
845-
type: propValue.type,
846-
deprecated: propValue.deprecated,
847-
enum: propValue.enum || undefined,
848-
minLength: propValue.minLength,
849-
maxLength: propValue.maxLength,
850-
minimum: propValue.minimum,
851-
maximum: propValue.maximum,
852-
pattern: propValue.pattern,
853-
example: propValue.example,
854-
title: propValue.title,
855-
description: propValue.description,
856-
format: propValue.format
838+
type: resolvedSchema.type
857839
};
858840

859-
if (requiredProperties.has(propName)) {
860-
schemaDetails.required.push(propName);
861-
}
841+
// Only include properties if they exist in the original schema
842+
if (resolvedSchema.hasOwnProperty('properties')) {
843+
schemaDetails.properties = {};
862844

863-
if (propValue.anyOf) {
864-
propertyDetails.anyOf = propValue.anyOf.map((schema) => {
865-
return processSchema(schema);
866-
});
867-
}
868-
else if (propValue.oneOf) {
869-
propertyDetails.oneOf = propValue.oneOf.map((schema) => {
870-
return processSchema(schema);
871-
});
872-
}
873-
else if (propValue.allOf) {
874-
propertyDetails.allOf = propValue.allOf.map((schema) => {
875-
return processSchema(schema);
876-
});
877-
}
878-
else if (propValue.properties) {
879-
let processedProperties = processSchema(propValue);
880-
propertyDetails.properties = processedProperties.properties;
881-
if (processedProperties.required) {
882-
propertyDetails.required = processedProperties.required;
845+
for (let [propName, propValue] of Object.entries(resolvedSchema.properties)) {
846+
if (!propValue.type && !propValue.anyOf && !propValue.oneOf && !propValue.allOf) {
847+
continue;
883848
}
884-
}
885-
else if (propValue.type === 'array' && propValue.items) {
886-
propertyDetails.items = processSchema(propValue.items);
887-
}
849+
const propertyDetails = {
850+
type: propValue.type,
851+
deprecated: propValue.deprecated,
852+
enum: propValue.enum || undefined,
853+
minLength: propValue.minLength,
854+
maxLength: propValue.maxLength,
855+
minimum: propValue.minimum,
856+
maximum: propValue.maximum,
857+
pattern: propValue.pattern,
858+
example: propValue.example,
859+
title: propValue.title,
860+
description: propValue.description,
861+
format: propValue.format
862+
};
888863

889-
schemaDetails.properties[propName] = propertyDetails;
890-
}
891-
if (schemaDetails.required && schemaDetails.required.length === 0) {
892-
schemaDetails.required = undefined;
864+
if (propValue.anyOf) {
865+
propertyDetails.anyOf = propValue.anyOf.map((schema) => {
866+
return processSchema(schema);
867+
});
868+
}
869+
else if (propValue.oneOf) {
870+
propertyDetails.oneOf = propValue.oneOf.map((schema) => {
871+
return processSchema(schema);
872+
});
873+
}
874+
else if (propValue.allOf) {
875+
propertyDetails.allOf = propValue.allOf.map((schema) => {
876+
return processSchema(schema);
877+
});
878+
}
879+
else if (propValue.properties) {
880+
let processedProperties = processSchema(propValue);
881+
propertyDetails.properties = processedProperties.properties;
882+
if (processedProperties.required) {
883+
propertyDetails.required = processedProperties.required;
884+
}
885+
}
886+
else if (propValue.type === 'array' && propValue.items) {
887+
propertyDetails.items = processSchema(propValue.items);
888+
}
889+
890+
schemaDetails.properties[propName] = propertyDetails;
891+
}
893892
}
894-
if (schemaDetails.properties && Object.keys(schemaDetails.properties).length === 0) {
895-
schemaDetails.properties = undefined;
893+
894+
if (resolvedSchema.required) {
895+
schemaDetails.required = resolvedSchema.required;
896896
}
897+
897898
return schemaDetails;
898899
}
899900
else if (resolvedSchema.type === 'array' && resolvedSchema.items) {

libV2/utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const _ = require('lodash'),
1414
url: requestItem.request.url
1515
},
1616
originalRequestQueryParams = _.get(response, 'originalRequest.params.queryParams',
17-
_.get(response, 'originalRequest.url.query', []));
17+
_.get(response, 'originalRequest.url.query', [])),
18+
originalRequestPathParams = _.get(response, 'originalRequest.params.pathParams',
19+
_.get(requestItem, 'request.url.variables.members', []));
1820

1921
/**
2022
* Setting variable
@@ -38,6 +40,7 @@ const _ = require('lodash'),
3840

3941
// Assimilate original query params as SDK doesn't handle query params well.
4042
sdkResponse.originalRequest.url.query.assimilate(originalRequestQueryParams);
43+
sdkResponse.originalRequest.url.variables.assimilate(originalRequestPathParams);
4144

4245
/**
4346
* Adding it here because sdk converts

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openapi-to-postmanv2",
3-
"version": "5.4.0",
3+
"version": "5.4.1",
44
"description": "Convert a given OpenAPI specification to Postman Collection v2.0",
55
"homepage": "https://github.com/postmanlabs/openapi-to-postman",
66
"bugs": "https://github.com/postmanlabs/openapi-to-postman/issues",

0 commit comments

Comments
 (0)