@@ -9,7 +9,6 @@ var Resolver = require('../lib/resolver');
99var instance ;
1010
1111describe ( 'swagger resolver' , function ( ) {
12-
1312 before ( function ( done ) {
1413 mock . petstore ( done , function ( petstore , server ) {
1514 instance = server ;
@@ -43,7 +42,7 @@ describe('swagger resolver', function () {
4342 }
4443 } ;
4544
46- api . resolve ( spec , 'http://localhost:8000 /v2/petstore.json' , function ( spec ) {
45+ api . resolve ( spec , 'http://localhost:8080 /v2/petstore.json' , function ( spec ) {
4746 expect ( spec . definitions . Category ) . toExist ( ) ;
4847 done ( ) ;
4948 } ) ;
@@ -131,7 +130,7 @@ describe('swagger resolver', function () {
131130 }
132131 } ;
133132
134- api . resolve ( spec , 'http://localhost:8000 /v2/petstore.json' , function ( spec ) {
133+ api . resolve ( spec , 'http://localhost:8080 /v2/petstore.json' , function ( spec ) {
135134 expect ( spec . definitions . Category ) . toExist ( ) ;
136135 done ( ) ;
137136 } ) ;
@@ -154,7 +153,7 @@ describe('swagger resolver', function () {
154153 }
155154 } ;
156155
157- api . resolve ( spec , 'http://localhost:8000 /v2/petstore.json' , function ( spec ) {
156+ api . resolve ( spec , 'http://localhost:8080 /v2/petstore.json' , function ( spec ) {
158157 expect ( spec . definitions . Pet ) . toExist ( ) ;
159158 done ( ) ;
160159 } ) ;
@@ -177,7 +176,7 @@ describe('swagger resolver', function () {
177176 }
178177 } ;
179178
180- api . resolve ( spec , 'http://localhost:8000 /v2/petstore.json' , function ( spec ) {
179+ api . resolve ( spec , 'http://localhost:8080 /v2/petstore.json' , function ( spec ) {
181180 expect ( spec . definitions . Pet ) . toExist ( ) ;
182181 expect ( spec . paths [ '/pet' ] . post . responses [ '200' ] . schema . $ref ) . toBe ( '#/definitions/Pet' ) ;
183182
@@ -328,7 +327,7 @@ describe('swagger resolver', function () {
328327 }
329328 } ;
330329
331- api . resolve ( spec , 'http://localhost:8000 /v2/petstore.json' , function ( spec ) {
330+ api . resolve ( spec , 'http://localhost:8080 /v2/petstore.json' , function ( spec ) {
332331 var path = spec . paths [ '/myUsername' ] ;
333332 test . object ( path ) ;
334333 test . object ( path . get ) ;
@@ -390,7 +389,8 @@ describe('swagger resolver', function () {
390389 }
391390 }
392391 } ;
393- api . resolve ( spec , 'http://localhost:8000/v2/petstore.json' , function ( spec ) {
392+ // we use a different URL so the resolver doesn't treat the `spec` as the *entire* spec.
393+ api . resolve ( spec , 'http://localhost:8080/v2/petstore.json' , function ( spec ) {
394394 var get = spec . paths [ '/myUsername' ] . get ;
395395 var response = get . responses [ '400' ] ;
396396 expect ( response . description ) . toBe ( 'failed' ) ;
@@ -696,4 +696,34 @@ describe('swagger resolver', function () {
696696 done ( ) ;
697697 } ) ;
698698 } ) ;
699+
700+ it ( 'does not make multiple calls for parameter refs #489' , function ( done ) {
701+ var api = new Resolver ( ) ;
702+ var spec = {
703+ paths : {
704+ '/pet' : {
705+ post : {
706+ parameters : [ {
707+ $ref : '#/parameters/sharedSkip'
708+ } ]
709+ }
710+ }
711+ } ,
712+ parameters : {
713+ sharedSkip : {
714+ name : 'skip' ,
715+ in : 'query' ,
716+ description : 'Results to skip' ,
717+ required : false ,
718+ type : 'integer' ,
719+ format : 'int32'
720+ }
721+ }
722+ } ;
723+
724+ api . resolve ( spec , 'http://localhost:8000/swagger.json' , function ( spec , unresolved ) {
725+ expect ( Object . keys ( unresolved ) . length ) . toBe ( 0 ) ;
726+ done ( ) ;
727+ } ) ;
728+ } ) ;
699729} ) ;
0 commit comments