Skip to content

Commit e9b31f2

Browse files
authored
Merge pull request OAI#893 from OAI/issue-589-examples
Examples documentation Merging per @OAI/tdc call
2 parents 8d012e6 + a452704 commit e9b31f2

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

versions/3.0.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,13 @@ Field Name | Type | Description
764764
<a name="parameterExplode"></a>explode | `boolean` | When this is true, parameter values of type `array` or `object` generate seperate parameters for each value of the array, or key-value-pair of the map. For other types of parameters this property has no effect. The default value is false.
765765
<a name="parameterAllowReserved"></a>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`.
766766
<a name="parameterSchema"></a>schema | [Schema Object](#schemaObject) | The schema defining the type used for the parameter.
767+
<a name="parameterExamples"></a>examples | [Examples Array](#examplesArray) | Examples of the content type. Each example in the Examples Array must 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 will _override_ the example provided by the schema.
768+
<a name="parameterExample"></a>example | [Example Object](#exampleObject) | Example of the content type. The example object _must_ 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 will _override_ the example provided by the the schema.
767769

768-
For more complex scenarios a `content` object can be used to define the media-type and schema of the parameter.
770+
For more complex scenarios a `content` object can be used to define the media-type
771+
and schema of the parameter. This option is mutually exclusive with the simple scenario
772+
above. When `example` or `examples` are provided in conjunction with the `schema` object,
773+
the example must follow the prescribed serialization strategy for the parameter.
769774

770775
Field Name | Type | Description
771776
---|:---:|---
@@ -1062,8 +1067,8 @@ Each content type object provides schema and examples for a the media type ident
10621067
Field Name | Type | Description
10631068
---|:---:|---
10641069
<a name="contentTypeSchema"></a>schema | [Schema Object](#schemaObject) | The schema defining the type used for the request body.
1065-
<a name="contentTypeExamples"></a>examples | [Examples Array](#examplesArray) | Examples of the content type.
1066-
<a name="contentTypeExample"></a>example | [Example Object](#exampleObject) | Example of the content type.
1070+
<a name="contentTypeExamples"></a>examples | [Examples Array](#examplesArray) | Examples of the content type. Each example in the Examples Array must be in the correct format as specified in the _content_ type. The `examples` object is mutually exclusive to the `example` object. Furthermore, if referencing a `schema` which contains an example, the `examples` value will _override_ the example provided by the schema.
1071+
<a name="contentTypeExample"></a>example | [Example Object](#exampleObject) | Example of the content type. The example object _should_ be in the correct format as specified in the _content_ type. The `example` object is mutually exclusive to the `examples` object. Furthermore, if referencing a `schema` which contains an example, the `example` value will _override_ the the example provided by the schema.
10671072

10681073
##### Patterned Fields
10691074
Field Pattern | Type | Description
@@ -1096,10 +1101,10 @@ application/json:
10961101
schema:
10971102
$ref: "#/definitions/Pet"
10981103
examples:
1104+
# converted directly from YAML to JSON
10991105
- name: Fluffy
11001106
petType: Cat
1101-
- name: Rover
1102-
petType: Frog
1107+
- {"name": "Rover", "petType": "Frog"}
11031108
11041109
```
11051110

@@ -2077,13 +2082,15 @@ description: Pets operations
20772082

20782083
#### <a name="examplesObject"></a>Examples Object
20792084

2080-
Anywhere an `example` may be given, allow a $ref object.
2081-
This does mean that `example`, structurally, can be either a string primitive or an object, like `additionalProperties`.
2085+
Anywhere an `example` may be given, a JSON Reference may be used, with the
2086+
explicit restriction that examples having a JSON format with object named
2087+
`$ref` are not allowed. This does mean that `example`, structurally, can be
2088+
either a string primitive or an object, similar to `additionalProperties`.
20822089

2083-
In locations where the field being provided an `example` is a scalar value _or_ has it's content-type definition determined by a higher-level construct (a response payload, for example, uses the `produces` attribute to select the correct message format), the plural `examples` shall be used, and the payload format be specified as a key to the example.
2084-
2085-
In all cases, the payload is expected to be compatible with the type schema for the value that it is accompanying.
2086-
Tooling Specifications may choose to validate compatibility automatically, and reject the example value(s) if they are not compatible.
2090+
In all cases, the payload is expected to be compatible with the type schema
2091+
for the value that it is accompanying. Tooling implementations may choose to
2092+
validate compatibility automatically, and reject the example value(s) if they
2093+
are not compatible.
20872094

20882095
```yaml
20892096
# in a model
@@ -2105,22 +2112,21 @@ definitions:
21052112
- {"bar": "baz"}
21062113
'application/xml':
21072114
examples:
2108-
-
2109-
$ref: 'http://foo.bar#/examples/address-example.xml'
2115+
- $ref: 'http://foo.bar#/examples/address-example.xml'
21102116
'text/plain':
21112117
examples:
2112-
-
2113-
$ref: 'http://foo.bar#/examples/address-example.txt'
2118+
- $ref: 'http://foo.bar#/examples/address-example.txt'
21142119

21152120
# in a parameter
21162121

21172122
parameters:
2118-
- name: 'zip'
2123+
- name: 'zipCode'
21192124
in: 'query'
2120-
type: 'string'
2121-
format: 'zip'
2122-
example:
2123-
$ref: 'http://foo.bar#/examples/zip-example'
2125+
schema:
2126+
type: 'string'
2127+
format: 'zip-code'
2128+
example:
2129+
$ref: 'http://foo.bar#/examples/zip-example'
21242130
# in a response, note the plural `examples`:
21252131
responses:
21262132
200:

0 commit comments

Comments
 (0)