content negotiation and versioning
I am looking to document a REST API that uses content negotiation for versioning. In short, the application is made in Jersey 2 and already works. Some endpoints in the API are versioned using content negotiation (e.g., they all started out as 'produces: application/json' but newer endpoints under the same path can have an updated version (like 'produces: application/vnd.myapi.20190110+json') which can have both a different return type and a different set of arguments or payload body.
So, Jersey works fine with
@Path("/endpoint") @Produces("application/json") @POST A doV1(B b)
and
@Path("/endpoint") @Produces("application/vnd.myapi.2+json") @POST X doV2(Y y, Z z)
It understands that both methods reside under /endpoint, but what it accepts as payload and what it returns is based on the Accept header.
I've been trying for a while now to make this visible in myapi.yaml but I can't seem be able to slot this level in a single document. As in, I can define different content types for an endpoint, but I can't define the version, like
paths: /endpoint: post: "application/json": ... "application/vnd.myapi.2+json" ...
where I would be able to define different parameters/arguments and response types per content type
Any ideas how this can be solved? Like, do I need to create a new, complete document, for each change to any endpoint to reflect that the API has changed?
The idea here is that we keep resources at the same path though the payload of the resource itself may change with new versions and not all endpoints update at the same time (e.g., /endpoint could be at application/vnd.myapi.2+json while /somethingelse would be at application/vnd.myapi.5+json), allowing partners to slowly migrate endpoints over time