@@ -2,6 +2,7 @@ import { isLocalRef } from '@stoplight/json';
22import { TreeListNode , TreeListParentNode } from '@stoplight/tree-list' ;
33import { JsonPath } from '@stoplight/types' ;
44import { JSONSchema4 } from 'json-schema' ;
5+ import { isObject as _isObject } from 'lodash-es' ;
56import { IArrayNode , IObjectNode , SchemaKind , SchemaNode , SchemaTreeListNode } from '../types' ;
67import { mergeAllOf } from '../utils' ;
78import { getPrimaryType } from '../utils/getPrimaryType' ;
@@ -56,7 +57,7 @@ export const populateTree: Walker = (schema, parent, level, path, options): unde
5657 } else if ( node . combiner === 'allOf' && options ?. mergeAllOf ) {
5758 parent . children . pop ( ) ;
5859 populateTree ( mergeAllOf ( schema ) , parent , level , path , options ) ;
59- } else if ( node . properties !== void 0 ) {
60+ } else if ( _isObject ( node . properties ) ) {
6061 ( treeNode as TreeListParentNode ) . children = [ ] ;
6162
6263 for ( const [ i , property ] of node . properties . entries ( ) ) {
@@ -97,7 +98,7 @@ function processArray(
9798 children . push ( child ) ;
9899 }
99100 }
100- } else if ( schema . items !== void 0 ) {
101+ } else if ( _isObject ( schema . items ) ) {
101102 const subtype = getPrimaryType ( schema . items ) ;
102103 switch ( subtype ) {
103104 case SchemaKind . Object :
@@ -123,7 +124,7 @@ function processObject(
123124) : TreeListNode {
124125 const children : TreeListNode [ ] = [ ] ;
125126
126- if ( schema . properties !== void 0 ) {
127+ if ( _isObject ( schema . properties ) ) {
127128 ( node as TreeListParentNode ) . children = children ;
128129
129130 for ( const [ prop , property ] of Object . entries ( schema . properties ) ) {
@@ -140,7 +141,7 @@ function processObject(
140141 }
141142 }
142143
143- if ( schema . patternProperties !== void 0 ) {
144+ if ( _isObject ( schema . patternProperties ) ) {
144145 ( node as TreeListParentNode ) . children = children ;
145146
146147 for ( const [ prop , property ] of Object . entries ( schema . patternProperties ) ) {
0 commit comments