Current API-Platform Frustration

Posted:

When API-Platform works, it works beautifully. But, when something goes amiss, it can be a bear to debug.

This week, we slammed into a bug where if our entities have a

__clone

function that intentionally nulls out the entity's id field, API-Platform would blow up. I figured out a way to decorate the event listener to get around that, but ended up downgrading for now for other reasons.

But, my real frustration is with trying to configure the OpenAPI docs to notify me when the JWT token expires. OpenAPI offers a

responseInterceptor

that would allow me to see that the "Try It Out" execution had returned a 401 status, and let me prompt the user to get a new token.

The responseInterceptor is just a JavaScript function that lets me check the response, and then handle the 401 status.

But, API-Platform has me configure the options in a yaml file, and it seems to wrap the entire JavaScript function in a string. I'm still playing with trying to inject my handler function in somehow, but it's been a stumper thus far.