diff --git a/versions/3.0.md b/versions/3.0.md index 6119777f95..9acd51bc98 100644 --- a/versions/3.0.md +++ b/versions/3.0.md @@ -128,9 +128,8 @@ Field Name | Type | Description openapi | `string` | **Required.** Specifies the OpenAPI Specification version being used. It can be used by tooling Specifications and clients to interpret the version. The structure shall be `major`.`minor`.`patch`, where `patch` versions _must_ be compatible with the existing `major`.`minor` tooling. Typically patch versions will be introduced to address errors in the documentation, and tooling should typically be compatible with the corresponding `major`.`minor` (3.0.*). Patch versions will correspond to patches of this document. info | [Info Object](#infoObject) | **Required.** Provides metadata about the API. The metadata can be used by the clients if needed. hosts | [Hosts Object](#hostsObject) | An array of Host objects which provide `scheme`, `host`, `port`, and `basePath` in an associative manner. -responses | [Responses] paths | [Paths Object](#pathsObject) | **Required.** The available paths and operations for the API. -components | [Components Object](#componentsObject) | An element to hold various schemas for the specification. +components | [Components Object](#componentsObject) | An element to hold various schemas for the specification. security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security schemes are applied for the API as a whole. The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements). Individual operations can override this definition. tags | [[Tag Object](#tagObject)] | A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](#operationObject) must be declared. The tags that are not declared may be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation. @@ -284,7 +283,7 @@ The intention is to put reusable components into a single location, allowing reu Field Pattern | Type | Description ---|:---:|--- | [Definitions Object](#definitionsObject) | A hash containing payload definitions for the specification. - | Responses Definitions Object | Reusable responses objects. + | [Responses Definitions Object](#responsesDefinitionsObject) | Reusable responses objects. | [Parameters Definitions Object](#parametersDefinitionsObject) | An object to hold parameters to be reused across operations. Parameter definitions can be referenced to the ones defined here. | [Response Headers Definitions Object](#responseHeadersDefinitionsObject) | Response headers to reuse across the specification. | [Security Definitions Object](#securityDefinitionsObject) | Security definitions to reuse across the specification. @@ -311,10 +310,10 @@ Field Pattern | Type | Description "get": { "description": "Returns all pets from the system that the user has access to", "responses": { - "200": { + "200": { "description": "A list of pets.", - "representations": { - "application/json": { + "content" : { + "application/json" : { "schema": { "type": "array", "items": { @@ -337,7 +336,7 @@ Field Pattern | Type | Description responses: '200': description: A list of pets. - representations: + content: application/json: schema: type: array @@ -356,8 +355,8 @@ The path itself is still exposed to the documentation viewer but they will not k Field Name | Type | Description ---|:---:|--- $ref | `string` | Allows for an external definition of this path item. The referenced structure MUST be in the format of a [Path Item Object](#pathItemObject). If there are conflicts between the referenced definition and this Path Item's definition, the behavior is *undefined*. -summary | An optional, string summary, intended to apply to all operations in this path. -description | An optional, string description, intended to apply to all operations in this path. +summary| `string` | An optional, string summary, intended to apply to all operations in this path. +description | `string` | An optional, string description, intended to apply to all operations in this path. get | [Operation Object](#operationObject) | A definition of a GET operation on this path. put | [Operation Object](#operationObject) | A definition of a PUT operation on this path. post | [Operation Object](#operationObject) | A definition of a POST operation on this path. @@ -387,7 +386,7 @@ Field Pattern | Type | Description "responses": { "200": { "description": "pet response", - "representations": { + "content": { "*": { "schema": { "type": "array", @@ -400,8 +399,8 @@ Field Pattern | Type | Description }, "default": { "description": "error payload", - "representations": { - "*": { + "content": { + "text/html" : { "schema": { "$ref": "#/definitions/ErrorModel" } @@ -434,16 +433,16 @@ get: responses: '200': description: pet response - representations: - application/json: + content: + *: schema: type: array items: $ref: '#/definitions/Pet' default: description: error payload - representations: - "*": + content: + 'text/html': schema: $ref: '#/definitions/ErrorModel' parameters: @@ -503,28 +502,40 @@ Field Pattern | Type | Description "description": "ID of pet that needs to be updated", "required": true, "type": "string" - }, - { - "name": "name", - "in": "formData", - "description": "Updated name of the pet", - "required": false, - "type": "string" - }, - { - "name": "status", - "in": "formData", - "description": "Updated status of the pet", - "required": false, - "type": "string" } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded":{ + "schema" : { + "type" : "object", + "properties": { + "name" + "description" : "Updated name of the pet", + "type": "string" + "status": + "description" : "Updated status of the pet", + "type": "string" + }, + "required" : ["status"] + } + } + } + }, "responses": { "200": { - "description": "Pet updated." + "description": "Pet updated.", + "content" : { + "application/json" : {}, + "application/xml" : {} + } }, "405": { - "description": "Invalid input" + "description": "Invalid input", + "content" : { + "application/json" : {}, + "application/xml" : {} + } } }, "security": [ @@ -550,21 +561,30 @@ parameters: description: ID of pet that needs to be updated required: true type: string -- name: name - in: formData - description: Updated name of the pet - required: false - type: string -- name: status - in: formData - description: Updated status of the pet - required: false - type: string +responseBody: + content: + 'application/x-www-form-urlencoded': + schema: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + required: + - status responses: '200': description: Pet updated. + content: + 'application/json': {} + 'application/xml': {} '405': description: Invalid input + content: + 'application/json': {} + 'application/xml': {} security: - petstore_auth: - write:pets @@ -609,17 +629,12 @@ Describes a single operation parameter. A unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). -There are five possible parameter types. +There are four possible parameter types. * Path - Used together with [Path Templating](#pathTemplating), where the parameter value is actually part of the operation's URL. This does not include the host or base path of the API. For example, in `/items/{itemId}`, the path parameter is `itemId`. * Query - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`. * Header - Custom headers that are expected as part of the request. -* Form - Used to describe the payload of an HTTP request when either `application/x-www-form-urlencoded`, `multipart/form-data` or both are used as the content type of the request representations. This is the only parameter type that can be used to send files, thus supporting the `file` type. Since form parameters are sent in the payload, they cannot be declared together with a body parameter for the same operation. Form parameters have a different format based on the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4): - * `application/x-www-form-urlencoded` - Similar to the format of Query parameters but as a payload. For example, `foo=1&bar=swagger` - both `foo` and `bar` are form parameters. This is normally used for simple parameters that are being transferred. - * `multipart/form-data` - each parameter takes a section in the payload with an internal header. For example, for the header `Content-Disposition: form-data; name="submit-name"` the name of the parameter is `submit-name`. This type of form parameters is more commonly used for file transfers. - * Cookie - Used to pass a specific cookie value to the API. - For complex parameter schemas, a serialization strategy is required. For all types, a serialization strategy must be declared. @@ -755,7 +770,7 @@ Describes a single request body. Field Name | Type | Description ---|:---:|--- description | `string` | A brief description of the request body. This could contain examples of use. [CommonMark syntax](http://spec.commonmark.org/) can be used for rich text representation. -examples | [Examples Object](#examplesObject) | Examples of the request body, referenced by media type. +content | [Content Object](#contentObject) | The content of the request body. required | `boolean` | Determines if the request body is required in the request. Defaults to `true`. @@ -772,45 +787,52 @@ A request body with a referenced model definition. ```json { "description": "user to add to the system", - "representations": { - "application/json": { + "content" : { + "application/json" : { "schema": { - "$ref": "#/definitions/User" - }, - "example": { - "$ref": "http://foo.bar#/examples/address-example.json" - } + "$ref": "#/definitions/User" + }, + "examples": [ + { "$ref": 'http://foo.bar#/examples/address-example.json'} + ] }, - "application/xml": { - "schema": { + "application/xml" : { + "schema": { "$ref": "#/definitions/User" }, - "example": { - "$ref": "http://foo.bar#/examples/address-example.xml" - } + "examples": [ + { "$ref": 'http://foo.bar#/examples/address-example.xml'} + ] + }, + "text/plain" : { + "examples": [ + { "$ref": 'http://foo.bar#/examples/address-example.txt'} + ] }, "*": { "example": { $ref: "http://foo.bar#/examples/address-example.whatever" } - } } } ``` ```yaml description: user to add to the system -representations: +content: 'application/json': schema: $ref: '#/definitions/User' - example: - $ref: 'http://foo.bar/examples/user-example.json' + examples: + - 'http://foo.bar/examples/user-example.json' 'application/xml': schema: $ref: '#/definitions/User' - example: - $ref: 'http://foo.bar/examples/user-example.xml' + examples: + - 'http://foo.bar/examples/user-example.xml' + 'text/plain': + examples: + - 'http://foo.bar/examples/user-example.txt' '*': schema: $ref: 'http://foo.bar/examples/user-example.whatever' @@ -820,7 +842,7 @@ A body parameter that is an array of string values: ```json { "description": "user to add to the system", - "representations": { + "content": { "text/plain": { "schema": { "type": "array", @@ -836,7 +858,7 @@ A body parameter that is an array of string values: ```yaml description: user to add to the system required: true -representations: +content: text/plain: schema: type: array @@ -844,6 +866,115 @@ representations: type: string ``` + +#### Content Object + +Describes a set of supported content types. A content object can be used in [requestBody](#requestBody) and [response objects](#responseObject). + +Each key in the content object is the media-type of the [Content Type Object](#contentTypeObject). + +##### Content Examples + +```js +"content" : { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "examples": [ + ["Bob","Diane","Mary","Bill"], + [] + ] + }, + "application/xml" : { + "examples" : [ + "", + "" + ] + }, + "text/plain" : { + "Bob,Diane,Mary,Bill", + "" + } +} +``` + +```yaml +content: + 'application/json': + schema: + type: array + items: + type: string + examples: + - + - Bob + - Diane + - Mary + - Bill + - {} + + 'application/xml': + examples: + - "" + - "" + 'text/plain': + examples: + - "Bob,Diane,Mary,Bill" +``` + +#### Content Type Object +Each content type object provides schema and examples for a the media type identified by its key. Content Type objects can be used in a [content object](#contentObject). + +##### Fixed Fields +Field Name | Type | Description +---|:---:|--- +schema | [Schema Object](#schemaObject) | The schema defining the type used for the request body. +examples | [Examples Array](#examplesArray) | Examples of the content type. +example | [Example Object](#exampleObject) | Example of the content type. + +##### Patterned Fields +Field Pattern | Type | Description +---|:---:|--- +^x- | Any | Allows extensions to the OpenAPI Schema. The field name MUST begin with `x-`, for example, `x-internal-id`. The value can be `null`, a primitive, an array or an object. See [Vendor Extensions](#vendorExtensions) for further details. + +##### Content Type Examples + +A content type description. +```js +{ + "application/json": { + "schema": { + "$ref": "#/definitions/Pet" + }, + "examples": [{ + "name" : "Fluffy", + "petType" : "Cat" + }, + { + "name" : "Rover", + "petType" : "Frog" + }] + } +} +``` + +```yaml +application/json: + schema: + $ref: "#/definitions/Pet" + examples: + - name: Fluffy + petType: Cat + - name: Rover + petType: Frog + +``` + + #### Items Object A limited subset of JSON-Schema's items object. @@ -878,7 +1009,7 @@ Field Pattern | Type | Description ##### Items Object Examples -Items must be of type string and have the minimum length of 2 characters: +Items must be of type string and have the minimum length of 2 characters: ```json { @@ -946,8 +1077,8 @@ A 200 response for successful operation and a default response for others (imply { "200": { "description": "a pet to be returned", - "representations": { - "application/json": { + "content" : { + "application/json" : { "schema": { "$ref": "#/definitions/Pet" } @@ -956,8 +1087,8 @@ A 200 response for successful operation and a default response for others (imply }, "default": { "description": "Unexpected error", - "representations": { - "application/json": { + "content" : { + "application/json" : { "schema": { "$ref": "#/definitions/ErrorModel" } @@ -970,14 +1101,14 @@ A 200 response for successful operation and a default response for others (imply ```yaml '200': description: a pet to be returned - representations: - application/json + content: + application/json: schema: $ref: '#/definitions/Pet' default: description: Unexpected error - representations: - '*': + content: + application/json: schema: $ref: '#/definitions/ErrorModel' ``` @@ -990,7 +1121,7 @@ Field Name | Type | Description ---|:---:|--- description | `string` | **Required.** A short description of the response. [CommonMark syntax](http://spec.commonmark.org/) can be used for rich text representation. headers | [Headers Object](#headersObject) | A list of headers that are sent with the response. -examples | [Example Object](#exampleObject) | An example of the response message. +content | [Content Object](#contentObject) | An object containing descriptions of potential response payloads. links | [Links Object](#linksObject) | An object representing operations related to the response payload. @@ -1010,8 +1141,8 @@ Response of an array of a complex type: ```json { "description": "A complex object array response", - "representations": { - "application/json": { + "content" : { + "application/json" : { "schema": { "type": "array", "items": { @@ -1025,9 +1156,9 @@ Response of an array of a complex type: ```yaml description: A complex object array response -representations: +content: application/json: - schema: + schema: type: array items: $ref: '#/definitions/VeryComplexType' @@ -1038,13 +1169,14 @@ Response with a string type: ```json { "description": "A simple string response", - "representations": { - "schema": { - "text/plain": { - "type": "string" + "content" : { + "text/plain" : { + "schema": { + "type": "string" } } } + } ``` @@ -1061,7 +1193,7 @@ Response with headers: ```json { "description": "A simple string response", - "representations": { + "content" : { "text/plain": { "schema": { "type": "string" @@ -1087,7 +1219,7 @@ Response with headers: ```yaml description: A simple string response -representations: +content: text/plain: schema: type: string @@ -1157,7 +1289,7 @@ X-Rate-Limit-Reset: type: integer ``` -#### Example Object +#### Examples Object Allows sharing examples for operation requests and responses. @@ -1166,24 +1298,25 @@ Field Pattern | Type | Description ---|:---:|--- {[media type](#mediaTypes)} | Any | The name of the property MUST be one of the Operation `produces` values (either implicit or inherited). The value SHOULD be an example of what such a response would look like. -##### Example Object Example +##### Examples Array Example -Example request or response for application/json media type of a Pet data type: +Example representation for application/json media type of a Pet data type: +<<<<<<< HEAD ```json -{ - "application/json": { +[ + { "name": "Puma", "type": "Dog", "color": "Black", "gender": "Female", "breed": "Mixed" } -} +] ``` ```yaml -application/json: +- name: Puma type: Dog color: Black @@ -1304,7 +1437,7 @@ paths: responses: 200: description: the user being returned - representations: + content: application/json: schema: type: object @@ -1376,8 +1509,8 @@ paths: required: true responses: 200: - description: The User - representations: + description: The User + content: application/json: schema: $ref: '#/components/definitions/user' @@ -1395,7 +1528,7 @@ paths: responses: 200: description: repositories owned by the supplied user - representations: + content: application/json: schema: type: array @@ -1418,11 +1551,11 @@ paths: required: true responses: 200: - description: The repository - representations: - application/json: - schema: - $ref: '#/components/definitions/repository' + description: The repository + content: + application/json: + schema: + $ref: '#/components/definitions/repository' links: repositoryPullRequests: $ref: '#/components/links/RepositoryPullRequests' @@ -1448,8 +1581,8 @@ paths: responses: 200: description: an array of pull request objects - representations: - application/json: + content: + application/json: schema: type: array items: @@ -1473,10 +1606,10 @@ paths: responses: 200: description: a pull request object - representations: - application/json: - schema: - $ref: '#/components/definitions/pullrequest' + content: + application/json: + schema: + $ref: '#/components/definitions/pullrequest' links: $ref: '#/components/links/PullRequestMerge' /2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge: @@ -1704,14 +1837,22 @@ definitions: # in a request body, note the plural `examples` as the content-type is set to `*`: requestBody: - representations: + content: 'application/json': schema: $ref: '#/definitions/Address' - examples: + examples: - {"foo": "bar"} - {"bar": "baz"} - + 'application/xml': + examples: + - + $ref: 'http://foo.bar#/examples/address-example.xml' + 'text/plain': + examples: + - + $ref: 'http://foo.bar#/examples/address-example.txt' + # in a parameter parameters: @@ -1725,7 +1866,7 @@ definitions: responses: 200: description: your car appointment has been booked - representations: + content: application/json: schema: $ref: '#/definitions/SuccessResponse'