@@ -134,6 +134,7 @@ if (typeof brutusin === "undefined") {
134134 var error ;
135135 var initialValue ;
136136 var inputCounter = 0 ;
137+ var root = schema ;
137138 var formId = "BrutusinForms#" + BrutusinForms . instances . length ;
138139 //console.log(schema);
139140 populateSchemaMap ( "$" , schema ) ;
@@ -775,10 +776,16 @@ if (typeof brutusin === "undefined") {
775776 return pseudoSchema ;
776777 }
777778 function getDefinition ( path ) {
778- // Translate the path to schema standard.
779- // $/definitions/ from #/definitions/
780- // fetch that schema.
781-
779+ var newpath = "$" + path . substring ( 1 ) ;
780+ var parts = path . split ( '/' ) ;
781+ var def = root ;
782+ for ( p in parts ) {
783+ if ( p == 0 )
784+ continue ;
785+ def = def [ parts [ p ] ] ;
786+
787+ }
788+ return def ;
782789 }
783790
784791 function populateSchemaMap ( name , schema ) {
@@ -796,15 +803,15 @@ if (typeof brutusin === "undefined") {
796803 }
797804 } else if ( schema . hasOwnProperty ( "$ref" ) ) {
798805 console . log ( "REFERENTIAL" ) ;
799- var newschema = getDefinition ( schema [ "$ref" ] ) ;
806+ var newSchema = getDefinition ( schema [ "$ref" ] ) ;
807+ console . log ( name , newSchema , schemaMap ) ;
800808 populateSchemaMap ( name , newSchema ) ;
801809 } else if ( schema . type === "object" ) {
802810 if ( schema . properties ) {
803811 pseudoSchema . properties = new Object ( ) ;
804812 for ( var prop in schema . properties ) {
805813 var childProp = name + "." + prop ;
806814 pseudoSchema . properties [ prop ] = childProp ;
807- //console.log(prop,childProp,schema);
808815 populateSchemaMap ( childProp , schema . properties [ prop ] ) ;
809816 }
810817 }
@@ -817,16 +824,6 @@ if (typeof brutusin === "undefined") {
817824 populateSchemaMap ( childProp , SCHEMA_ANY ) ;
818825 }
819826 }
820- if ( schema . hasOwnProperty ( "definitions" ) ) {
821- console . log ( "DEFS" , schema . definitions ) ;
822- pseudoSchema . definitions = new Object ( ) ;
823- for ( var def in schema . definitions ) {
824- continue ;
825- var childProp = name + "/" + prop ;
826- pseudoSchema . definitions [ prop ] = childProp ;
827- populateSchemaMap ( childProp , schema . definitions [ prop ] ) ;
828- }
829- }
830827 } else if ( schema . type === "array" ) {
831828 pseudoSchema . items = name + "[#]" ;
832829 populateSchemaMap ( pseudoSchema . items , schema . items ) ;
0 commit comments