Skip to content

Commit dc9531f

Browse files
committed
Adding information for version functionality
I had a quite hard time to collect informations and make working the version functionality of the bundle. I think it requires more detailed informations. Here is my proposal, feel free to retouch my input to better english / informations :)
1 parent 035cdc4 commit dc9531f

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

Resources/doc/format_listener.rst

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,35 @@ The matched version is set as a Request attribute with the name ``version``,
124124
and when using JMS serializer it is also set as an exclusion strategy
125125
automatically in the ``ViewHandler``.
126126

127-
See `this JMS Serializer article`_ for details.
127+
To make the version mechanism working :
128+
129+
1 - The client must pass the requested version in his header like this :
130+
131+
.. code-block:: yaml
132+
133+
Accept:application/json;version=1.0
134+
135+
2 - You must have declared the version value in your config, otherwise it won't be catched :
136+
137+
.. code-block:: yaml
138+
139+
fos_rest:
140+
view:
141+
mime_types:
142+
json: ['application/json', 'application/json;version=1.0', 'application/json;version=1.1']
143+
144+
3 - You should have tagged your entities with version information (@Since, @Until ...)
145+
146+
See `this JMS Serializer article`_ for details about versioning objects.
128147

129148
.. _`this JMS Serializer article`: http://jmsyst.com/libs/serializer/master/cookbook/exclusion_strategies#versioning-objects
149+
150+
That's it, it should work now.
151+
152+
If you have to verify if the version is correctly catched you can use something like :
153+
154+
.. code-block:: php
155+
156+
if($this->container->get('fos_rest.version_listener')) {
157+
print $this->container->get('fos_rest.version_listener')->getVersion();
158+
}

0 commit comments

Comments
 (0)