FriendsOfSymfony / FOSRestBundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony
http://symfony.com/doc/master/bundles/FOSRestBundle/index.html
MIT License
2.8k stars 703 forks source link

Ability to disable fos rest array normalization for certain paths #1660

Open koemeet opened 7 years ago

koemeet commented 7 years ago

When using the FOSOAuthServerBundle in combination with FOSRest you end up with an issue that the array normalizer converts an token request from underscored to camelcase. Because of this the token request will fail, since the OAuth2 server needs the parameters to be underscored.

To fix this I tried doing this:

fos_rest:
    format_listener:
        rules:
            - { path: '^/api/oauth/token', stop: true } # this doesn't work
            - { path: '^/api', priorities: ['json'], fallback_format: json, prefer_extension: false }
            - { path: '^/', stop: true }

Is there currently a good way to solve this? It should be possible to disable the request manipulation that fos rest does for certain requests.

xabbuh commented 7 years ago

Does it help to define zones so that the OAuth routes are not covered by any zone?

koemeet commented 7 years ago

@xabbuh My oauth routes live inside /api, for now I solved it by removing the array normalization. But I am sure that more people stumble upon this issue.