-
Notifications
You must be signed in to change notification settings - Fork 693
[WIP] added support for a API versioning #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@lsmith77 any news here ? |
no .. basically the notes in the PR description are still valid, but its a fair bit of work and i haven't been able to work on it further .. |
Needs to be updated to support new Routing architecture. But it should be fairly easy as new arch is freaking clean :-D |
this PR is currently idling unfortunately. but yes thats the idea and we should support this right now already. aka allow setting the serializer version via the View class. regards, On 22.03.2012, at 10:43, Oleg Zinchenko reply@reply.github.com wrote:
|
Hi, any news on this ? (maybe after yesterday's REST talk at symfony live ?) |
no .. there is no progress here aside from some general improvements to better integrate JMSSerializerBundle inside the View class. that BadFaith lib is however slowly, but surely, maturing. |
Any way I can help scoot this along? What's the block exactly? |
the key thing is improving the support fir mime types inside the routing. this is the basis for mime type based versioning. see the link to the BadFaith lib. it seems like Flow3 1.1 will also feature a solution for Accept header negotiation which could serve as an inspiration. |
Any chance we could look at URI versioning for the time being since that will likely be desired by many users? |
personally i am not too interested to work on that. also i dont think doing url based versioning is so hard to do right now already since for that mainly all you need is url pattern based routing which already exists and then you just point to different controllers leveraging inheritance where needed. |
here is what the flow3 guys did for routing with content type negotiation: |
see also symfony/symfony#5711 |
any news |
nope. symfony/symfony#5711 is stalled which seemed like the most promising initiative for a while. |
The version need to be also configured in the |
API versioning still out in the cold? |
yes .. there is some progress in terms of a better content negotiation lib with https://github.com/willdurand/Negotiation but now the big task is left of integrating it within the Routing system /cc @willdurand |
Yup. Don't really know how to that though. I did API versioning once using different routes
I thought about using a proxy controller that would forward the request to the right controller. Example: the routing uses
|
we could maybe do a simple solution that will likely work in more than 80% of the cases. we could have a very early listener that looks at the media type and if it finds there is only one then we attempt to extract a version via a convention (optionally via some callback). this version is set as a request attribute and can therefore be checked via a route requirement. |
Ah I am stupid. Yes, using the routing layer makes sense. |
Actually @meandmymonkey and I thought about a similar approach lately using a listener which does negotiation before the routing using https://github.com/willdurand/Negotiation and setting request attributes. |
anyone want to try and implement it? :) |
It does not work. UrlMatcher don't use attributes.. I think we need a RequestMatcher, but don't know who to inject it into the RouterListener... |
what about using the default then? |
See this: willdurand/BazingaRestExtraBundle@5880f3e Which default? So, the |
i was thinking the route defaults .. but they obviously don't exist yet .. so nevermind. @Tobion .. maybe you can help here? |
Not at all! I just hacked into this bundle as it does not pollute that one, and it made things easier in my test project. This feature MUST be part of the FOSRestBundle. So now that we know that this solution does not work, we need to find a new idea :p |
Should 2 different versions go to 2 different controllers? Shouldn't they both go to the same controller that has something like this: $serializer->serialize($object, 'json', SerializationContext::create()->setVersion($versionFromAcceptHeader)); ? |
@kbond you could do more stuff than changing the "view" of your data between two given versions. |
@kbond https://github.com/kbond Absolutely... two different versions of On Fri, Aug 16, 2013 at 11:43 AM, William Durand
|
Is there anything stable already released about a dynamic versioning support with FosRestBundle and JMSSerializer (for Until and Since annotation support)? |
This PR will eventually fix #12 and #30
For now we will only support media type based versioning (aka no URL based versioning)
See also the following links for details:
http://www.informit.com/articles/article.aspx?p=1566460
http://barelyenough.org/blog/2008/05/versioning-rest-web-services/
basically it looks like the best approach will be to replace the default
RouterListener
by simply registering a request listener that loads before the default one. In this listener we will need to examine the accept headers to determine the format and based on this decide which controller to use.Now the tricky bit is that essentially for a single pattern, we will need to have a list of potential controllers we should examine. I have not yet found a good way to do this. Atm I would be inclined to say the best solution would be to support multiple resources per route:
symfony/symfony#2145
There are also some things still missing (on all inclusive list):
foo/*
priorities (actually consider using the algorithm described here http://httpd.apache.org/docs/2.2/content-negotiation.html)Also note that through out all of this we must be aware that some browsers seem to prefer XHTML or worse XML over HTML:
http://www.gethifi.com/blog/browser-rest-http-accept-headers