@@ -2275,6 +2275,71 @@ describe('serializers/swagger/v2.0/Serializer.js', () => {
2275
2275
2276
2276
expect ( actual ) . toEqual ( expected )
2277
2277
} )
2278
+
2279
+ it ( 'should work if underlying methods are correct and with request method' , ( ) => {
2280
+ spyOn ( __internals__ , 'getTagStrings' ) . andReturn ( [ 'pet' , 'store' ] )
2281
+ spyOn ( __internals__ , 'getKeysFromRecord' ) . andReturn ( {
2282
+ summary : 'update a Pet' ,
2283
+ description : 'updates a pet with some params' ,
2284
+ operationId : 'updatePet'
2285
+ } )
2286
+
2287
+ spyOn ( __internals__ , 'getConsumesEntry' ) . andReturn ( [ 'application/json' ] )
2288
+ spyOn ( __internals__ , 'getProducesEntry' ) . andReturn ( [ 'application/xml' ] )
2289
+ spyOn ( __internals__ , 'getParametersFromRequest' ) . andReturn ( [ {
2290
+ in : 'query' ,
2291
+ name : 'petId' ,
2292
+ type : 'string'
2293
+ } ] )
2294
+ spyOn ( __internals__ , 'getSchemesFromRequestEndpointOverlay' ) . andReturn ( [ 'https' ] )
2295
+ spyOn ( __internals__ , 'getSecurityRequirementsFromRequest' ) . andReturn ( [
2296
+ {
2297
+ petstore_auth : [ 'write:self' ]
2298
+ }
2299
+ ] )
2300
+ spyOn ( __internals__ , 'getResponsesFromRequest' ) . andReturn ( {
2301
+ '200' : {
2302
+ description : 'this method should return 200'
2303
+ }
2304
+ } )
2305
+
2306
+ const store = new Store ( )
2307
+ const globalInfo = { }
2308
+ const request = new Request ( { method : 'Get' } )
2309
+ const key = 'put'
2310
+
2311
+ const expectedValue = {
2312
+ tags : [ 'pet' , 'store' ] ,
2313
+ summary : 'update a Pet' ,
2314
+ description : 'updates a pet with some params' ,
2315
+ operationId : 'updatePet' ,
2316
+ consumes : [ 'application/json' ] ,
2317
+ produces : [ 'application/xml' ] ,
2318
+ parameters : [
2319
+ {
2320
+ in : 'query' ,
2321
+ name : 'petId' ,
2322
+ type : 'string'
2323
+ }
2324
+ ] ,
2325
+ schemes : [ 'https' ] ,
2326
+ security : [
2327
+ {
2328
+ petstore_auth : [ 'write:self' ]
2329
+ }
2330
+ ] ,
2331
+ responses : {
2332
+ '200' : {
2333
+ description : 'this method should return 200'
2334
+ }
2335
+ }
2336
+ }
2337
+
2338
+ const expected = { key : 'get' , value : expectedValue }
2339
+ const actual = __internals__ . convertRequestToOperationObject ( store , globalInfo , request , key )
2340
+
2341
+ expect ( actual ) . toEqual ( expected )
2342
+ } )
2278
2343
/* eslint-enable max-statements */
2279
2344
} )
2280
2345
0 commit comments