@@ -603,9 +603,9 @@ prototype.buildParameter = function(oldParameter) {
603603 required : fixNonStringValue ( oldParameter . required )
604604 } ) ;
605605
606- Object . keys ( oldParameter ) . forEach ( function ( property ) {
607- if ( property . match ( / ^ X - / i) !== null ) {
608- parameter [ property ] = oldParameter [ property ] ;
606+ this . forEach ( oldParameter , function ( oldProperty , name ) {
607+ if ( name . match ( / ^ X - / i) !== null ) {
608+ parameter [ name ] = oldProperty ;
609609 }
610610 } ) ;
611611
@@ -740,30 +740,32 @@ prototype.buildSecurityDefinitions = function(oldAuthorizations) {
740740prototype . buildModel = function ( oldModel ) {
741741 var required = [ ] ;
742742 var properties = { } ;
743+ var items ;
743744
744745 this . forEach ( oldModel . properties , function ( oldProperty , propertyName ) {
745746 if ( fixNonStringValue ( oldProperty . required ) === true ) {
746747 required . push ( propertyName ) ;
747748 }
748749
749- properties [ propertyName ] = extend ( { } ,
750- this . buildDataType ( oldProperty , true ) ,
751- {
752- description : oldProperty . description ,
753- example : oldProperty . example
754- }
755- ) ;
750+ properties [ propertyName ] = this . buildModel ( oldProperty ) ;
756751 } ) ;
757752
758- required = oldModel . required || required ;
753+ if ( Array . isArray ( oldModel . required ) ) {
754+ required = oldModel . required ;
755+ }
756+
757+ if ( isValue ( oldModel . items ) ) {
758+ items = this . buildModel ( oldModel . items ) ;
759+ }
759760
760761 return extend ( this . buildDataType ( oldModel , true ) ,
761762 {
762763 description : oldModel . description ,
763764 required : undefinedIfEmpty ( required ) ,
764765 properties : undefinedIfEmpty ( properties ) ,
765766 discriminator : oldModel . discriminator ,
766- example : oldModel . example
767+ example : oldModel . example ,
768+ items : undefinedIfEmpty ( items ) ,
767769 } ) ;
768770} ;
769771
@@ -835,7 +837,9 @@ prototype.forEach = function(collection, iteratee) {
835837 collection . forEach ( iteratee ) ;
836838 }
837839 else {
838- Object . keys ( collection ) . forEach ( function ( key ) {
840+ //In some cases order of iteration influence order of arrays in output.
841+ //To have stable result of convertion, keys need to be sorted.
842+ Object . keys ( collection ) . sort ( ) . forEach ( function ( key ) {
839843 iteratee ( collection [ key ] , key ) ;
840844 } ) ;
841845 }
0 commit comments