-
-
Notifications
You must be signed in to change notification settings - Fork 900
Doctrine ORM StateOptions uses entity instead of DTO class #6039
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
Comments
https://github.com/api-platform/core/blob/main/tests/Fixtures/TestBundle/ApiResource/Issue5648/DummyResource.php#L25-L31 ? Not sure what you're trying to do |
Hi ! Sorry I was not clear. I'm not using force_resource_class, i was just showing the behavior in the AbstractItemNormalizer that I have in my debugger ! :-) Here's my snippet for my resource !
I have defined the entity like this, in the Get Operation i have the force_resource_class set in my context, but not in the GetCollection. |
I have found out that Doctrine gets the whole object and not only the properties declared in my ClubApi Object. I don't get why. The expected behavior in GetCollection is incorrect, where as when using Get it is correct. |
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. |
Hi! I can confirm this error on the latest 3.2.14 and have a reproducer from our tutorial: The #[ApiResource(
shortName: 'User',
stateOptions: new Options(entityClass: User::class),
)]
class UserApi
{
public ?int $id = null;
public ?string $email = null;
public ?string $username = null;
} To reproduce:
Then go to
I can also confirm that the bug is introduced when upgrading specifically from Cheers! |
sorry for the delay, thanks for the reproducer |
API Platform version(s) affected: 3.2.7
Description
Hello There (General Kenwebby) ! I want to split my API logic from my entity logic using ORM state Options.
It works perfectly on a Get Operation (there is the "force_resource_class" specified in my AbstractItemNormalizer, but when using a GetCollection it does not work and serializes my entity object instead.
How to reproduce
Create an Entity "Club" and a DTO "ClubApi", set an id and a name property on the entity and an id only on the ClubApi Class.
Additional Context
When using Get Operation

When using GetCollection Operation

Thanks a lot !
The text was updated successfully, but these errors were encountered: