Skip to content
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

Fix mising @type in output DTO collections #3699

Merged
merged 4 commits into from
Sep 13, 2020
Merged

Conversation

soyuka
Copy link
Member

@soyuka soyuka commented Aug 31, 2020

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tickets fixes
License MIT
Doc PR

The @type property was missing from collection using output DTOs.

@soyuka soyuka force-pushed the fix/dtos branch 2 times, most recently from 3f920d6 to 4fda99c Compare September 1, 2020 07:57
@@ -79,7 +79,7 @@ public function normalize($object, $format = null, array $context = [])
$context['api_empty_resource_as_iri'] = true;

$data = $this->decorated->normalize($object, $format, $context);
if (!\is_array($data)) {
if (!\is_array($data) || !$data) {
Copy link
Member

@dunglas dunglas Aug 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should test the type too (in case it's a string or another falsy value).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an empty array because of the first part of the condition

@soyuka soyuka force-pushed the fix/dtos branch 2 times, most recently from f9c985b to 355bee7 Compare September 13, 2020 09:41
@soyuka soyuka merged commit 31de66f into api-platform:2.5 Sep 13, 2020
dunglas added a commit that referenced this pull request Oct 2, 2020
* 2.5:
  fix: simplify PurgeHttpCacheListener
  Fix expression language argument for PublishMercureUpdatesListener
  Backport pull request #3486 (#3723)
  Fix mising @type in output DTO collections (#3699)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants