Skip to content
This repository was archived by the owner on Jul 1, 2021. It is now read-only.

Commit 6bcbde9

Browse files
committed
Updated examples throughout spec
1 parent 3a11cc5 commit 6bcbde9

File tree

1 file changed

+117
-46
lines changed

1 file changed

+117
-46
lines changed

versions/3.0.md

Lines changed: 117 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,20 +1128,38 @@ A request body with a referenced model definition.
11281128
"schema": {
11291129
"$ref": "#/components/schemas/User"
11301130
},
1131-
"examples": [ "http://foo.bar/examples/user-example.json" ]
1131+
"examples": {
1132+
"user" : {
1133+
"summary": "User Example",
1134+
"valueUrl": "http://foo.bar/examples/user-example.json"
1135+
}
1136+
}
11321137
},
11331138
"application/xml": {
11341139
"schema": {
11351140
"$ref": "#/components/schemas/User"
11361141
},
1137-
"examples": [ "http://foo.bar/examples/user-example.xml" ]
1142+
"examples": {
1143+
"user" : {
1144+
"summary": "User example in XML",
1145+
"valueUrl": "http://foo.bar/examples/user-example.xml"
1146+
}
1147+
}
11381148
},
11391149
"text/plain": {
1140-
"examples": [ "http://foo.bar/examples/user-example.txt" ]
1150+
"examples": {
1151+
"user" : {
1152+
"summary": "User example in Plain text",
1153+
"valueUrl": "http://foo.bar/examples/user-example.txt"
1154+
}
1155+
}
11411156
},
11421157
"*/*": {
1143-
"example": {
1144-
"$ref": "http://foo.bar/examples/user-example.whatever"
1158+
"examples": {
1159+
"user" : {
1160+
"summary": "User example in other format",
1161+
"valueUrl": "http://foo.bar/examples/user-example.whatever"
1162+
}
11451163
}
11461164
}
11471165
}
@@ -1155,18 +1173,26 @@ content:
11551173
schema:
11561174
$ref: '#/components/schemas/User'
11571175
examples:
1158-
- 'http://foo.bar/examples/user-example.json'
1176+
user:
1177+
summary: User Example
1178+
valueUrl: 'http://foo.bar/examples/user-example.json'
11591179
'application/xml':
11601180
schema:
11611181
$ref: '#/components/schemas/User'
11621182
examples:
1163-
- 'http://foo.bar/examples/user-example.xml'
1183+
user:
1184+
summary: User Example in XML
1185+
valueUrl: 'http://foo.bar/examples/user-example.xml'
11641186
'text/plain':
11651187
examples:
1166-
- 'http://foo.bar/examples/user-example.txt'
1188+
user:
1189+
summary: User example in text plain format
1190+
valueUrl: 'http://foo.bar/examples/user-example.txt'
11671191
'*/*':
1168-
example:
1169-
$ref: 'http://foo.bar/examples/user-example.whatever'
1192+
examples:
1193+
user:
1194+
summary: User example in other format
1195+
valueUrl: 'http://foo.bar/examples/user-example.whatever'
11701196
```
11711197

11721198
A body parameter that is an array of string values:
@@ -1216,22 +1242,40 @@ Each key in the Content Object is the media type of the [Media Type Object](#med
12161242
"type": "string"
12171243
}
12181244
},
1219-
"examples": [
1220-
["Bob","Diane","Mary","Bill"],
1221-
[]
1222-
]
1245+
"examples": {
1246+
"list": {
1247+
"summary": "List of names",
1248+
"value" : ["Bob","Diane","Mary","Bill"]
1249+
},
1250+
"empty":{
1251+
"summary": "Empty List",
1252+
"value": []
1253+
}
1254+
}
12231255
},
12241256
"application/xml": {
1225-
"examples": [
1226-
"<Users><User name='Bob'/><User name='Diane'/><User name='Mary'/><User name='Bill'/></Users>",
1227-
"<Users/>"
1228-
]
1257+
"examples": {
1258+
"list": {
1259+
"summary": "List of names",
1260+
"value": "<Users><User name='Bob'/><User name='Diane'/><User name='Mary'/><User name='Bill'/></Users>"
1261+
},
1262+
"empty": {
1263+
"summary":"Empty",
1264+
"value": "<Users/>"
1265+
}
1266+
}
12291267
},
12301268
"text/plain": {
1231-
"examples": [
1232-
"Bob,Diane,Mary,Bill",
1233-
""
1234-
]
1269+
"examples": {
1270+
"list": {
1271+
"summary": "List of names",
1272+
"value": "Bob,Diane,Mary,Bill"
1273+
},
1274+
"empty": {
1275+
"summary": "Empty",
1276+
"value" : ""
1277+
}
1278+
}
12351279
}
12361280
}
12371281
```
@@ -1244,21 +1288,33 @@ content:
12441288
items:
12451289
type: string
12461290
examples:
1247-
-
1248-
- Bob
1249-
- Diane
1250-
- Mary
1251-
- Bill
1252-
- {}
1291+
list:
1292+
summary: List of Names
1293+
value:
1294+
- Bob
1295+
- Diane
1296+
- Mary
1297+
- Bill
1298+
empty:
1299+
summary: Empty
1300+
value: {}
12531301
12541302
'application/xml':
12551303
examples:
1256-
- "<Users><User name='Bob'/><User name='Diane'/><User name='Mary'/><User name='Bill'/></Users>"
1257-
- "<Users/>"
1304+
list:
1305+
summary: List of names
1306+
value: "<Users><User name='Bob'/><User name='Diane'/><User name='Mary'/><User name='Bill'/></Users>"
1307+
empty:
1308+
summmary: Empty list
1309+
value: "<Users/>"
12581310
'text/plain':
12591311
examples:
1260-
- "Bob,Diane,Mary,Bill"
1261-
- ""
1312+
list:
1313+
summary: List of names
1314+
value: "Bob,Diane,Mary,Bill"
1315+
empty:
1316+
summary: Empty
1317+
value: ""
12621318
```
12631319

12641320
#### <a name="mediaTypeObject"></a>Media Type Object
@@ -1889,8 +1945,9 @@ schemas:
18891945
properties:
18901946
name:
18911947
type: string
1892-
example:
1893-
$ref: http://example.org/petapi-examples/OpenApi.json#/components/examples/name-example
1948+
examples:
1949+
name:
1950+
$ref: http://example.org/petapi-examples/OpenApi.json#/components/examples/name-example
18941951
18951952
# in a request body, note the plural `examples` as the Content-Type is set to `*`:
18961953
requestBody:
@@ -2781,14 +2838,22 @@ example:
27812838
"required": [
27822839
"name"
27832840
],
2784-
"examples": [
2785-
{
2786-
"name": "Puma",
2787-
"id": 1
2788-
}, {
2789-
"name": "Ferguson",
2790-
"id": 2
2791-
}]
2841+
"examples": {
2842+
"cat": {
2843+
"summary": "Big cat example",
2844+
"value": {
2845+
"name": "Puma",
2846+
"id": 1
2847+
}
2848+
},
2849+
"dog": {
2850+
"summary": "Family dog example",
2851+
"value": {
2852+
"name": "Ferguson",
2853+
"id": 2
2854+
}
2855+
}
2856+
}
27922857
}
27932858
```
27942859

@@ -2803,10 +2868,16 @@ properties:
28032868
required:
28042869
- name
28052870
examples:
2806-
- name: Puma
2807-
id: 1
2808-
- name: Ferguson
2809-
id: 2
2871+
cat:
2872+
summary: Big cat example
2873+
value:
2874+
name: Puma
2875+
id: 1
2876+
dog:
2877+
summary: Family Dog
2878+
value:
2879+
name: Ferguson
2880+
id: 2
28102881
```
28112882

28122883
###### Models with Composition

0 commit comments

Comments
 (0)