@@ -345,13 +345,23 @@ if (typeof brutusin === "undefined") {
345345 appendChild ( input , noption , s ) ;
346346 for ( var i = 0 ; i < s . oneOf . length ; i ++ ) {
347347 var option = document . createElement ( "option" ) ;
348- var propId = id + "." + i ;
348+ var propId = schemaId + "." + i ;
349349 var ss = getSchema ( propId ) ;
350- //console.log(s,i,id,ss);
350+ //console.log(s,i,id,ss,schemaMap,propId );
351351 var textNode = document . createTextNode ( ss . title ) ;
352352 option . value = s . oneOf [ i ] ;
353353 appendChild ( option , textNode , s ) ;
354354 appendChild ( input , option , s ) ;
355+ if ( value . hasOwnProperty ( "type" ) ) {
356+ if ( ss . hasOwnProperty ( "properties" ) ) {
357+ if ( ss . properties . hasOwnProperty ( "type" ) ) {
358+ var tryit = getSchema ( ss . properties . type ) ;
359+ if ( value . type == tryit . enum [ 0 ] ) {
360+ input . selectedIndex = i + 1 ;
361+ render ( null , display , id + "." + ( input . selectedIndex - 1 ) , parentObject , propertyProvider , value ) ; }
362+ }
363+ }
364+ }
355365 }
356366 input . onchange = function ( ) {
357367 render ( null , display , id + "." + ( input . selectedIndex - 1 ) , parentObject , propertyProvider , value ) ;
@@ -762,6 +772,12 @@ if (typeof brutusin === "undefined") {
762772 }
763773 return pseudoSchema ;
764774 }
775+ function getDefinition ( path ) {
776+ // Translate the path to schema standard.
777+ // $/definitions/ from #/definitions/
778+ // fetch that schema.
779+
780+ }
765781
766782 function populateSchemaMap ( name , schema ) {
767783 var pseudoSchema = createPseudoSchema ( schema ) ;
@@ -771,18 +787,22 @@ if (typeof brutusin === "undefined") {
771787 pseudoSchema . oneOf = new Array ( ) ;
772788 pseudoSchema . type = "oneOf" ;
773789 for ( var i in schema . oneOf ) {
774- // console.log(schema.oneOf[i]);
790+ console . log ( "ONEOF" , name , schema . oneOf [ i ] ) ;
775791 var childProp = name + "." + i ;
776792 pseudoSchema . oneOf [ i ] = childProp ;
777793 populateSchemaMap ( childProp , schema . oneOf [ i ] ) ;
778794 }
795+ } else if ( schema . hasOwnProperty ( "$ref" ) ) {
796+ console . log ( "REFERENTIAL" ) ;
797+ var newschema = getDefinition ( schema [ "$ref" ] ) ;
798+ populateSchemaMap ( name , newSchema ) ;
779799 } else if ( schema . type === "object" ) {
780800 if ( schema . properties ) {
781801 pseudoSchema . properties = new Object ( ) ;
782802 for ( var prop in schema . properties ) {
783803 var childProp = name + "." + prop ;
784804 pseudoSchema . properties [ prop ] = childProp ;
785- console . log ( prop , childProp , schema ) ;
805+ // console.log(prop,childProp,schema);
786806 populateSchemaMap ( childProp , schema . properties [ prop ] ) ;
787807 }
788808 }
@@ -795,6 +815,16 @@ if (typeof brutusin === "undefined") {
795815 populateSchemaMap ( childProp , SCHEMA_ANY ) ;
796816 }
797817 }
818+ if ( schema . hasOwnProperty ( "definitions" ) ) {
819+ console . log ( schema . definitions ) ;
820+ pseudoSchema . definitions = new Object ( ) ;
821+ for ( var def in schema . definitions ) {
822+ continue ;
823+ var childProp = name + "/" + prop ;
824+ pseudoSchema . definitions [ prop ] = childProp ;
825+ populateSchemaMap ( childProp , schema . definitions [ prop ] ) ;
826+ }
827+ }
798828 } else if ( schema . type === "array" ) {
799829 pseudoSchema . items = name + "[#]" ;
800830 populateSchemaMap ( pseudoSchema . items , schema . items ) ;
0 commit comments