@@ -218,7 +218,12 @@ function getBlankObject(schema, getRef) {
218218 let value = schema_keys [ key ] ;
219219 let isRef = value . hasOwnProperty ( '$ref' ) ;
220220 let isConst = value . hasOwnProperty ( 'const' ) ;
221- if ( isRef ) value = getRef ( value [ '$ref' ] ) ;
221+
222+ if ( isRef ) {
223+ value = _extends ( { } , getRef ( value [ '$ref' ] ) , value ) ;
224+ delete value [ '$ref' ] ;
225+ }
226+
222227 let type = normalizeKeyword ( value . type ) ;
223228
224229 if ( ! type ) {
@@ -258,7 +263,8 @@ function getBlankArray(schema, getRef) {
258263 if ( schema . items . hasOwnProperty ( '$ref' ) ) {
259264 // :TODO: this mutates the original schema
260265 // but i'll fix it later
261- schema . items = getRef ( schema . items [ '$ref' ] ) ;
266+ schema . items = _extends ( { } , getRef ( schema . items [ '$ref' ] ) , schema . items ) ;
267+ delete schema . items [ '$ref' ] ;
262268 }
263269
264270 let type = normalizeKeyword ( schema . items . type ) ;
@@ -317,7 +323,11 @@ function getBlankAnyOf(schema, getRef) {
317323 return getBlankData ( nextSchema , getRef ) ;
318324}
319325function getBlankData ( schema , getRef ) {
320- if ( schema . hasOwnProperty ( '$ref' ) ) schema = getRef ( schema [ '$ref' ] ) ;
326+ if ( schema . hasOwnProperty ( '$ref' ) ) {
327+ schema = _extends ( { } , getRef ( schema [ '$ref' ] ) , schema ) ;
328+ delete schema [ '$ref' ] ;
329+ }
330+
321331 let type = getSchemaType ( schema ) ;
322332 let default_ = schema . default ;
323333
@@ -338,7 +348,8 @@ function getSyncedArray(data, schema, getRef) {
338348 if ( schema . items . hasOwnProperty ( '$ref' ) ) {
339349 // :TODO: this will most probably mutate the original schema
340350 // but i'll fix it later
341- schema . items = getRef ( schema . items [ '$ref' ] ) ;
351+ schema . items = _extends ( { } , getRef ( schema . items [ '$ref' ] ) , schema . items ) ;
352+ delete schema . items [ '$ref' ] ;
342353 }
343354
344355 let type ;
@@ -400,7 +411,12 @@ function getSyncedObject(data, schema, getRef) {
400411 let key = keys [ i ] ;
401412 let schemaValue = schema_keys [ key ] ;
402413 let isRef = schemaValue . hasOwnProperty ( '$ref' ) ;
403- if ( isRef ) schemaValue = getRef ( schemaValue [ '$ref' ] ) ;
414+
415+ if ( isRef ) {
416+ schemaValue = _extends ( { } , getRef ( schemaValue [ '$ref' ] ) , schemaValue ) ;
417+ delete schemaValue [ '$ref' ] ;
418+ }
419+
404420 let type ;
405421 let default_ ;
406422
@@ -454,7 +470,11 @@ function getSyncedAnyOf(data, schema, getRef) {
454470}
455471function getSyncedData ( data , schema , getRef ) {
456472 // adds those keys to data which are in schema but not in data
457- if ( schema . hasOwnProperty ( '$ref' ) ) schema = getRef ( schema [ '$ref' ] ) ;
473+ if ( schema . hasOwnProperty ( '$ref' ) ) {
474+ schema = _extends ( { } , getRef ( schema [ '$ref' ] ) , schema ) ;
475+ delete schema [ '$ref' ] ;
476+ }
477+
458478 let type = getSchemaType ( schema ) ;
459479 let syncFunc = getSyncFunc ( type ) ;
460480 if ( syncFunc ) return syncFunc ( data , schema , getRef ) ;
@@ -473,7 +493,12 @@ function findMatchingSubschemaIndex(data, schema, getRef, schemaName) {
473493
474494 for ( let i = 0 ; i < subschemas . length ; i ++ ) {
475495 let subschema = subschemas [ i ] ;
476- if ( subschema . hasOwnProperty ( '$ref' ) ) subschema = getRef ( subschema [ '$ref' ] ) ;
496+
497+ if ( subschema . hasOwnProperty ( '$ref' ) ) {
498+ subschema = _extends ( { } , getRef ( subschema [ '$ref' ] ) , subschema ) ;
499+ delete subschema [ '$ref' ] ;
500+ }
501+
477502 let subType = getSchemaType ( subschema ) ;
478503
479504 if ( dataType === 'object' ) {
@@ -499,7 +524,12 @@ function findMatchingSubschemaIndex(data, schema, getRef, schemaName) {
499524 // so we'll just return the first schema that matches the data type
500525 for ( let i = 0 ; i < subschemas . length ; i ++ ) {
501526 let subschema = subschemas [ i ] ;
502- if ( subschema . hasOwnProperty ( '$ref' ) ) subschema = getRef ( subschema [ '$ref' ] ) ;
527+
528+ if ( subschema . hasOwnProperty ( '$ref' ) ) {
529+ subschema = _extends ( { } , getRef ( subschema [ '$ref' ] ) , subschema ) ;
530+ delete subschema [ '$ref' ] ;
531+ }
532+
503533 let subType = getSchemaType ( subschema ) ;
504534
505535 if ( dataType === subType ) {
@@ -2730,7 +2760,12 @@ function getArrayFormRow(args) {
27302760 let max_items = getKeyword ( schema , 'max_items' , 'maxItems' ) || 100 ;
27312761 if ( data . length >= max_items || isReadonly ) addable = false ;
27322762 let isRef = schema . items . hasOwnProperty ( '$ref' ) ;
2733- if ( isRef ) schema . items = args . getRef ( schema . items [ '$ref' ] ) ;
2763+
2764+ if ( isRef ) {
2765+ schema . items = _extends ( { } , args . getRef ( schema . items [ '$ref' ] ) , schema . items ) ;
2766+ delete schema . items [ '$ref' ] ;
2767+ }
2768+
27342769 let type = normalizeKeyword ( schema . items . type ) ;
27352770 let nextArgs = {
27362771 schema : schema . items ,
@@ -2895,7 +2930,12 @@ function getObjectFormRow(args) {
28952930 }
28962931
28972932 let isRef = schemaValue . hasOwnProperty ( '$ref' ) ;
2898- if ( isRef ) schemaValue = args . getRef ( schemaValue [ '$ref' ] ) ;
2933+
2934+ if ( isRef ) {
2935+ schemaValue = _extends ( { } , args . getRef ( schemaValue [ '$ref' ] ) , schemaValue ) ;
2936+ delete schemaValue [ '$ref' ] ;
2937+ }
2938+
28992939 if ( isReadonly ) schemaValue . readOnly = true ;
29002940 let type = normalizeKeyword ( schemaValue . type ) ;
29012941
@@ -3049,7 +3089,14 @@ class OneOfTopLevel extends React__default["default"].Component {
30493089 if ( index === undefined ) index = this . state . option ;
30503090 let schema = this . props . args . schema [ this . schemaName ] [ index ] ;
30513091 let isRef = schema . hasOwnProperty ( '$ref' ) ;
3052- if ( isRef ) schema = this . props . args . getRef ( schema [ '$ref' ] ) ;
3092+
3093+ if ( isRef ) {
3094+ schema = _extends ( { } , this . props . args . getRef ( schema [ '$ref' ] ) , {
3095+ schema
3096+ } ) ;
3097+ delete schema [ '$ref' ] ;
3098+ }
3099+
30533100 return schema ;
30543101 } ;
30553102
@@ -3136,7 +3183,12 @@ class OneOf extends React__default["default"].Component {
31363183 for ( let i = 0 ; i < subschemas . length ; i ++ ) {
31373184 let subschema = subschemas [ i ] ;
31383185 let isRef = subschema . hasOwnProperty ( '$ref' ) ;
3139- if ( isRef ) subschema = this . props . parentArgs . getRef ( subschema [ '$ref' ] ) ;
3186+
3187+ if ( isRef ) {
3188+ subschema = _extends ( { } , this . props . parentArgs . getRef ( subschema [ '$ref' ] ) , subschema ) ;
3189+ delete subschema [ '$ref' ] ;
3190+ }
3191+
31403192 let subType = getSchemaType ( subschema ) ;
31413193
31423194 if ( subschema . hasOwnProperty ( 'const' ) ) {
@@ -3256,7 +3308,12 @@ class OneOf extends React__default["default"].Component {
32563308 }
32573309
32583310 let isRef = schema . hasOwnProperty ( '$ref' ) ;
3259- if ( isRef ) schema = this . props . parentArgs . getRef ( schema [ '$ref' ] ) ;
3311+
3312+ if ( isRef ) {
3313+ schema = _extends ( { } , this . props . parentArgs . getRef ( schema [ '$ref' ] ) , schema ) ;
3314+ delete schema [ '$ref' ] ;
3315+ }
3316+
32603317 return schema ;
32613318 } ;
32623319
@@ -3431,6 +3488,10 @@ function validateSchema(schema) {
34313488 validation = validateOneOf ( schema ) ;
34323489 } else if ( schema . hasOwnProperty ( 'anyOf' ) ) {
34333490 validation = validateAnyOf ( schema ) ;
3491+ } else if ( schema . hasOwnProperty ( '$ref' ) ) {
3492+ validation = {
3493+ isValid : true
3494+ } ;
34343495 } else {
34353496 validation = {
34363497 isValid : false ,
@@ -3797,6 +3858,12 @@ class ReactJSONForm extends React__default["default"].Component {
37973858 let data = this . props . editorState . getData ( ) ;
37983859 let schema = this . props . editorState . getSchema ( ) ;
37993860 let formGroups = [ ] ;
3861+
3862+ if ( schema . hasOwnProperty ( '$ref' ) ) {
3863+ schema = _extends ( { } , this . getRef ( schema [ '$ref' ] ) , schema ) ;
3864+ delete schema [ '$ref' ] ;
3865+ }
3866+
38003867 let type = getSchemaType ( schema ) ;
38013868 let args = {
38023869 data : data ,
0 commit comments