Skip to content

Commit

Permalink
Do not set a body on a 204, it never makes sense to have it and it of…
Browse files Browse the repository at this point in the history
…ten causes problems everywhere.
  • Loading branch information
wparad committed Sep 7, 2023
1 parent 5be0578 commit 9c59477
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ This is the changelog for [OpenAPI Factory](readme.md).

## 5.4 ##
* Invert the path map. This actually isn't a breaking change, but you are directly using the internals of this library, they are changing.
* 204 response status codes shall never include the body.

## 5.3 ##
* Upgrade to node 14
Expand Down
2 changes: 1 addition & 1 deletion src/response.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class Response {
constructor(body, statusCode, headers) {
let pullBody = body && (body.body || body.statusCode || body.headers);
this.body = pullBody ? body.body : body;
this.statusCode = (pullBody ? body.statusCode : statusCode) || 200;
let populatedHeaders = (pullBody ? body.headers : headers) || {};
this.isBase64Encoded = (pullBody ? body.isBase64Encoded : false) || false;
this.body = this.statusCode === 204 ? undefined : (pullBody ? body.body : body);

if (!this.body) {
delete this.body;
Expand Down

0 comments on commit 9c59477

Please sign in to comment.