-
-
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
Support empty collections in _embedded
section
#80
Support empty collections in _embedded
section
#80
Conversation
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Hey @weierophinney, I would greatly appreciate your valuable insight to ensure its completeness, per your offer. Thank you in advance. 🙏🏾 |
@ghostwriter
https://datatracker.ietf.org/doc/html/draft-kelly-json-hal#section-4.1.2 The problem I see here is that there is a change in the output and this can cause errors in existing applications and tests. |
@froschdesign I agree, the missing of the The pr/discussion is regarding: an empty array of Resource Objects.
Please look at the test fixtures for examples. |
@ghostwriter |
We have two competing issues:
I'd recommend we make this functionality opt-in, then. @ghostwriter , do you have any ideas on how you could adapt the PR to enable that? |
my idea was to introduce this change as a bug fix with a breaking change in a new minor version and communicate the breaking change to your users and provide documentation on how to handle the change in their applications. based on our discussion in Slack, I was under the impression we all wanted to include both non-empty and empty collections within the |
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
based on both of your feedbacks, it now uses the configuration key |
Signed-off-by: Nathanael Esayeas <[email protected]>
…-embedded-section
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great, @ghostwriter !
My primary concern at this point is that it looks like you rewrote existing tests that tested the existing behavior to test the behavior when the flag is toggled. Since we'll be doing both behaviors, we need to ensure we also test the default behavior.
Commit suggestion: The above makes the order of operations more clear. Additionally, our CS has us put operators on the next line. Co-authored-by: Matthew Weier O'Phinney <[email protected]> Signed-off-by: Nathanael Esayeas <[email protected]>
Co-authored-by: Matthew Weier O'Phinney <[email protected]> Signed-off-by: Nathanael Esayeas <[email protected]>
Co-authored-by: Matthew Weier O'Phinney <[email protected]> Signed-off-by: Nathanael Esayeas <[email protected]>
Co-authored-by: Matthew Weier O'Phinney <[email protected]> Signed-off-by: Nathanael Esayeas <[email protected]>
Commit suggestion: Since the default behavior remains unchanged, we should note in the test that the tested behavior is specifically for when the embed empty collections option is toggled on. Co-authored-by: Matthew Weier O'Phinney <[email protected]> Signed-off-by: Nathanael Esayeas <[email protected]>
Add a note here that this feature is available since version 2.7.0. Signed-off-by: Nathanael Esayeas <[email protected]>
Use constructor property promotion here Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
|
||
if ( | ||
$resource instanceof self || | ||
$resource === [] || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$resource === [] ||
because old behavior allows empty arrays.
Signed-off-by: Nathanael Esayeas <[email protected]>
Signed-off-by: Nathanael Esayeas <[email protected]>
Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor changes to the documentation are necessary. Otherwise it looks good. 👍🏻
commit suggestion Co-authored-by: Frank Brückner <[email protected]> Signed-off-by: Nathanael Esayeas <[email protected]>
commit suggestion Co-authored-by: Frank Brückner <[email protected]> Signed-off-by: Nathanael Esayeas <[email protected]>
commit suggestion Co-authored-by: Frank Brückner <[email protected]> Signed-off-by: Nathanael Esayeas <[email protected]>
Fix Documentation Linting issues Signed-off-by: Nathanael Esayeas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found one little typo, but otherwise, all my feedback has been addressed! I'll apply that change and merge; thanks for the patch, @ghostwriter ! 🎉
Signed-off-by: Matthew Weier O'Phinney <[email protected]>
ARGH - this was targeted at 2.7.x, but slated for 2.8.0. I'll figure out how to untangle it. |
Description
The goal/convention is to include both non-empty and empty collections within the
_embedded
section of the response, to maintain consistency in the structure of the response, regardless of whether the collection is empty or not.Discussion: https://laminas.slack.com/archives/C4RF57B0E/p1686214950164379
Maybe Related #4
empty-contacts-collection-not-embedded.json
{ "contacts": [] }
empty-contacts-collection-embedded.json
non-empty-contacts-collection.json
The user also explained that adding the code below to the constructor worked for them (in case we need to refactor the constructor)