-
Notifications
You must be signed in to change notification settings - Fork 22
Mapped NULL values are serialized outside of the _embedded key #52
Comments
Since you have the scenario mapped here, could you please submit a pull request demonstrating the issue? I can work on a solution this week if so. |
@weierophinney demonstrating the issue = failing unit test ? |
Indeed!
…On Mon, Jan 7, 2019, 5:47 PM Julien Guittard ***@***.*** wrote:
@weierophinney <https://github.com/weierophinney> *demonstrating the
issue* = failing unit test ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#52 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABlVyIfRiJ4156tgWfJ0Gmg66A6L5qkks5vA9yigaJpZM4Zy6QM>
.
|
@weierophinney see #53 |
After seeing #53, I took a closer look at the expected/actual results you had above, and I'm not 100% convinced that what you expect is correct. In the specification description for
The specification is explicitly stating that the values for each relation must be an object or array of objects (what we call collections in this package). As such, because you have assigned a One way I've looked at HAL: the complete resource is the combination of its properties, and the various |
Two things before going deeper into business considerations:
|
The point is that, for purposes of HAL, a resource MUST be an object, and, specifically, an object with relational links. Neither does an empty object - UNLESS you provide relational links for it (e.g., a POST URL to which one can make a request to create a resource of that type). Even then, I'd argue the relational link goes in the parent: {
"_links": {
"avatar": { "href": "/users" }
"self": { "href": "..." }
},
} |
How does HAL then represent the property of an object whose value is not set? It just not represents it? |
I think the problem is assuming that a value is either under the top-level or an .then(function(payload) {
let user = Object.assign(payload, payload._embedded);
delete user._embedded;
return user;
}) If you do pre-processing of the returned payload such as the above, you will not have to worry about where in the representation a property lies; your code will just see a unified "user" object, where some of the properties just happen to be objects that also contain links. |
This repository has been closed and moved to mezzio/mezzio-hal; a new issue has been opened at mezzio/mezzio-hal#4. |
Provide a narrative description of what you are trying to accomplish.
Code to reproduce the issue
User.php
Avatar.php
config.php
Expected results
Actual results
The text was updated successfully, but these errors were encountered: