Admin throws error "Cannot find the class related to [Entrypoint/RESOURCE_NAME]" if POST operation is removed from ApiResource
API Platform version(s) affected: 4.0.6
Description
When I remove the POST operation from an ApiResource, the Admin UI throws the following error:
Cannot find the class related to https://localhost/api/docs.jsonld#Entrypoint/[RESOURCE_NAME]
Enabling Hydra prefixes in the API Platform config (which is disabled by default in v4) resolves the issue with the same resource operations.
How to reproduce
In a fresh install of API Platform (v4.x), modify the Greeting resource to only include GET and GET Collection operations:
#[ApiResource(operations: [new Get(), new GetCollection()])]
Expected behavior
The Admin UI should work even if the POST operation is removed from the resource, and without requiring Hydra to be explicitly enabled.
Reproduced, thanks!
I’m experiencing the same issue. Has there been any progress on this or a known workaround?
I've got the idea that this issue relates to entities / resources of which the entrypoint name would be more than one word. Am facing the same issue for an entity named "FooBar", while defining just these two operations as mentioned above for an entity named "Foo" it does work.
# Works
#[ApiResource(
operations: [
new Get(),
new GetCollection(),
],
)]
class Foo {}
# Fails. lets APIP ReactAdmin throw 'Cannot fetch API documentation: Cannot find the class related to https://localhost/docs.jsonld#Entrypoint/fooBar
#[ApiResource(
operations: [
new Get(),
new GetCollection(),
],
)]
class FooBar {}
@slax57 does that match your reproducer? And what would it take to expect an incoming fix?
@rvanlaak My reproducer used the 'Greetings' resource like suggested by the OP. So no, this doesn't seem to be related to the entity name. I can't tell you when this will be fixed. Feel free to have a look at it yourself if you are facing this issue and it is a problem to you. We'll gladly welcome a PR if you manage to find a fix. Also remind there is a workaround for this issue: Enabling Hydra prefixes in the API Platform config (as stated by the OP).