Open eiosca opened 6 years ago
+1 Same problem, can't get API versioning to work with Symfony 4.1. Any solution for this?
+1 I have the same problem. It is specify in the Symfony doc that the version is automatically set to the context of the view returned in the controller (by using View::create() or $this->view()) (https://symfony.com/doc/master/bundles/FOSRestBundle/versioning.html#configure-fosrestbundle-to-use-the-api-versioning).
I have checking the context and it seems that the value of the version is always null. If I specify the version value manually, it is working. I have the attributes for my newest version and not for the old ones.
+1
In my case, I'm using the X-Accept-Version
solution. The parsing procedure seems works when I'm sending v2
. But the @Version
annotation seems don't. (I set @Version("v1"), it shouldn't visit the API for I'm supplying v2
)
But set the condition in the route file works:
api:
resource: ../../src/Controller/Api/
prefix: /api
type: annotation
condition: "request.attributes.get('version') == 'v1'"
@yarcowang @Version
only works if your controller extends the AbstractFOSRestController
, is it the case?
@iMac0de is the version set in the request attributes?
@GuilhemN Still can not make it work even after I changed it to use AbstractFOSRestController
. And the doc at the bottom doc seems not right. I'm following the doc, it didn't extend other controller.
Hi, Got the same issue. I tried tu extend my controller with AbstractFOSRestController but no effect. I tried specify manually the context like @iMac0de said and it's working good (thanks a lot man !) Is anyone has another solution ?
Hi, I don't understand why the versioning not working. Could you help me please?
Version: "friendsofsymfony/rest-bundle": "^2.2",
The config file:
In my entity i try to set a condition on a field like that:
I try request with a header like that:
And
But, nothing work. I always receive the field whatever i'm doing. like he don't check media_type.
Thk's for your help.