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

Throw an error when no identifier is defined #3871

Merged
merged 1 commit into from Dec 2, 2020

Conversation

soyuka
Copy link
Member

@soyuka 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#...

@soyuka soyuka force-pushed the fix/no-identifiers branch 2 times, most recently from 0947f15 to a89b405 Compare December 2, 2020 18:01
src/Api/IdentifiersExtractor.php Outdated Show resolved Hide resolved
@@ -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));
Copy link
Contributor

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

pamil added a commit to Sylius/Sylius that referenced this pull request Jan 26, 2021
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
pamil pushed a commit to Sylius/SyliusApiBundle that referenced this pull request Jan 26, 2021
@julienfalque
Copy link
Contributor

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?

@soyuka
Copy link
Member Author

soyuka commented Jan 29, 2021

It should not break unless your DTO is a resource. Please open an issue and provide a reproducer I definitely want to check this!

@maks-rafalko
Copy link
Contributor

@soyuka there is already an issue #3975

Please re-read it, author has edited description

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.

None yet

4 participants