Skip to content

When read operations are explicitly defined, the documentation schema cannot be parsed by the admin panel #2870

@zpi12lmm

Description

@zpi12lmm

API Platform version(s) affected: 4.1.1

Description
When I try to define the operations I need in the ApiResource attribute, the following error occurs on the admin panel side:

Error: Cannot fetch API documentation:
Cannot find the class related to https://localhost/docs.jsonld#Entrypoint/greeting.
Have you verified that CORS is correctly configured in your API?

How to reproduce
The easiest way to reproduce this error is to simply use this repository (clone it, or use it as a template), and modify the existing Greeting class, this is enough to get this error, for example, by default, the ApiResource attributes in the Greeting class are defined like this:

#[ApiResource(mercure: true)]

and I'm trying to define the following operations:

#[ApiResource(
    operations: [new GetCollection(), new Get()],
    mercure: true,
)]

Possible Solution
Probably, the problem is in the generation of the scheme for Hydra, because if you add the new Post() operation, then this error disappears. (I tried disabling the create action on the list page from the admin panel, but it had no effect)

Additional Context
I have another project based on ApiPlatform, where I first encountered this problem, but I have a fairly large ecosystem of technologies there, and the use of third-party libraries, so I thought it was caused by something else, so I first tried to investigate the problem there, I came to the conclusion that the error occurs at the stage of parsing the Hydra documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions