Skip to content

Commit 9bd5034

Browse files
author
Vishal Shingala
committed
Merge branch 'release/4.1.1'
2 parents b032215 + 0ec700e commit 9bd5034

File tree

8 files changed

+31
-22
lines changed

8 files changed

+31
-22
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# OpenAPI-Postman Changelog
22

3+
#### v4.1.1 (July 29, 2022)
4+
* Replaced Object.hasOwnProperty usages with loadsh _.has for safe access.
5+
36
#### v4.1.0 (July 20, 2022)
47
* Fixed issue where conversion was failing for definitions with info object as null.
58
* Fixed issue where generated collection did not have correct examples value from XML type of content.

lib/30XUtils/inputValidation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = {
3636
};
3737
}
3838

39-
if (!spec.info.hasOwnProperty('$ref')) {
39+
if (!_.has(spec.info, '$ref')) {
4040
if (_.isNil(_.get(spec, 'info.title'))) {
4141
return {
4242
result: false,

lib/31XUtils/inputValidation31X.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = {
3131
};
3232
}
3333

34-
if (!spec.info.hasOwnProperty('$ref')) {
34+
if (!_.has(spec.info, '$ref')) {
3535
if (_.isNil(_.get(spec, 'info.title'))) {
3636
return {
3737
result: false,

lib/31XUtils/schemaUtils31X.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ module.exports = {
9898
*/
9999
fixExamplesByVersion(schema) {
100100
// This method could be removed when schema faker gets upgraded
101-
const hasExamplesInRoot = schema.hasOwnProperty('examples'),
102-
hasChildItems = schema.hasOwnProperty('type') &&
103-
schema.hasOwnProperty('items'),
104-
hasProperties = schema.hasOwnProperty('properties'),
105-
typeIsAnArray = schema.hasOwnProperty('type') &&
101+
const hasExamplesInRoot = _.has(schema, 'examples'),
102+
hasChildItems = _.has(schema, 'type') &&
103+
_.has(schema, 'items'),
104+
hasProperties = _.has(schema, 'properties'),
105+
typeIsAnArray = _.has(schema, 'type') &&
106106
Array.isArray(schema.type);
107107

108108
if (hasExamplesInRoot && typeIsAnArray) {
@@ -153,11 +153,14 @@ module.exports = {
153153
addOuterPropsToRefSchemaIfIsSupported(refSchema, outerProps) {
154154
const resolvedSchema = _.cloneDeep(refSchema),
155155
outerKeys = Object.keys(outerProps);
156-
outerKeys.forEach((key) => {
157-
resolvedSchema[key] = (resolvedSchema[key] && Array.isArray(resolvedSchema[key])) ?
158-
[...new Set([...resolvedSchema[key], ...outerProps[key]])] :
159-
outerProps[key];
160-
});
156+
157+
if (_.isObject(resolvedSchema) && _.isObject(outerProps)) {
158+
outerKeys.forEach((key) => {
159+
resolvedSchema[key] = (resolvedSchema[key] && Array.isArray(resolvedSchema[key])) ?
160+
[...new Set([...resolvedSchema[key], ...outerProps[key]])] :
161+
outerProps[key];
162+
});
163+
}
161164
return resolvedSchema;
162165
}
163166
};

lib/common/schemaUtilsCommon.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ function checkValueEqualsDefault(value, definedDefault) {
170170
* @returns {Boolean} the value is the representation of its type
171171
*/
172172
function isTypeValue(value, schema) {
173+
if (!_.isObject(schema)) {
174+
return false;
175+
}
173176
if (schema.hasOwnProperty('type') && schema.hasOwnProperty('default')) {
174177
const isDefault = checkValueEqualsDefault(value, schema.default);
175178
if (isDefault) {
@@ -194,7 +197,7 @@ function isTypeValue(value, schema) {
194197
* @returns {Boolean} the value is the representation of its type
195198
*/
196199
function checkIsCorrectType(value, schema) {
197-
if (schema.hasOwnProperty('type') &&
200+
if (_.has(schema, 'type') &&
198201
typeof schemaTypeToJsValidator[schema.type] === 'function') {
199202
const isCorrectType = schemaTypeToJsValidator[schema.type](value);
200203
if (isCorrectType) {
@@ -272,10 +275,10 @@ module.exports = {
272275
},
273276

274277
handleExclusiveMaximum: function(schema, max) {
275-
max = schema.hasOwnProperty('maximum') ?
278+
max = _.has(schema, 'maximum') ?
276279
schema.maximum :
277280
max;
278-
if (schema.hasOwnProperty('exclusiveMaximum')) {
281+
if (_.has(schema, 'exclusiveMaximum')) {
279282
if (typeof schema.exclusiveMaximum === 'boolean') {
280283
return schema.multipleOf ?
281284
max - schema.multipleOf :
@@ -291,10 +294,10 @@ module.exports = {
291294
},
292295

293296
handleExclusiveMinimum: function(schema, min) {
294-
min = schema.hasOwnProperty('minimum') ?
297+
min = _.has(schema, 'minimum') ?
295298
schema.minimum :
296299
min;
297-
if (schema.hasOwnProperty('exclusiveMinimum')) {
300+
if (_.has(schema, 'exclusiveMinimum')) {
298301
if (typeof schema.exclusiveMinimum === 'boolean') {
299302
return schema.multipleOf ?
300303
min + schema.multipleOf :
@@ -349,7 +352,7 @@ module.exports = {
349352

350353
getServersPathVars: function(servers) {
351354
return servers.reduce((acc, current) => {
352-
const newVarNames = current.hasOwnProperty('variables') ?
355+
const newVarNames = _.has(current, 'variables') ?
353356
Object.keys(current.variables).filter((varName) => {
354357
return !acc.includes(varName);
355358
}) :

lib/common/versionUtils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ function getFileByFileNameSpecificVersion(data, specificationVersion) {
143143
function getFileWithVersion(data, specificationVersion) {
144144
let file;
145145

146-
if (data[0].hasOwnProperty('content')) {
146+
if (_.has(data[0], 'content')) {
147147
if (specificationVersion) {
148148
file = getFileByContentSpecificationVersion(data, specificationVersion);
149149
}
150150
else {
151151
file = getFileByContent(data);
152152
}
153153
}
154-
else if (data[0].hasOwnProperty('fileName')) {
154+
else if (_.has(data[0], 'fileName')) {
155155
if (specificationVersion) {
156156
file = getFileByFileNameSpecificVersion(data, specificationVersion);
157157
}

package-lock.json

Lines changed: 1 addition & 1 deletion
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": "4.1.0",
3+
"version": "4.1.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)