This is an automated email from the ASF dual-hosted git repository. rabbah pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-js.git
The following commit(s) were added to refs/heads/master by this push: new 244d2b0 Adding support for responsetype parameter during route create. (#74) 244d2b0 is described below commit 244d2b00d197aeb32687a551c344df7b23dbd4fc Author: James Thomas <jthomas...@gmail.com> AuthorDate: Tue Oct 17 11:50:37 2017 +0100 Adding support for responsetype parameter during route create. (#74) --- README.md | 3 ++- lib/routes.js | 2 +- package.json | 4 ++-- test/unit/routes.test.js | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fdd4998..159b3e3 100644 --- a/README.md +++ b/README.md @@ -464,7 +464,8 @@ ow.routes.create({relpath: '...', operation: '...', action: '...'}) *`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 @@ class Routes extends BaseOperation { } 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 @@ test('should create a route with apigw_token', t => { 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}` -- To stop receiving notification emails like this one, please contact ['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].