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
Throw an error when no identifier is defined #3871
Conversation
soyuka
commented
Dec 2, 2020
Q | A |
---|---|
Bug fix? | no |
New feature? | no |
BC breaks? | kinda |
Deprecations? | no |
Tickets | |
License | MIT |
Doc PR | api-platform/docs#... |
0947f15
to
a89b405
Compare
a89b405
to
167e92f
Compare
Caused by this change api-platform/core#3871
@@ -57,6 +57,10 @@ public function getIdentifiersFromResourceClass(string $resourceClass): array | |||
} | |||
} | |||
|
|||
if (!$identifiers) { | |||
throw new RuntimeException(sprintf('No identifier defined "%s". You should add #[\ApiPlatform\Core\Annotation\ApiProperty(identifier: true)]" on the property identifying the resource."', $resourceClass)); |
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.
What do you think about
- No identifier defined "%s".
+ No identifier defined in "%s".
I mean, "in" is missed from my point of view
This PR was merged into the 1.8 branch. Discussion ---------- Caused by this change api-platform/core#3871 | Q | A | --------------- | ----- | Branch? | 1.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | api-platform/core#3871 | License | MIT Commits ------- 5a7bc59 Fix no identifier defined error in ApiPlatform 2.6
Caused by this change api-platform/core#3871
This new exception seems to break POST/PUT endpoints that use a DTO without id as the resource. Is that intended? If so, what are the alternatives? |
It should not break unless your DTO is a resource. Please open an issue and provide a reproducer I definitely want to check this! |