baupen / web

Issue management for construction sites
MIT License
3 stars 2 forks source link

Bump API platform #554

Closed famoser closed 2 years ago

famoser commented 2 years ago

Summary: API Platform introduced more type hints, which now prevents a workaround for custom responses. Refactoring this is hard, and might require different API nodes.

Some API nodes (like api/issues/report) do not return a json+ld response, but binary data or another custom format. Due to an implementation detail, it was possible to simply return a Response in the DataProvider. However, the DataProvider now enforces [] as a return type, hence this is no longer possible.

We want to continue to use the DataProvider to reuse the logic around the search parameters. However, we now have to convert the result of the DataConverter into a proper Response at another place.

This mechanism was used for all api nodes which return non-doctrine-entites. For Dtos, it is already fixed on this branch. It only required some serialization config; however the API format slightly changes: As now API Platform does the serialization, the response is in the hydra format. This PR is therefore already a breaking change!

Three special cases exist, with each needing their own workaround:

The current approach uses custom encoders for each of these three nodes. However, this has two problems:

Two ways forward: