admin icon indicating copy to clipboard operation
admin copied to clipboard

Docs error after upgrading to API Platform v4.0.2 (backend) and API Platform Admin v4.0.1 (frontend)

Open ekergreis opened this issue 1 year ago • 6 comments
trafficstars

Hi API Platform Admin Team,

I was previously using API Platform v3.3.7 for my backend and API Platform Admin v3.4.7 for my frontend. After upgrading to API Platform v4.0.2 and API Platform Admin v4.0.1, I encountered the following error on the frontend :

Cannot fetch API documentation:
The API documentation has no "http://www.w3.org/ns/hydra/core#supportedClass" key or its value is not an array.
Have you verified that CORS is correctly configured in your API ?

The hydra-prefixed tags have been removed from my APIs as expected, but the API responses are otherwise in the correct format.

Interestingly, if I revert the backend to API Platform v3.3.7 while keeping the frontend at API Platform Admin v4.0.1, everything works fine. The issue only appears when both the backend and frontend are on the latest versions (v4.x).

Thank you for your help!

ekergreis avatar Sep 29 '24 14:09 ekergreis

The issue only appears when both the backend and frontend are on the latest versions (v4.x).

These versions are not correlated. AP Admin major version change from 3.x to 4.x was done only because of adding React Admin 5.x support what was a breaking change.

PawelSuwinski avatar Sep 30 '24 05:09 PawelSuwinski

@alanpoulain @dunglas can api doc parser be compatible with the latest two versions of API Platform?

fzaninotto avatar Sep 30 '24 07:09 fzaninotto

It's maybe because we removed the hydra: prefix by default. We'll take a look.

dunglas avatar Sep 30 '24 07:09 dunglas

Could you please try to set the hydra_prefix of the API component to true to see if this workaround works:

# api/config/packages/api_platform.yaml
api_platform:
    serializer:
        hydra_prefix: true

https://api-platform.com/docs/core/upgrade-guide/

dunglas avatar Sep 30 '24 08:09 dunglas

Set the hydra_prefix of the API component to true works.

valentin-dassonville avatar Sep 30 '24 15:09 valentin-dassonville

Thanks, it's OK with hydra_prefix: true

ekergreis avatar Sep 30 '24 15:09 ekergreis