Skip to content

Commit 5cd19e9

Browse files
committed
Fix for TypeError: OPENAPI3.0: Cannot read properties of undefined (reading 'type')
1 parent 5210cd3 commit 5cd19e9

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

lib/schemaUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ module.exports = {
634634
Object.assign(specComponentsAndUtils, concreteUtils.getRequiredData(spec));
635635

636636
for (path in paths) {
637-
if (paths.hasOwnProperty(path)) {
637+
if (paths.hasOwnProperty(path) && (paths[path] !== undefined || paths[path] !== null)) {
638638
currentPathObject = paths[path];
639639

640640
// discard the leading slash, if it exists

lib/xmlSchemaFaker.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ function convertSchemaToXML(name, schema, attribute, indentChar, indent, resolve
1414
cIndent = _.times(indent, _.constant(indentChar)).join(''),
1515
retVal = '';
1616

17+
if (schema === null || typeof schema === 'undefined') {
18+
return retVal;
19+
}
20+
1721
const schemaExample = typeof schema === 'object' && (schema.example);
1822

1923
name = _.get(schema, 'xml.name', name || 'element');

libV2/xmlSchemaFaker.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ function convertSchemaToXML(name, schema, attribute, indentChar, indent, resolve
1414
cIndent = _.times(indent, _.constant(indentChar)).join(''),
1515
retVal = '';
1616

17+
if (schema === null || typeof schema === 'undefined') {
18+
return retVal;
19+
}
20+
1721
const schemaExample = typeof schema === 'object' && (schema.example);
1822

1923
name = _.get(schema, 'xml.name', name || 'element');

0 commit comments

Comments
 (0)