@@ -915,6 +915,15 @@ if (typeof brutusin === "undefined") {
915915 return def ;
916916 }
917917
918+ function containsStr ( array , string ) {
919+ for ( var i = 0 ; i < array . length ; i ++ ) {
920+ if ( array [ i ] == string ) {
921+ return true ;
922+ }
923+ }
924+ return false ;
925+ }
926+
918927 function populateSchemaMap ( name , schema ) {
919928 var pseudoSchema = createPseudoSchema ( schema ) ;
920929 pseudoSchema [ "$id" ] = name ;
@@ -936,10 +945,24 @@ if (typeof brutusin === "undefined") {
936945 } else if ( schema . type === "object" ) {
937946 if ( schema . properties ) {
938947 pseudoSchema . properties = new Object ( ) ;
948+ var requiredProperties ;
949+ if ( schema . hasOwnProperty ( "required" ) ) {
950+ if ( Array . isArray ( schema . required ) ) {
951+ requiredProperties = schema . required ;
952+ }
953+ }
939954 for ( var prop in schema . properties ) {
940955 var childProp = name + "." + prop ;
941956 pseudoSchema . properties [ prop ] = childProp ;
942- populateSchemaMap ( childProp , schema . properties [ prop ] ) ;
957+ var subSchema = schema . properties [ prop ] ;
958+ if ( requiredProperties ) {
959+ if ( containsStr ( requiredProperties , prop ) ) {
960+ subSchema . required = true ;
961+ } else {
962+ subSchema . required = false ;
963+ }
964+ }
965+ populateSchemaMap ( childProp , subSchema ) ;
943966 }
944967 }
945968 if ( schema . patternProperties ) {
0 commit comments