Adding support for responsetype parameter during route create. (#74)
diff --git a/README.md b/README.md
index fdd4998..159b3e3 100644
--- a/README.md
+++ b/README.md
@@ -464,7 +464,8 @@
*`action` supports normal (actionName) and fully-qualified (/namespace/actionName) formats.*
-The following optional parameters are supported to filter the result set:
+The following optional parameters are supported:
+- `responsetype` - content type returned by web action, possible values: `html`, `http`, `json`, `text` and `svg` (default: `json`).
- `basepath` - base URI path for endpoints (default: `/`)
## Debugging
diff --git a/lib/routes.js b/lib/routes.js
index 2de8ab4..edb5f60 100644
--- a/lib/routes.js
+++ b/lib/routes.js
@@ -48,7 +48,7 @@
}
const body = this.route_swagger_definition(options)
- const qs = this.qs(options, [])
+ const qs = this.qs(options, ['responsetype'])
return this.client.request('POST', this.routeMgmtApiPath('createApi'), { body, qs })
}
diff --git a/package.json b/package.json
index 8a7f3e1..105f154 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "openwhisk",
- "version": "3.6.0",
+ "version": "3.9.0",
"description": "JavaScript client library for the OpenWhisk platform",
"main": "lib/main.js",
"typings": "lib/main.d.ts",
@@ -65,4 +65,4 @@
"babel-core/register"
]
}
-}
\ No newline at end of file
+}
diff --git a/test/unit/routes.test.js b/test/unit/routes.test.js
index 5e3767c..0d25c36 100644
--- a/test/unit/routes.test.js
+++ b/test/unit/routes.test.js
@@ -171,6 +171,41 @@
return routes.create({relpath: '/hello', operation: 'GET', action: 'helloAction'})
})
+test('should create a route with response type', t => {
+ t.plan(4)
+ const path_url = path => `https://openwhisk.ng.bluemix.net/api/v1/${path}`
+ const api_key = 'username:password'
+ const client_options = { api_key }
+ const client = { path_url, options: client_options }
+ const options = {force: true, basepath: '/hello', relpath: '/bar/1', operation: 'GET'}
+
+ const body = {
+ apidoc: {
+ namespace: '_',
+ gatewayBasePath: '/',
+ gatewayPath: '/hello',
+ gatewayMethod: 'GET',
+ id: 'API:_:/',
+ action: {
+ name: 'helloAction',
+ namespace: '_',
+ backendMethod: 'GET',
+ backendUrl: 'https://openwhisk.ng.bluemix.net/api/v1/web/_/default/helloAction.http',
+ authkey: api_key }
+ }
+ }
+
+ client.request = (method, path, _options) => {
+ t.is(method, 'POST')
+ t.is(path, routes.routeMgmtApiPath('createApi'))
+ t.deepEqual(_options.body, body)
+ t.deepEqual(_options.qs, { responsetype: 'http' })
+ }
+
+ const routes = new Routes(client)
+ return routes.create({relpath: '/hello', operation: 'GET', action: 'helloAction', responsetype: 'http'})
+})
+
test('should create a route with apigw_token and action with package', t => {
t.plan(4)
const path_url = path => `https://openwhisk.ng.bluemix.net/api/v1/${path}`