@@ -3,13 +3,14 @@ import { JsonPath, Optional } from '@stoplight/types';
33import { JSONSchema4 } from 'json-schema' ;
44import { isObject as _isObject } from 'lodash' ;
55import { IArrayNode , IObjectNode , SchemaKind , SchemaNode , SchemaTreeListNode } from '../../types' ;
6+ import { generateId } from '../../utils/generateId' ;
67import { getCombiner } from '../../utils/getCombiner' ;
78import { getPrimaryType } from '../../utils/getPrimaryType' ;
89import { isCombinerNode , isRefNode } from '../../utils/guards' ;
910import { getNodeMetadata , getSchemaNodeMetadata , metadataStore } from '../metadata' ;
1011import { createErrorTreeNode } from './createErrorTreeNode' ;
1112import { mergeAllOf } from './mergeAllOf' ;
12- import { walk } from './walk' ;
13+ import { processNode , walk } from './walk' ;
1314
1415export type WalkerRefResolver = ( path : JsonPath | null , $ref : string ) => JSONSchema4 ;
1516
@@ -245,7 +246,22 @@ function prepareSchema(
245246 try {
246247 return resolveSchema ( schema , path , options ) ;
247248 } catch ( ex ) {
248- ( node as TreeListParentNode ) . children = [ ] ;
249- return void ( node as TreeListParentNode ) . children . push ( createErrorTreeNode ( node as TreeListParentNode , ex . message ) ) ;
249+ const treeNode : SchemaTreeListNode = {
250+ id : generateId ( ) ,
251+ name : '' ,
252+ parent : node as TreeListParentNode ,
253+ children : [ ] ,
254+ } ;
255+
256+ ( node as TreeListParentNode ) . children . push ( treeNode ) ;
257+ metadataStore . set ( treeNode , {
258+ schemaNode : processNode ( schema || { } ) ,
259+ schema : schema || { } ,
260+ path,
261+ } ) ;
262+
263+ treeNode . children . push ( createErrorTreeNode ( treeNode , ex . message ) ) ;
264+
265+ return null ;
250266 }
251267}
0 commit comments