This is a proposal to address a number of the issues aggregated under #560.
Specifically:
The basic premise is that OpenAPI models operations that interact with resources using a specific HTTP method. The interaction involves sending representations and retrieving those representations. A single operation may support different representations identified by a media-type.
Consider the following GET operation that returns one of two representations.
get:
description: Returns pets based on IDsummary: Find pets by IDoperationId: getPetsByIdresponses:
'200':
description: pet responserepresentations: application/json:
schema:
type: arrayitems:
$ref: '#/definitions/Pet'text/html:
default:
description: error payloadrepresentations: application/json:
schema:
$ref: '#/definitions/ErrorModel'text/html:
parameters:
- name: idin: pathdescription: ID of pet to userequired: truetype: arrayitems:
type: stringcollectionFormat: csv
The description and headers properties of a response object stay, but the schema and examples move under the representation object that is defined as a property of the representations object. The examples property will need to change to either an array of objects, or a single object because all examples would be for the same media type.
By defining the supported media types on the representations object, there is no longer a need for a produces array.
It is important to note that different representations should not be semantically different when accompanied with the same class of status code. A request to a resource should always the same thing (for some unfortunately nebulous definition of thing). However, the syntax of that representation may be different and the amount of information contained may be different, but from a consumer's perspective. it is same concept, regardless of the representation. This is why the description property is the same for all representations.
The following is an example of a POST request that may send a HTML form as a request body.
tags:
- petsummary: Updates a pet in the store with form datadescription: ""operationId: updatePetWithFormparameters:
- name: petIdin: pathdescription: ID of pet that needs to be updatedrequired: truetype: stringrequestbody:
description: Updated status of the petrequired: falserepresentations:
application/x-www-form-urlencoded:
schema: properties:
name: description: Updated name of the pettype: stringstatus:
description: Updated status of the pettype: stringrequired: - statusresponses:
'200':
description: Pet updated.representations: application/json: application/xml:
'405':
description: Invalid inputrepresentations:
application/json: application/xml: security:
- petstore_auth:
- write:pets
- read:pets
The structure of the HTML form that is passed as a body are no longer intermixed with the URI parameters and are described by a schema object in the representation object. This enables us to support all the different form related media types. There would no longer be any need for the formData parameter type and no need for the consumes array.
One open question is whether there is a value to allowing representation objects (media type, schema and examples) to be defined within the reusable components section.
This is a proposal to address a number of the issues aggregated under #560.
Specifically:
The basic premise is that OpenAPI models
operationsthat interact withresourcesusing a specific HTTP method. The interaction involves sendingrepresentationsand retrieving thoserepresentations. A singleoperationmay support differentrepresentationsidentified by amedia-type.Consider the following
GEToperation that returns one of tworepresentations.The
descriptionandheadersproperties of a response object stay, but theschemaandexamplesmove under therepresentation objectthat is defined as a property of therepresentations object. Theexamplesproperty will need to change to either an array of objects, or a single object because all examples would be for the same media type.By defining the supported media types on the
representations object, there is no longer a need for aproducesarray.It is important to note that different
representationsshould not be semantically different when accompanied with the same class of status code. A request to a resource should always the same thing (for some unfortunately nebulous definition of thing). However, the syntax of that representation may be different and the amount of information contained may be different, but from a consumer's perspective. it is same concept, regardless of the representation. This is why thedescriptionproperty is the same for all representations.The following is an example of a POST request that may send a HTML form as a request body.
The structure of the HTML form that is passed as a body are no longer intermixed with the URI parameters and are described by a
schema objectin therepresentation object. This enables us to support all the different form related media types. There would no longer be any need for theformDataparameter type and no need for theconsumesarray.One open question is whether there is a value to allowing
representation objects (media type, schema and examples) to be defined within the reusablecomponentssection.