Skip to content

Commit

Permalink
Only parse JSON responses if we need to
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Damphousse authored and robertdamphousse-okta committed Jun 27, 2017
1 parent e018827 commit b0bbd08
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/generated-client.js
Expand Up @@ -440,7 +440,7 @@ class GeneratedApiClient {

url += queryString ? ('?' + queryString) : '';

const request = this.http.post(url);
const request = this.http.postJson(url);
return request.then(jsonRes => new models.UserActivationToken(jsonRes, this));
}

Expand Down Expand Up @@ -469,7 +469,7 @@ class GeneratedApiClient {

url += queryString ? ('?' + queryString) : '';

const request = this.http.post(url);
const request = this.http.postJson(url);
return request.then(jsonRes => new models.TempPassword(jsonRes, this));
}

Expand Down Expand Up @@ -499,7 +499,7 @@ class GeneratedApiClient {

url += queryString ? ('?' + queryString) : '';

const request = this.http.post(url);
const request = this.http.postJson(url);
return request.then(jsonRes => new models.ResetPasswordToken(jsonRes, this));
}

Expand Down
20 changes: 20 additions & 0 deletions templates/generated-client.js.hbs
Expand Up @@ -38,22 +38,42 @@ class GeneratedApiClient {
{{/if}}
{{#if (eq method 'post')}}
{{#if bodyModel}}
{{#if responseModel}}
const request = this.http.postJson(url, {
body: {{camelCase bodyModel}}
});
{{else}}
const request = this.http.post(url, {
body: {{camelCase bodyModel}}
});
{{/if}}
{{else}}
{{#if responseModel}}
const request = this.http.postJson(url);
{{else}}
const request = this.http.post(url);
{{/if}}
{{/if}}
{{/if}}
{{#if (eq method 'put')}}
{{#if bodyModel}}
{{#if responseModel}}
const request = this.http.putJson(url, {
body: {{camelCase bodyModel}}
});
{{else}}
const request = this.http.put(url, {
body: {{camelCase bodyModel}}
});
{{/if}}
{{else}}
{{#if responseModel}}
const request = this.http.putJson(url);
{{else}}
const request = this.http.put(url);
{{/if}}
{{/if}}
{{/if}}
{{#if responseModel}}
return request.then(jsonRes => new models.{{responseModel}}(jsonRes, this));
{{else}}
Expand Down

0 comments on commit b0bbd08

Please sign in to comment.