@@ -260,7 +260,7 @@ describe('OpenWhiskCompileHttpEvents', () => {
260260
261261 const httpEvent = {
262262 relpath : '/api/foo/{id}' , operation : 'GET' , secure_key : 'auth-token' ,
263- action : 'action-name' , namespace : 'user@host.com_space' , pkge : 'default' , responsetype : 'json '
263+ action : 'action-name' , namespace : 'user@host.com_space' , pkge : 'default' , responsetype : 'http '
264264 }
265265
266266 const host = 'openwhisk.somewhere.com'
@@ -280,7 +280,7 @@ describe('OpenWhiskCompileHttpEvents', () => {
280280 action : "action-name" ,
281281 namespace : "user@host.com_space" ,
282282 package : "default" ,
283- url : "https://openwhisk.somewhere.com/api/v1/web/user@host.com_space/default/action-name.json "
283+ url : "https://openwhisk.somewhere.com/api/v1/web/user@host.com_space/default/action-name.http "
284284 }
285285 }
286286
@@ -323,6 +323,40 @@ describe('OpenWhiskCompileHttpEvents', () => {
323323
324324 return expect ( result ) . to . deep . equal ( expectedResult )
325325 } ) ;
326+
327+ it ( 'should define swagger case statement from http events with path parameters' , ( ) => {
328+ openwhiskCompileHttpEvents . serverless . service . service = 'my-service'
329+ openwhiskCompileHttpEvents . serverless . service . provider = { namespace : "sample_ns" } ;
330+
331+ const httpEvent = {
332+ relpath : '/api/foo/{id}' , operation : 'GET' , secure_key : 'auth-token' ,
333+ action : 'action-name' , namespace : 'user@host.com_space' , pkge : 'default' , responsetype : 'http'
334+ }
335+
336+ const host = 'openwhisk.somewhere.com'
337+ const result = openwhiskCompileHttpEvents . compileSwaggerCaseSwitch ( httpEvent , host ) ;
338+
339+ const expectedResult = {
340+ execute : [ {
341+ "set-variable" : {
342+ actions : [ {
343+ set : "message.headers.X-Require-Whisk-Auth" ,
344+ value : "auth-token"
345+ } ]
346+ }
347+ } ,
348+ {
349+ invoke : {
350+ "target-url" : "https://openwhisk.somewhere.com/api/v1/web/user@host.com_space/default/action-name.http$(request.path)" ,
351+ "verb" : "keep"
352+ }
353+ }
354+ ] ,
355+ operations : [ "get-/api/foo/{id}" ]
356+ }
357+
358+ return expect ( result ) . to . deep . equal ( expectedResult )
359+ } ) ;
326360 } ) ;
327361
328362 describe ( '#generateSwagger()' , ( ) => {
0 commit comments