Skip to content

Review API-Guidelines: consider using content negotiation to request version of response #50

@dshorthouse

Description

@dshorthouse

The JSON API guidelines say little onj topic but there has been considerable discussion elsewhere about best practices for versioning API responses. Some people advocate for versioning to be expressed as part of the URL path (& as suggested in the API-Guidelines here), other people advocate for coordinating this through content negotiation.

I advocate for versioning to be accomplished as part of content negotiation instead of it being baked in the URL. The reason is that endpoints & their routes remain clean. Documentation is easier to maintain. There is no confusion between the model and the resource. Other documents like JSON-LD via other accept headers can be produced without being encumbered by the URL structure that was established for other content/responses. And, deprecation of a version does not have to result in complete loss of paths with a possible need for hard-coded redirects in a route (or elsewhere).

So, requesting specific versions of a response would look like this:

Accept: application/vnd.api+json;version=1.2.1

And the latest version would be like:

Accept: application/vnd.api+json

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions