You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
As we prepare to release version v2.0 Beta 1 we still need to add versioning to the core endpoints. Also, as noted by @danielbachhuber we may want to consider versioning our filters as well: #937 (comment)
Does anyone have an idea of how we can add versioning to our route registrations?
we still need to add versioning to the core endpoints
We should discuss the purpose of versioning too. To me, having versioned routes set the expectation responses will be consistent. Given we're letting plugin authors do whatever, responses can't ever be expected to be consistent. I'm not sure what versioned routes are intended to solve.
We need to add support for versioning to our endpoint registration function so that plugins can version their own endpoints. Example: /gravity-forms/v2.3/forms
Having endpoint versions allows us to make breaking changes with new API versions.
To the point of not being able to version because we can't expect responses to be consistent due to plugins changing data around.
I understand what you mean. But I think we don't need to get too carried away with being too literal. We've had some discussions like this in the past about trying to police what devs to, and it's not a good idea. What we can and should do is police ourselves, and give devs the ability to do the same. Worrying about the possibility of a plugin breaking the site (or in this case versioning of the API) isn't a super good use of our time. Doing the right thing for ourselves and providing others the tools to walk in our footsteps certainly is.
Agreed with @apokalyptik. The version number is a strong indicator of what to expect (i.e. "which API handling class should I use?"), but clients still need to be robust enough to know the response might change independently of that.
With regards to versioning internally: it's always been my intent to change the prefixes on everything for v2. This sounds like a good time to do it. V2 can use WP_REST_ for class names, and rest_ for filters. If/When we do a v3, we can pick a different prefix then, possibly just WP_REST_V3 and rest_v3, but I don't think we should be too tied to that.
Versioning externally: we decided back at WCNYC to add the version to the URLs. Originally, we thought this would be a separate parameter to register_api_route, but we changed our thinking on enforcing this permanently, as it can encourage copy-and-paste antipatterns. Instead, the plan is that you can handle versioning inside the "namespace" parameter, so we basically just need to change our code from register_api_route( 'wp', ... to register_api_route( 'wp/v2', ... and we should be OK.
Activity
danielbachhuber commentedon Apr 19, 2015
We should discuss the purpose of versioning too. To me, having versioned routes set the expectation responses will be consistent. Given we're letting plugin authors do whatever, responses can't ever be expected to be consistent. I'm not sure what versioned routes are intended to solve.
rachelbaker commentedon Apr 20, 2015
apokalyptik commentedon Apr 20, 2015
To the point of not being able to version because we can't expect responses to be consistent due to plugins changing data around.
I understand what you mean. But I think we don't need to get too carried away with being too literal. We've had some discussions like this in the past about trying to police what devs to, and it's not a good idea. What we can and should do is police ourselves, and give devs the ability to do the same. Worrying about the possibility of a plugin breaking the site (or in this case versioning of the API) isn't a super good use of our time. Doing the right thing for ourselves and providing others the tools to walk in our footsteps certainly is.
rmccue commentedon Apr 20, 2015
Agreed with @apokalyptik. The version number is a strong indicator of what to expect (i.e. "which API handling class should I use?"), but clients still need to be robust enough to know the response might change independently of that.
With regards to versioning internally: it's always been my intent to change the prefixes on everything for v2. This sounds like a good time to do it. V2 can use
WP_REST_for class names, andrest_for filters. If/When we do a v3, we can pick a different prefix then, possibly justWP_REST_V3andrest_v3, but I don't think we should be too tied to that.Versioning externally: we decided back at WCNYC to add the version to the URLs. Originally, we thought this would be a separate parameter to
register_api_route, but we changed our thinking on enforcing this permanently, as it can encourage copy-and-paste antipatterns. Instead, the plan is that you can handle versioning inside the "namespace" parameter, so we basically just need to change our code fromregister_api_route( 'wp', ...toregister_api_route( 'wp/v2', ...and we should be OK.danielbachhuber commentedon Apr 28, 2015
Do we want to do a filter pass here too? Seems like there's a fair amount of low-hanging fruit in this regard.