-
-
Notifications
You must be signed in to change notification settings - Fork 921
Allow serializing when property and method start from "is" #4125
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
Conversation
features/main/dummy_boolean.feature
Outdated
"@type": "DummyBoolean", | ||
"id": 1, | ||
"isDummyBoolean": true, | ||
"dummyBoolean": true |
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.
I have no idea where dummyBoolean
serialized key/value comes from.
If I remove the fix ('enable_getter_setter_extraction' => true
) - both isDummyBoolean
and DummyBoolean
are absent.
Is it something json-ld
adds in addition to isDummyBoolean
?
I can't reproduce it locally on 2.6.3
in our project (we use application/json
)
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.
I think it's more a normalizer issue and it should be fixed in Symfony itself.
I saw it too when debugging the previous PR.
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.
Oh, I think I understand why I can't reproduce it locally - because we have a composer.lock
and our serializer doesn't have this bug, while api-platform/core
installs the latest versions
features/main/dummy_boolean.feature
Outdated
@@ -0,0 +1,30 @@ | |||
Feature: Serialization of boolean properties |
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.
Wouldn't it be better in serializer
?
The unit tests need to be fixed too. |
90ea6bf
to
ef4731a
Compare
{ | ||
$this->isDummyBoolean = $isDummyBoolean; | ||
} | ||
|
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.
we should avoid changing old tests
$options = []; | ||
$options = [ | ||
/* @see https://github.com/symfony/symfony/blob/v5.1.0/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php */ | ||
'enable_getter_setter_extraction' => true, |
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.
wondering if this should be opt-in, does this break existing tests?
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.
No it doesn't break existing tests. However it can be considered as a BC break.
b8c4da4
to
bb142f0
Compare
I think this feature should probably target 2.7 and can be considered as a BC break. <?php
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
/**
* @ApiResource
* @ORM\Entity
*/
class Test
{
/**
* @var int
*
* @ORM\Column(type="integer", nullable=true)
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var bool
*
* @ORM\Column(type="boolean", nullable=true)
*/
private $last;
public function getId()
{
return $this->id;
}
public function last(): bool
{
return $this->last;
}
} Before it was not serialized and now it will be. WDYT @maks-rafalko @soyuka? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
It still the issue, however I don't have time/energy to complete it. If someone can help, that would be awesome. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Follow up for https://github.com/api-platform/core/pull/4064/files
In #4064, there was a fix for documentation generated on UI. But, unfortunately, when we use
public function isActive()
method and$isActive
property, the value is not being serialized - it is not included in the response.The reason is the same -
$options
array does not contain'enable_getter_setter_extraction' => true
default value.I have some issues with the tests, probably you can help me with understanding what's going on, will comment below.