Skip to content

Commit

Permalink
feat(getStream): add support for getStream to swagger-based client co…
Browse files Browse the repository at this point in the history
…de (#206)

Related: #199
  • Loading branch information
silasbw committed Mar 7, 2018
1 parent 67e77a5 commit ccb2be0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/swagger-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ class Component {
//
Object.keys(endpoint.pathItem)
.filter(key => endpoint.pathItem[key].operationId)
.forEach(method => { component[method] = component['_' + method]; });
.forEach(method => {
component[method] = component['_' + method];
if (method === 'get') component.getStream = component._getStream;
});
}

/**
Expand All @@ -172,6 +175,16 @@ class Component {
// Supported operations.
//

/**
* Invoke a GET request against the Kubernetes API server
* @param {ApiRequestOptions} options - Options object.
* @returns {Stream} Stream
*/
_getStream(options) {
options = Object.assign({ path: this.splits }, options);
return this.http.request('GET', options);
}

/**
* Invoke a GET request against the Kubernetes API server
* @param {ApiRequestOptions} options - Options object.
Expand Down
1 change: 1 addition & 0 deletions test/swagger-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('lib.swagger', () => {
const client = new SwaggerClient({ spec });
assume(client.foo).is.truthy();
assume(client.foo.get).is.a('function');
assume(client.foo.getStream).is.a('function');

assume(client.foo.bar).is.falsy();
assume(client.foo).is.a('function');
Expand Down

0 comments on commit ccb2be0

Please sign in to comment.