Skip to content

Commit

Permalink
Fix empty object attributes by jsonapi spec
Browse files Browse the repository at this point in the history
  • Loading branch information
r0mm4k committed Nov 11, 2020
1 parent ae67805 commit fbc1ef7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ function serializeEntity (entity, transformer: Transformer, options: Options, in
delete data.relationships
}

if (Object.keys(data.attributes).length === 0) {
delete data.attributes
}

return data
}

Expand Down

0 comments on commit fbc1ef7

Please sign in to comment.