@@ -12,6 +12,24 @@ var _ = {
1212 */
1313var Resolver = module . exports = function ( ) { } ;
1414
15+ Resolver . prototype . processAllOf = function ( name , definition , resolutionTable , unresolvedRefs , spec ) {
16+ var i , location , property ;
17+
18+ definition [ 'x-resolved-from' ] = [ '#/definitions/' + name ] ;
19+ var allOf = definition . allOf ;
20+ // the refs go first
21+ allOf . sort ( function ( a , b ) {
22+ if ( a . $ref && b . $ref ) { return 0 ; }
23+ else if ( a . $ref ) { return - 1 ; }
24+ else { return 1 ; }
25+ } ) ;
26+ for ( i = 0 ; i < allOf . length ; i ++ ) {
27+ property = allOf [ i ] ;
28+ location = '/definitions/' + name + '/allOf' ;
29+ this . resolveInline ( null , spec , property , resolutionTable , unresolvedRefs , location ) ;
30+ }
31+ }
32+
1533Resolver . prototype . resolve = function ( spec , arg1 , arg2 , arg3 ) {
1634 var root = arg1 , callback = arg2 , scope = arg3 , location , i ;
1735 if ( typeof arg1 === 'function' ) {
@@ -32,23 +50,16 @@ Resolver.prototype.resolve = function (spec, arg1, arg2, arg3) {
3250 var definition = spec . definitions [ name ] ;
3351 for ( propertyName in definition . properties ) {
3452 property = definition . properties [ propertyName ] ;
35- this . resolveTo ( root , property , resolutionTable , '/definitions' ) ;
53+ if ( _ . isArray ( property . allOf ) ) {
54+ this . processAllOf ( name , property , resolutionTable , unresolvedRefs , spec ) ;
55+ }
56+ else {
57+ this . resolveTo ( root , property , resolutionTable , '/definitions' ) ;
58+ }
3659 }
3760
3861 if ( definition . allOf ) {
39- definition [ 'x-resolved-from' ] = [ '#/definitions/' + name ] ;
40- var allOf = definition . allOf ;
41- // the refs go first
42- allOf . sort ( function ( a , b ) {
43- if ( a . $ref && b . $ref ) { return 0 ; }
44- else if ( a . $ref ) { return - 1 ; }
45- else { return 1 ; }
46- } ) ;
47- for ( i = 0 ; i < allOf . length ; i ++ ) {
48- property = allOf [ i ] ;
49- location = '/definitions/' + name + '/allOf' ;
50- this . resolveInline ( null , spec , property , resolutionTable , unresolvedRefs , location ) ;
51- }
62+ this . processAllOf ( name , definition , resolutionTable , unresolvedRefs , spec ) ;
5263 }
5364 }
5465
@@ -461,7 +472,6 @@ Resolver.prototype.resolveInline = function (root, spec, property, resolutionTab
461472
462473Resolver . prototype . resolveTo = function ( root , property , resolutionTable , location ) {
463474 var ref = property . $ref ;
464-
465475 if ( ref ) {
466476 if ( ref . indexOf ( '#' ) >= 0 ) {
467477 location = ref . split ( '#' ) [ 1 ] ;
0 commit comments