-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapped NULL values are serialized outside of the _embedded key #4
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. Originally posted by @weierophinney at zendframework/zend-expressive-hal#52 (comment) |
@weierophinney demonstrating the issue = failing unit test ? Originally posted by @jguittard at zendframework/zend-expressive-hal#52 (comment) |
Indeed! On Mon, Jan 7, 2019, 5:47 PM Julien Guittard <[email protected]
Originally posted by @weierophinney at zendframework/zend-expressive-hal#52 (comment) |
@weierophinney see #53 Originally posted by @jguittard at zendframework/zend-expressive-hal#52 (comment) |
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 Originally posted by @weierophinney at zendframework/zend-expressive-hal#52 (comment) |
Two things before going deeper into business considerations:
Originally posted by @jguittard at zendframework/zend-expressive-hal#52 (comment) |
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": "..." }
},
} Originally posted by @weierophinney at zendframework/zend-expressive-hal#52 (comment) |
How does HAL then represent the property of an object whose value is not set? It just not represents it? Originally posted by @jguittard at zendframework/zend-expressive-hal#52 (comment) |
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. Originally posted by @weierophinney at zendframework/zend-expressive-hal#52 (comment) |
Closing issue due to being inactive for more than 1 year. |
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
Originally posted by @jguittard at zendframework/zend-expressive-hal#52
The text was updated successfully, but these errors were encountered: