-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Description
This is a proposal for OpenAPI.next.
One of the foundations of REST are media types (inherited from MIME, such as text/html). A media type defines how a resource representation might look like, and what it means.
For JSON REST APIs described with Swagger, one possible way of using media types is to declare anything as application/json – because actually every message is in this format. But of course our API will not accept/produce just any JSON document – we have schema definitions which restrict what can be in a response, or in a body parameter, and whose descriptions also give some meaning to the fields of the JSON object. In effect, we are creating a kind of media type here.
In my team, we actually define a media type for each schema (e.g. application/x.zalando.wholesale.warehouse+json in one of my recent APIs), and use it also for the Content-Type and Accept headers (and document it in the produces/consumes properties of the operations).
Could we make it possible to formally name the media type belonging to a schema?
First, this is just documentation.
But then this could also be used to enable Content-Negotiation (in #146), by linking it to the consumes/produces properties of an operation.