multiple-examples-core.openapi.yaml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. openapi: 3.0.0
  2. info:
  3. title: "Multiple Examples: Core Document"
  4. description: |
  5. This document has examples for straightforward usage of `examples` in...
  6. * Parameter Object positions
  7. * Response Object positions
  8. * Request Body Object positions
  9. It includes:
  10. * cases for each JSON Schema type as an example value (except null) in each position
  11. * variously-sized `examples` objects
  12. * multi-paragraph descriptions within each example
  13. It **does not** include the following out-of-scope items:
  14. * usage of `examples` within `Parameter.content` or `Response.content`
  15. * `externalValue` (might change)
  16. It also lacks edge cases, which will be covered in the "Corner" Document:
  17. * `examples` n=1, which presents an interesting UI problem w/ the dropdown
  18. * `example` and `examples` both present
  19. * example item value that doesn't match the input type
  20. * e.g., `Parameter.type === "number"`, but `Parameter.examples.[key].value` is an object
  21. * `null` as an example value
  22. version: "1.0.2"
  23. paths:
  24. /String:
  25. post:
  26. summary: "Bonus: contains two requestBody media types"
  27. parameters:
  28. - in: query
  29. name: message
  30. required: true
  31. description: This parameter just so happens to have a one-line description.
  32. schema:
  33. type: string
  34. examples:
  35. StringExampleA:
  36. $ref: '#/components/examples/StringExampleA'
  37. StringExampleB:
  38. $ref: '#/components/examples/StringExampleB'
  39. requestBody:
  40. description: the wonderful payload of my request
  41. content:
  42. text/plain:
  43. schema:
  44. type: string
  45. examples:
  46. StringExampleA:
  47. $ref: '#/components/examples/StringExampleA'
  48. StringExampleB:
  49. $ref: '#/components/examples/StringExampleB'
  50. text/plain+other:
  51. schema:
  52. type: string
  53. examples:
  54. StringExampleA:
  55. $ref: '#/components/examples/StringExampleA'
  56. StringExampleB:
  57. $ref: '#/components/examples/StringExampleB'
  58. responses:
  59. 200:
  60. description: has two media types; the second has a third example!
  61. content:
  62. text/plain:
  63. schema:
  64. type: string
  65. examples:
  66. StringExampleA:
  67. $ref: '#/components/examples/StringExampleA'
  68. StringExampleB:
  69. $ref: '#/components/examples/StringExampleB'
  70. text/plain+other:
  71. schema:
  72. type: string
  73. examples:
  74. StringExampleA:
  75. $ref: '#/components/examples/StringExampleA'
  76. StringExampleB:
  77. $ref: '#/components/examples/StringExampleB'
  78. StringExampleC:
  79. $ref: '#/components/examples/StringExampleC'
  80. /Number:
  81. post:
  82. parameters:
  83. - in: query
  84. name: message
  85. required: true
  86. schema:
  87. type: number
  88. examples:
  89. NumberExampleA:
  90. $ref: '#/components/examples/NumberExampleA'
  91. NumberExampleB:
  92. $ref: '#/components/examples/NumberExampleB'
  93. NumberExampleC:
  94. $ref: '#/components/examples/NumberExampleC'
  95. requestBody:
  96. description: the wonderful payload of my request
  97. content:
  98. text/plain:
  99. schema:
  100. type: number
  101. examples:
  102. NumberExampleA:
  103. $ref: '#/components/examples/NumberExampleA'
  104. NumberExampleB:
  105. $ref: '#/components/examples/NumberExampleB'
  106. NumberExampleC:
  107. $ref: '#/components/examples/NumberExampleC'
  108. text/plain+other:
  109. schema:
  110. type: number
  111. examples:
  112. NumberExampleA:
  113. $ref: '#/components/examples/NumberExampleA'
  114. NumberExampleB:
  115. $ref: '#/components/examples/NumberExampleB'
  116. NumberExampleC:
  117. $ref: '#/components/examples/NumberExampleC'
  118. responses:
  119. 200:
  120. description: OK!
  121. content:
  122. text/plain:
  123. schema:
  124. type: number
  125. examples:
  126. NumberExampleA:
  127. $ref: '#/components/examples/NumberExampleA'
  128. NumberExampleB:
  129. $ref: '#/components/examples/NumberExampleB'
  130. text/plain+other:
  131. schema:
  132. type: number
  133. examples:
  134. NumberExampleA:
  135. $ref: '#/components/examples/NumberExampleA'
  136. NumberExampleB:
  137. $ref: '#/components/examples/NumberExampleB'
  138. NumberExampleC:
  139. $ref: '#/components/examples/NumberExampleC'
  140. /Boolean:
  141. post:
  142. parameters:
  143. - in: query
  144. name: message
  145. required: true
  146. schema:
  147. type: boolean
  148. examples:
  149. BooleanExampleA:
  150. $ref: '#/components/examples/BooleanExampleA'
  151. BooleanExampleB:
  152. $ref: '#/components/examples/BooleanExampleB'
  153. requestBody:
  154. description: the wonderful payload of my request
  155. content:
  156. text/plain:
  157. schema:
  158. type: boolean
  159. examples:
  160. BooleanExampleA:
  161. $ref: '#/components/examples/BooleanExampleA'
  162. BooleanExampleB:
  163. $ref: '#/components/examples/BooleanExampleB'
  164. text/plain+other:
  165. schema:
  166. type: boolean
  167. examples:
  168. BooleanExampleA:
  169. $ref: '#/components/examples/BooleanExampleA'
  170. BooleanExampleB:
  171. $ref: '#/components/examples/BooleanExampleB'
  172. responses:
  173. 200:
  174. description: OK!
  175. content:
  176. text/plain:
  177. schema:
  178. type: boolean
  179. examples:
  180. BooleanExampleA:
  181. $ref: '#/components/examples/BooleanExampleA'
  182. BooleanExampleB:
  183. $ref: '#/components/examples/BooleanExampleB'
  184. text/plain+other:
  185. schema:
  186. type: boolean
  187. examples:
  188. BooleanExampleA:
  189. $ref: '#/components/examples/BooleanExampleA'
  190. BooleanExampleB:
  191. $ref: '#/components/examples/BooleanExampleB'
  192. /Array:
  193. post:
  194. parameters:
  195. - in: query
  196. name: message
  197. required: true
  198. schema:
  199. type: array
  200. items: {} # intentionally empty; don't want to assert on the items
  201. examples:
  202. ArrayExampleA:
  203. $ref: '#/components/examples/ArrayExampleA'
  204. ArrayExampleB:
  205. $ref: '#/components/examples/ArrayExampleB'
  206. ArrayExampleC:
  207. $ref: '#/components/examples/ArrayExampleC'
  208. requestBody:
  209. description: the wonderful payload of my request
  210. content:
  211. application/json:
  212. schema:
  213. type: array
  214. items: {} # intentionally empty; don't want to assert on the items
  215. examples:
  216. ArrayExampleA:
  217. $ref: '#/components/examples/ArrayExampleA'
  218. ArrayExampleB:
  219. $ref: '#/components/examples/ArrayExampleB'
  220. ArrayExampleC:
  221. $ref: '#/components/examples/ArrayExampleC'
  222. responses:
  223. 200:
  224. description: OK!
  225. content:
  226. application/json:
  227. schema:
  228. type: array
  229. items: {} # intentionally empty; don't want to assert on the items
  230. examples:
  231. ArrayExampleA:
  232. $ref: '#/components/examples/ArrayExampleA'
  233. ArrayExampleB:
  234. $ref: '#/components/examples/ArrayExampleB'
  235. ArrayExampleC:
  236. $ref: '#/components/examples/ArrayExampleC'
  237. /Object:
  238. post:
  239. parameters:
  240. - in: query
  241. name: data
  242. required: true
  243. schema:
  244. type: object
  245. examples:
  246. ObjectExampleA:
  247. $ref: '#/components/examples/ObjectExampleA'
  248. ObjectExampleB:
  249. $ref: '#/components/examples/ObjectExampleB'
  250. requestBody:
  251. description: the wonderful payload of my request
  252. content:
  253. application/json:
  254. schema:
  255. type: object
  256. examples:
  257. ObjectExampleA:
  258. $ref: '#/components/examples/ObjectExampleA'
  259. ObjectExampleB:
  260. $ref: '#/components/examples/ObjectExampleB'
  261. text/plain+other:
  262. schema:
  263. type: object
  264. examples:
  265. ObjectExampleA:
  266. $ref: '#/components/examples/ObjectExampleA'
  267. ObjectExampleB:
  268. $ref: '#/components/examples/ObjectExampleB'
  269. responses:
  270. 200:
  271. description: OK!
  272. content:
  273. application/json:
  274. schema:
  275. type: object
  276. examples:
  277. ObjectExampleA:
  278. $ref: '#/components/examples/ObjectExampleA'
  279. ObjectExampleB:
  280. $ref: '#/components/examples/ObjectExampleB'
  281. text/plain+other:
  282. schema:
  283. type: object
  284. examples:
  285. ObjectExampleA:
  286. $ref: '#/components/examples/ObjectExampleA'
  287. ObjectExampleB:
  288. $ref: '#/components/examples/ObjectExampleB'
  289. components:
  290. examples:
  291. StringExampleA:
  292. value: "hello world"
  293. summary: Don't just string me along...
  294. description: |
  295. A string in C is actually a character array. As an individual character variable can store only one character, we need an array of characters to store strings. Thus, in C string is stored in an array of characters. Each character in a string occupies one location in an array. The null character ‘\0’ is put after the last character. This is done so that program can tell when the end of the string has been reached.
  296. For example, the string “Hello” is stored as follows...
  297. ![](http://www.tutorialspoint.com/computer_programming/images/string_representation.jpg)
  298. Since the string contains 5 characters. it requires a character array of size 6 to store it. the last character in a string is always a NULL('\0') character. Always keep in mind that the '\0' is not included in the length if the string, so here the length of the string is 5 only. Notice above that the indexes of the string starts from 0 not one so don't confuse yourself with index and length of string.
  299. Thus, in C, a string is a one-dimensional array of characters terminated a null character. The terminating null character is important. In fact, a string not terminated by ‘\0’ is not really a string, but merely a collection of characters.
  300. StringExampleB:
  301. value: "The quick brown fox jumps over the lazy dog"
  302. summary: "I'm a pangram!"
  303. description: |
  304. A pangram (Greek: παν γράμμα, pan gramma, "every letter") or holoalphabetic sentence is a sentence using every letter of a given alphabet at least once. Pangrams have been used to display typefaces, test equipment, and develop skills in handwriting, calligraphy, and keyboarding.
  305. The best-known English pangram is "The quick brown fox jumps over the lazy dog". It has been used since at least the late 19th century, was utilized by Western Union to test Telex / TWX data communication equipment for accuracy and reliability, and is now used by a number of computer programs (most notably the font viewer built into Microsoft Windows) to display computer fonts.
  306. Pangrams exist in practically every alphabet-based language. An example from German is _Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich_, which contains all letters, including every umlaut (ä, ö, ü) plus the ß. It has been used since before 1800.
  307. In a sense, the pangram is the opposite of the lipogram, in which the aim is to omit one or more letters.
  308. A perfect pangram contains every letter of the alphabet only once and
  309. can be considered an anagram of the alphabet. The only perfect pangrams
  310. that are known either use abbreviations, such as "Mr Jock, TV quiz PhD,
  311. bags few lynx", or use words so obscure that the phrase is hard to
  312. understand, such as "Cwm fjord bank glyphs vext quiz", where cwm is a
  313. loan word from the Welsh language meaning a steep-sided valley, and vext
  314. is an uncommon way to spell vexed.
  315. StringExampleC:
  316. value: "JavaScript rules"
  317. summary: "A third example, for use in special places..."
  318. NumberExampleA:
  319. value: 7710263025
  320. summary: "World population"
  321. description: |
  322. In demographics, the world population is the total number of humans currently living, and was estimated to have reached 7.7 billion people as of April 2019. It took over 200,000 years of human history for the world's population to reach 1 billion; and only 200 years more to reach 7 billion.
  323. World population has experienced continuous growth since the end of the Great Famine of 1315–1317 and the Black Death in 1350, when it was near 370 million. The highest population growth rates – global population increases above 1.8% per year – occurred between 1955 and 1975, peaking to 2.1% between 1965 and 1970. The growth rate has declined to 1.2% between 2010 and 2015 and is projected to decline further in the course of the 21st century. However, the global population is still growing and is projected to reach about 10 billion in 2050 and more than 11 billion in 2100.
  324. Total annual births were highest in the late 1980s at about 139 million, and as of 2011 were expected to remain essentially constant at a level of 135 million, while deaths numbered 56 million per year and were expected to increase to 80 million per year by 2040. The median age of the world's population was estimated to be 30.4 years in 2018.
  325. NumberExampleB:
  326. value: 9007199254740991
  327. summary: "Number.MAX_SAFE_INTEGER"
  328. description: |
  329. The `MAX_SAFE_INTEGER` constant has a value of `9007199254740991` (9,007,199,254,740,991 or ~9 quadrillion). The reasoning behind that number is that JavaScript uses double-precision floating-point format numbers as specified in IEEE 754 and can only safely represent numbers between `-(2^53 - 1)` and `2^53 - 1`.
  330. Safe in this context refers to the ability to represent integers exactly and to correctly compare them. For example, `Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2` will evaluate to `true`, which is mathematically incorrect. See `Number.isSafeInteger()` for more information.
  331. Because `MAX_SAFE_INTEGER` is a static property of `Number`, you always use it as `Number.MAX_SAFE_INTEGER`, rather than as a property of a `Number` object you created.
  332. NumberExampleC:
  333. # `description` and `summary` intentionally omitted
  334. value: 0
  335. BooleanExampleA:
  336. value: true
  337. summary: The truth will set you free
  338. description: |
  339. In some programming languages, any expression can be evaluated in a context that expects a Boolean data type. Typically (though this varies by programming language) expressions like the number zero, the empty string, empty lists, and null evaluate to false, and strings with content (like "abc"), other numbers, and objects evaluate to true. Sometimes these classes of expressions are called "truthy" and "falsey".
  340. BooleanExampleB:
  341. # `description` intentionally omitted
  342. value: false
  343. summary: Friends don't lie to friends
  344. ArrayExampleA:
  345. value: [a, b, c]
  346. summary: A lowly array of strings
  347. description: |
  348. In computer science, a list or sequence is an abstract data type that represents a countable number of ordered values, where the same value may occur more than once. An instance of a list is a computer representation of the mathematical concept of a finite sequence; the (potentially) infinite analog of a list is a stream.[1]:§3.5 Lists are a basic example of containers, as they contain other values. If the same value occurs multiple times, each occurrence is considered a distinct item.
  349. ArrayExampleB:
  350. value: [1, 2, 3, 4]
  351. summary: A lowly array of numbers
  352. description: |
  353. Many programming languages provide support for list data types, and have special syntax and semantics for lists and list operations. A list can often be constructed by writing the items in sequence, separated by commas, semicolons, and/or spaces, within a pair of delimiters such as parentheses '()', brackets '[]', braces '{}', or angle brackets '<>'. Some languages may allow list types to be indexed or sliced like array types, in which case the data type is more accurately described as an array. In object-oriented programming languages, lists are usually provided as instances of subclasses of a generic "list" class, and traversed via separate iterators. List data types are often implemented using array data structures or linked lists of some sort, but other data structures may be more appropriate for some applications. In some contexts, such as in Lisp programming, the term list may refer specifically to a linked list rather than an array.
  354. In type theory and functional programming, abstract lists are usually defined inductively by two operations: nil that yields the empty list, and cons, which adds an item at the beginning of a list.
  355. ArrayExampleC:
  356. # `summary` intentionally omitted
  357. value: []
  358. description: An empty array value should clear the current value
  359. ObjectExampleA:
  360. value:
  361. firstName: Kyle
  362. lastName: Shockey
  363. email: kyle.shockey@smartbear.com
  364. summary: A user's contact info
  365. description: Who is this guy, anyways?
  366. ObjectExampleB:
  367. value:
  368. name: Abbey
  369. type: kitten
  370. color: calico
  371. gender: female
  372. age: 11 weeks
  373. summary: A wonderful kitten's info
  374. description: |
  375. Today’s domestic cats are physically very similar to their wild
  376. ancestors. “Domestic cats and wildcats share a majority of their
  377. characteristics,” Lyons says, but there are a few key differences:
  378. wildcats were and are typically larger than their domestic kin, with
  379. brown, tabby-like fur. “Wildcats have to have camouflage that’s going to
  380. keep them very inconspicuous in the wild,” Lyons says. “So you can’t
  381. have cats with orange and white running around—they’re going to be
  382. snatched up by their predators.” As cats were domesticated, they began
  383. to be selected and bred for more interesting colorations, thus giving us
  384. today’s range of beautiful cat breeds.