@@ -7,6 +7,7 @@ import * as React from 'react';
77import { JSONSchema4 } from 'json-schema' ;
88import { SchemaTree } from '../tree/tree' ;
99import { GoToRefHandler , RowRenderer } from '../types' ;
10+ import { mergeAllOf } from '../utils' ;
1011import { isSchemaViewerEmpty } from '../utils/isSchemaViewerEmpty' ;
1112import { SchemaTree as SchemaTreeComponent } from './SchemaTree' ;
1213
@@ -35,7 +36,11 @@ export class JsonSchemaViewerComponent extends React.PureComponent<IJsonSchemaVi
3536 super ( props ) ;
3637
3738 this . treeState = new TreeState ( ) ;
38- this . tree = new SchemaTree ( this . schema , this . treeState , this . expandedDepth ) ;
39+ this . tree = new SchemaTree (
40+ props . mergeAllOf ? mergeAllOf ( props . schema ) : props . schema ,
41+ this . treeState ,
42+ this . expandedDepth ,
43+ ) ;
3944 this . treeStore = new TreeStore ( this . tree , this . treeState , {
4045 defaultExpandedDepth : this . expandedDepth ,
4146 } ) ;
@@ -53,10 +58,6 @@ export class JsonSchemaViewerComponent extends React.PureComponent<IJsonSchemaVi
5358 return 1 ;
5459 }
5560
56- protected get schema ( ) {
57- return this . props . schema ;
58- }
59-
6061 protected renderSchema ( ) {
6162 if ( this . tree . count > 1 ) {
6263 for ( const child of this . tree ) {
@@ -78,7 +79,7 @@ export class JsonSchemaViewerComponent extends React.PureComponent<IJsonSchemaVi
7879 this . tree . expandedDepth = this . expandedDepth ;
7980 this . renderSchema ( ) ;
8081 } else if ( prevProps . schema !== this . props . schema || prevProps . mergeAllOf !== this . props . mergeAllOf ) {
81- this . tree . schema = this . props . schema ;
82+ this . tree . schema = this . props . mergeAllOf ? mergeAllOf ( this . props . schema ) : this . props . schema ;
8283 this . renderSchema ( ) ;
8384 }
8485 }
0 commit comments