diff --git a/versions/3.0.md b/versions/3.0.md
index fd613139ee..c100e27b2b 100644
--- a/versions/3.0.md
+++ b/versions/3.0.md
@@ -58,7 +58,6 @@ Additional utilities can also take advantage of the resulting files, such as tes
- [Link Parameters Object](#linkParametersObject)
- [Header Object](#headerObject)
- [Tag Object](#tagObject)
- - [Examples Object](#examplesObject)
- [Reference Object](#referenceObject)
- [Schema Object](#schemaObject)
- [XML Object](#xmlObject)
@@ -680,7 +679,7 @@ This object can be extended with [Specification Extensions](#specificationExtens
"200": {
"description": "pet response",
"content": {
- "*": {
+ "*/*": {
"schema": {
"type": "array",
"items": {
@@ -727,7 +726,7 @@ get:
'200':
description: pet response
content:
- *:
+ '*/*' :
schema:
type: array
items:
@@ -938,8 +937,8 @@ Field Name | Type | Description
explode | `boolean` | When this is true, parameter values of type `array` or `object` generate separate parameters for each value of the array, or key-value-pair of the map. For other types of parameters this property has no effect. When [`style`](#parameterStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`.
allowReserved | `boolean` | Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. This property only applies to parameters with an `in` value of `query`. The default value is `false`.
schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject)] | The schema defining the type used for the parameter.
-examples | [[Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the content type. Each example in the Examples array SHOULD be in the correct format as specified parameter encoding. The `examples` object is mutually exclusive to the `example` object. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema.
-example | [Example Object](#exampleObject) \| [Reference Object](#referenceObject) | Example of the content type. The example object SHOULD be in the correct format as specified in the parameter encoding. The `example` object is mutually exclusive to the `examples` object. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the example provided by the schema.
+example | Any | Example of the media type. The example SHOULD match the specified schema and encoding properties if present. The `example` object is mutually exclusive to the `examples` object. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the the example provided by the schema. To represent examples of media types that cannot naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary.
+examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the media type. Each example SHOULD contain a value in the correct format as specified in the parameter encoding. The `examples` object is mutually exclusive to the `example` object. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema.
For more complex scenarios a [Content Object](#contentObject) can be used to define the media type
and schema of the parameter. This option is mutually exclusive with the simple scenario
@@ -1128,20 +1127,38 @@ A request body with a referenced model definition.
"schema": {
"$ref": "#/components/schemas/User"
},
- "examples": [ "http://foo.bar/examples/user-example.json" ]
+ "examples": {
+ "user" : {
+ "summary": "User Example",
+ "externalValue": "http://foo.bar/examples/user-example.json"
+ }
+ }
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/User"
},
- "examples": [ "http://foo.bar/examples/user-example.xml" ]
+ "examples": {
+ "user" : {
+ "summary": "User example in XML",
+ "externalValue": "http://foo.bar/examples/user-example.xml"
+ }
+ }
},
"text/plain": {
- "examples": [ "http://foo.bar/examples/user-example.txt" ]
+ "examples": {
+ "user" : {
+ "summary": "User example in Plain text",
+ "externalValue": "http://foo.bar/examples/user-example.txt"
+ }
+ }
},
"*/*": {
- "example": {
- "$ref": "http://foo.bar/examples/user-example.whatever"
+ "examples": {
+ "user" : {
+ "summary": "User example in other format",
+ "externalValue": "http://foo.bar/examples/user-example.whatever"
+ }
}
}
}
@@ -1155,18 +1172,26 @@ content:
schema:
$ref: '#/components/schemas/User'
examples:
- - 'http://foo.bar/examples/user-example.json'
+ user:
+ summary: User Example
+ externalValue: 'http://foo.bar/examples/user-example.json'
'application/xml':
schema:
$ref: '#/components/schemas/User'
examples:
- - 'http://foo.bar/examples/user-example.xml'
+ user:
+ summary: User Example in XML
+ externalValue: 'http://foo.bar/examples/user-example.xml'
'text/plain':
examples:
- - 'http://foo.bar/examples/user-example.txt'
+ user:
+ summary: User example in text plain format
+ externalValue: 'http://foo.bar/examples/user-example.txt'
'*/*':
- example:
- $ref: 'http://foo.bar/examples/user-example.whatever'
+ examples:
+ user:
+ summary: User example in other format
+ externalValue: 'http://foo.bar/examples/user-example.whatever'
```
A body parameter that is an array of string values:
@@ -1216,22 +1241,40 @@ Each key in the Content Object is the media type of the [Media Type Object](#med
"type": "string"
}
},
- "examples": [
- ["Bob","Diane","Mary","Bill"],
- []
- ]
+ "examples": {
+ "list": {
+ "summary": "List of names",
+ "value" : ["Bob","Diane","Mary","Bill"]
+ },
+ "empty":{
+ "summary": "Empty List",
+ "value": []
+ }
+ }
},
"application/xml": {
- "examples": [
- "",
- ""
- ]
+ "examples": {
+ "list": {
+ "summary": "List of names",
+ "value": ""
+ },
+ "empty": {
+ "summary":"Empty",
+ "value": ""
+ }
+ }
},
"text/plain": {
- "examples": [
- "Bob,Diane,Mary,Bill",
- ""
- ]
+ "examples": {
+ "list": {
+ "summary": "List of names",
+ "value": "Bob,Diane,Mary,Bill"
+ },
+ "empty": {
+ "summary": "Empty",
+ "value" : ""
+ }
+ }
}
}
```
@@ -1244,21 +1287,33 @@ content:
items:
type: string
examples:
- -
- - Bob
- - Diane
- - Mary
- - Bill
- - {}
+ list:
+ summary: List of Names
+ value:
+ - Bob
+ - Diane
+ - Mary
+ - Bill
+ empty:
+ summary: Empty
+ value: {}
'application/xml':
examples:
- - ""
- - ""
+ list:
+ summary: List of names
+ value: ""
+ empty:
+ summmary: Empty list
+ value: ""
'text/plain':
examples:
- - "Bob,Diane,Mary,Bill"
- - ""
+ list:
+ summary: List of names
+ value: "Bob,Diane,Mary,Bill"
+ empty:
+ summary: Empty
+ value: ""
```
#### Media Type Object
@@ -1267,9 +1322,9 @@ Each Media Type Object provides schema and examples for a the media type identif
##### Fixed Fields
Field Name | Type | Description
---|:---:|---
-schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject)] | The schema defining the type used for the request body.
-examples | [[Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the media type. Each example in the Examples array SHOULD be in the correct format as specified in the media type. The `examples` object is mutually exclusive to the `example` object. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema.
-example | [Example Object](#exampleObject) \| [Reference Object](#referenceObject) | Example of the media type. The example object SHOULD be in the correct format as specified in the media type. The `example` object is mutually exclusive to the `examples` object. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the example provided by the schema.
+schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the request body.
+example | Any | Example of the media type. The example object SHOULD be in the correct format as specified in the media type. The `example` object is mutually exclusive to the `examples` object. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the the example provided by the schema.
+examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the media type. Each example object SHOULD match the media type and specified schema if present. The `examples` object is mutually exclusive to the `example` object. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema.
encoding | [Encoding Object](#encodingObject) | Encoding of the media type. The encoding object SHOULD only apply to `requestBody` objects when the content type is `multipart`.
This object can be extended with [Specification Extensions](#specificationExtensions).
@@ -1282,14 +1337,32 @@ This object can be extended with [Specification Extensions](#specificationExtens
"schema": {
"$ref": "#/components/schemas/Pet"
},
- "examples": [{
- "name": "Fluffy",
- "petType": "Cat"
- },
- {
- "name": "Rover",
- "petType": "Frog"
- }]
+ "examples": {
+ "cat" : {
+ "summary": "An example of a cat",
+ "value":
+ {
+ "name": "Fluffy",
+ "petType": "Cat",
+ "color": "White",
+ "gender": "male",
+ "breed": "Persian"
+ }
+ },
+ "dog": {
+ "summary": "An example of a dog with a cat's name",
+ "value" : {
+ "name": "Puma",
+ "petType": "Dog",
+ "color": "Black",
+ "gender": "Female",
+ "breed": "Mixed"
+ },
+ "frog": {
+ "$ref": "#/components/examples/frog-example"
+ }
+ }
+ }
}
}
```
@@ -1299,11 +1372,24 @@ application/json:
schema:
$ref: "#/components/schemas/Pet"
examples:
- # converted directly from YAML to JSON
- - name: Fluffy
- petType: Cat
- - {"name": "Rover", "petType": "Frog"}
-
+ cat:
+ summary: An example of a cat
+ value:
+ name: Fluffy
+ petType: Cat
+ color: White
+ gender: male
+ breed: Persian
+ dog:
+ summary: An example of a dog with a cat's name
+ value:
+ name: Puma
+ petType: Dog
+ color: Black
+ gender: Female
+ breed: Mixed
+ frog:
+ $ref: "#/components/examples/frog-example"
```
##### Considerations for file uploads
@@ -1822,30 +1908,80 @@ X-Rate-Limit-Reset:
#### Example Object
-Allows sharing examples for operation requests and responses. This object can either be a freeform object, array or primitive value. To represent examples of media types that cannot naturally represented in the OpenAPI definition, a string value can be used to contain the example with escaping where necessary.
+##### Fixed Fields
+Field Name | Type | Description
+---|:---:|---
+summary | `string` | Short description for the example.
+description | `string` | Long description for the example.
+value | Any | Embedded literal example. The `value` field and `externalValue` field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary.
+externalValue | `string` | A URL that points to the literal example. This provides the ability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive.
-##### Example Example
+This object can be extended with [Specification Extensions](#specificationExtensions).
-Example representation for application/json media type of a Pet data type:
+In all cases, the example value is expected to be compatible with the type schema
+for the value that it is accompanying. Tooling implementations MAY choose to
+validate compatibility automatically, and reject the example value(s) if they
+are not compatible.
-```json
- {
- "name": "Puma",
- "type": "Dog",
- "color": "Black",
- "gender": "Female",
- "breed": "Mixed"
- }
-```
+##### Example Object Example
```yaml
+# in a model
+schemas:
+ properties:
+ name:
+ type: string
+ examples:
+ name:
+ $ref: http://example.org/petapi-examples/openapi.json#/components/examples/name-example
+
+# in a request body:
+ requestBody:
+ content:
+ 'application/json':
+ schema:
+ $ref: '#/components/schemas/Address'
+ examples:
+ foo:
+ summary: A foo example
+ value: {"foo": "bar"}
+ bar:
+ summary: A bar example
+ value: {"bar": "baz"}
+ 'application/xml':
+ examples:
+ xmlExample:
+ summary: This is an example in XML
+ externalValue: 'http://example.org/examples/address-example.xml'
+ 'text/plain':
+ examples:
+ textExample:
+ summary: This is a text example
+ externalValue: 'http://foo.bar/examples/address-example.txt'
-name: Puma
-type: Dog
-color: Black
-gender: Female
-breed: Mixed
+# in a parameter
+ parameters:
+ - name: 'zipCode'
+ in: 'query'
+ schema:
+ type: 'string'
+ format: 'zip-code'
+ examples:
+ zip-example:
+ $ref: '#/components/examples/zip-example'
+
+# in a response
+ responses:
+ 200:
+ description: your car appointment has been booked
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/SuccessResponse'
+ examples:
+ confirmation-success:
+ $ref: '#/components/examples/confirmation-success'
```
#### Links Object
@@ -2391,7 +2527,6 @@ schemas:
- $ref: 'http://foo.bar#/examples/address-example.txt'
# in a parameter
-
parameters:
- name: 'zipCode'
in: 'query'
@@ -2517,8 +2652,7 @@ Field Name | Type | Description
writeOnly | `boolean` | Relevant only for Schema `"properties"` definitions. Declares the property as "write only". This means that it MAY be sent as part of a request but SHOULD NOT be sent as part of the response. If property is marked as `writeOnly` being `true` and is in the `required` list, the `required` will take effect on the request only. A property MUST NOT be marked as both `readOnly` and `writeOnly` being `true`. Default value is `false`.
xml | [XML Object](#xmlObject) | This MAY be used only on properties schemas. It has no effect on root schemas. Adds Additional metadata to describe the XML representation format of this property.
externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this schema.
-example | Any | A free-form property to include an example of an instance for this schema.
-examples | Any | An array of free-formed properties to include examples for this schema.
+example | Any | A free-form property to include an example of an instance for this schema. To represent examples that cannot naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary.
deprecated | `boolean` | Specifies that a schema is deprecated and SHOULD be transitioned out of usage.
This object can be extended with [Specification Extensions](#specificationExtensions).
@@ -2672,51 +2806,6 @@ example:
id: 1
```
-###### Model with Examples
-
-```json
-{
- "type": "object",
- "properties": {
- "id": {
- "type": "integer",
- "format": "int64"
- },
- "name": {
- "type": "string"
- }
- },
- "required": [
- "name"
- ],
- "examples": [
- {
- "name": "Puma",
- "id": 1
- }, {
- "name": "Ferguson",
- "id": 2
- }]
-}
-```
-
-```yaml
-type: object
-properties:
- id:
- type: integer
- format: int64
- name:
- type: string
-required:
-- name
-examples:
- - name: Puma
- id: 1
- - name: Ferguson
- id: 2
-```
-
###### Models with Composition
```json