ioggstream

openapi-ref-2.yaml

Apr 5th, 2018
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.36 KB | None | 0 0
  1. openapi: 3.0.0
  2. info:
  3. version: "0.0.1"
  4. title: |
  5. Core Vocabularies API
  6. description: |
  7. Dictionaries are versioned key-value store that you can
  8. retrieve via API. For each dictionary you can:
  9. - get metadata infos
  10. - retrieve a paged subset
  11. - get a single entry via an unique key
  12. - find entries by a given key (which could not be unique)
  13.  
  14. Dictionary structure is the following:
  15. - Dictionary: has a single name and many versions
  16. - Table: it's a specific version of a dictionary. May
  17. expire
  18. - Entry: it's the actual data contained in a table.
  19.  
  20. Despite http://zalando.github.io/restful-api-guidelines/index.html#160
  21. we use pagination as it's more intuitive for this use case.
  22. termsOfService: 'http://swagger.io/terms/'
  23. contact:
  24. name: Roberto Polli
  25. url: https://twitter.com/ioggstream
  26. x-audience: |
  27. Definire qui l'audience delle API
  28. x-api-id: b9ec7026-5da5-4db6-a959-fce72db5de64
  29. license:
  30. name: Apache 2.0
  31. url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
  32. servers:
  33. # Added by API Auto Mocking Plugin
  34. - description: SwaggerHub API Auto Mocking
  35. url: https://virtserver.swaggerhub.com/robipolli/core-vocabularies/0.0.1
  36.  
  37. paths:
  38. /dictionaries:
  39. get:
  40. summary: Get informations about provided dictionaries.
  41. description: |
  42. Shows a list of supported dictionaries.
  43. operationId: getDictionaries
  44.  
  45. responses:
  46. '200':
  47. description: |
  48. A list of Dictionaries.
  49. Headers secondo http://zalando.github.io/restful-api-guidelines/index.html#132
  50. headers:
  51. X-Rate-Limit-Limit:
  52. $ref: '#/components/headers/X-Rate-Limit-Limit'
  53. X-Rate-Limit-Remaining:
  54. $ref: '#/components/headers/X-Rate-Limit-Remaining'
  55. X-Rate-Limit-Reset:
  56. $ref: '#/components/headers/X-Rate-Limit-Reset'
  57. content:
  58. application/json:
  59. schema:
  60. $ref: '#/components/schemas/Dictionaries'
  61. /dictionaries/{dictionary_name}:
  62. get:
  63. summary: Get informations about a dictionary.
  64. description: |
  65. Retrieve available dictionary version and URI.
  66. operationId: getDictionary
  67. parameters:
  68. - $ref: "#/components/parameters/dictionary_name_path"
  69. responses:
  70. '200':
  71. description: |
  72. Retrieve information from a dictionary.
  73. headers:
  74. X-Rate-Limit-Limit:
  75. $ref: '#/components/headers/X-Rate-Limit-Limit'
  76. X-Rate-Limit-Remaining:
  77. $ref: '#/components/headers/X-Rate-Limit-Remaining'
  78. X-Rate-Limit-Reset:
  79. $ref: '#/components/headers/X-Rate-Limit-Reset'
  80. content:
  81. application/json:
  82. schema:
  83. $ref: '#/components/schemas/Dictionary'
  84. '400':
  85. $ref: '#/components/responses/400BadRequest'
  86. '404':
  87. $ref: '#/components/responses/404NotFound'
  88. default:
  89. $ref: '#/components/responses/default'
  90.  
  91. post:
  92. summary: |
  93. Upload a new (version of a) dictionary eventually creating
  94. a new dictionary. The passed csv file contains a trailing
  95. line with the expected line count. If the schema does not match
  96. previous version, an error is returned.
  97. operationId: uploadDictionary
  98. requestBody:
  99. description: |-
  100. Use MarkDown here!
  101. required: true
  102. content:
  103. application/json:
  104. schema:
  105. $ref: '#/components/schemas/TableData'
  106. responses:
  107. '201':
  108. description: |
  109. A new version of the table have been created.
  110. content:
  111. application/json:
  112. schema:
  113. $ref: '#/components/schemas/Table'
  114. '404':
  115. $ref: '#/components/responses/404NotFound'
  116. default:
  117. $ref: '#/components/responses/default'
  118. /dictionaries/{dictionary_name}/meta:
  119. get:
  120. summary: Get meta informations about a dictionary.
  121. description: |
  122. Retrieve available dictionary version and URI:
  123. foo bar
  124. operationId: getDictionaryMeta
  125. parameters:
  126. - $ref: "#/components/parameters/dictionary_name_path"
  127. responses:
  128. '200':
  129. description: |
  130. Retrieve information from a dictionary.
  131. headers:
  132. X-Rate-Limit-Limit:
  133. $ref: '#/components/headers/X-Rate-Limit-Limit'
  134. X-Rate-Limit-Remaining:
  135. $ref: '#/components/headers/X-Rate-Limit-Remaining'
  136. X-Rate-Limit-Reset:
  137. $ref: '#/components/headers/X-Rate-Limit-Reset'
  138. content:
  139. application/json:
  140. schema:
  141. $ref: '#/components/schemas/Dictionary'
  142. '400':
  143. $ref: '#/components/responses/400BadRequest'
  144. '404':
  145. $ref: '#/components/responses/404NotFound'
  146. default:
  147. $ref: '#/components/responses/default'
  148. /dictionaries/{dictionary_name}/{version}/{entry_key}:
  149. get:
  150. summary: Get a Table entry
  151. operationId: getEntry
  152. description: |-
  153. Retrieve an entry from a Table.
  154. parameters:
  155. - $ref: '#/components/parameters/dictionary_name_path'
  156. - $ref: '#/components/parameters/version_path'
  157. - $ref: '#/components/parameters/entry_key_path'
  158. responses:
  159. '200':
  160. description: |
  161. Returns the given entry.
  162. headers:
  163. X-Rate-Limit-Limit:
  164. $ref: '#/components/headers/X-Rate-Limit-Limit'
  165. X-Rate-Limit-Remaining:
  166. $ref: '#/components/headers/X-Rate-Limit-Remaining'
  167. X-Rate-Limit-Reset:
  168. $ref: '#/components/headers/X-Rate-Limit-Reset'
  169. content:
  170. application/json:
  171. schema:
  172. $ref: '#/components/schemas/Entries'
  173. '400':
  174. $ref: '#/components/responses/400BadRequest'
  175. '404':
  176. $ref: '#/components/responses/404NotFound'
  177. '429':
  178. $ref: '#/components/responses/429TooManyRequests'
  179. '503':
  180. $ref: '#/components/responses/503ServiceUnavailable'
  181. default:
  182. $ref: '#/components/responses/default'
  183.  
  184. components:
  185. parameters:
  186. limit:
  187. $ref: 'https://teamdigitale.github.io/openapi/parameters/v3.yaml#limit'
  188. offset:
  189. $ref: 'https://teamdigitale.github.io/openapi/parameters/v3.yaml#offset'
  190. sort:
  191. $ref: 'https://teamdigitale.github.io/openapi/parameters/v3.yaml#sort'
  192. name:
  193. name: name
  194. in: query
  195. description: The indexed key to search with.
  196. required: false
  197. example: Latina
  198. schema:
  199. type: string
  200. dictionary_name_path:
  201. name: dictionary_name
  202. in: path
  203. required: true
  204. description: The name of the dictionary
  205. example: cities
  206. schema:
  207. type: string
  208. dictionary_name:
  209. name: dictionary_name
  210. in: query
  211. description: The name of the dictionary
  212. example: cities
  213. schema:
  214. type: string
  215. entry_key_path:
  216. name: entry_key
  217. in: path
  218. required: true
  219. description: The entry key
  220. example: E472-2007
  221. schema:
  222. type: string
  223. table_uuid_path:
  224. name: table_uuid
  225. in: path
  226. required: true
  227. description: The table uuid
  228. example: 2b356821-868e-4274-9c8e-ca119dd097df
  229. schema:
  230. type: string
  231. version_path:
  232. name: version
  233. in: path
  234. required: true
  235. description: A specific version of a dictionary.
  236. example: 137
  237. schema:
  238. type: integer
  239.  
  240. headers:
  241. # Headers conform to http://zalando.github.io/restful-api-guidelines/index.html#132
  242. X-Rate-Limit-Limit:
  243. $ref: 'https://teamdigitale.github.io/openapi/headers/v3.yaml#/X-Rate-Limit-Limit'
  244. X-Rate-Limit-Remaining:
  245. $ref: 'https://teamdigitale.github.io/openapi/headers/v3.yaml#/X-Rate-Limit-Remaining'
  246. X-Rate-Limit-Reset:
  247. $ref: 'https://teamdigitale.github.io/openapi/headers/v3.yaml#/X-Rate-Limit-Reset'
  248.  
  249. responses:
  250. # Predefined error codes for this API
  251. 400BadRequest:
  252. $ref: 'https://teamdigitale.github.io/openapi/responses/v3.yaml#/400BadRequest'
  253. 404NotFound:
  254. $ref: 'https://teamdigitale.github.io/openapi/responses/v3.yaml#/404NotFound'
  255. 429TooManyRequests:
  256. $ref: 'https://teamdigitale.github.io/openapi/responses/v3.yaml#/429TooManyRequests'
  257. 503ServiceUnavailable:
  258. $ref: 'https://teamdigitale.github.io/openapi/responses/v3.yaml#/503ServiceUnavailable'
  259. default:
  260. $ref: 'https://teamdigitale.github.io/openapi/responses/v3.yaml#/default'
  261.  
  262. schemas:
  263.  
  264. Problem:
  265. $ref: 'https://teamdigitale.github.io/openapi/schemas/problem.yaml#Problem'
  266.  
  267. Dictionaries:
  268. required:
  269. - items
  270. - offset
  271. - offset_next
  272. properties:
  273. item:
  274. type: array
  275. items:
  276. $ref: '#/components/schemas/Dictionary'
  277. offset:
  278. type: integer
  279. format: int32
  280. example: 5
  281. offset_next:
  282. type: integer
  283. format: int32
  284. example: 10
  285.  
  286. Dictionary:
  287. description: |
  288. Reference to a dictionary, that is a multi-versioned table.
  289. required:
  290. - name
  291. - description
  292. - last_version
  293. - uri
  294. properties:
  295. name:
  296. type: string
  297. example: cities
  298. description:
  299. type: string
  300. example: |-
  301. Which data is contained in the dictionary? Cities? Foreign countries?
  302. Healtcare codes?
  303. last_version:
  304. type: integer
  305. example: 134
  306. uri:
  307. type: string
  308. format: uri
  309. example: http://dictionaries-beta.api.example.com/dictionaries/cities
  310.  
  311. Table:
  312. description: |
  313. Versioned dictionary.
  314. required:
  315. - name
  316. - version
  317. - uri
  318. - uuid
  319. - ttl
  320. properties:
  321. name:
  322. type: string
  323. example: cities
  324. version:
  325. type: integer
  326. example: 137
  327. uuid:
  328. type: string
  329. format: uuid
  330. example: 2b356821-868e-4274-9c8e-ca119dd097df
  331. table_uri:
  332. type: string
  333. format: uri
  334. example: http://dictionaries-beta.api.example.com/table/2b356821-868e-4274-9c8e-ca119dd097df
  335. uri:
  336. type: string
  337. format: uri
  338. example: http://dictionaries-beta.api.example.com/dictionaries/cities/137
  339. ttl:
  340. type: integer
  341. format: int32
  342. description: Seconds to the invalidation of the API.
  343.  
  344. Tables:
  345. required:
  346. - items
  347. - offset
  348. - offset_next
  349. properties:
  350. item:
  351. type: array
  352. items:
  353. $ref: '#/components/schemas/Table'
  354. offset:
  355. type: integer
  356. format: int32
  357. example: 5
  358. offset_next:
  359. type: integer
  360. format: int32
  361. example: 10
  362.  
  363. TableData:
  364. description: |
  365. Dictionary data, freely inspired by https://github.com/italia/daf-ontologie-vocabolari-controllati/
  366. required:
  367. - name
  368. - ttl
  369. - data
  370. properties:
  371. name:
  372. type: string
  373. example: cities
  374. ttl:
  375. type: integer
  376. format: int32
  377. description: Seconds to the invalidation of the API.
  378. data:
  379. type: array
  380. items:
  381. $ref: '#/components/schemas/Entry'
  382.  
  383. Entry:
  384. required:
  385. - key
  386. - data
  387. properties:
  388. key:
  389. type: string
  390. description: |-
  391. An unique ID for the entry in the given table. This may have
  392. a semantic meaning or could be just an UUID.
  393. example: E472-2007
  394. data:
  395. type: object
  396. example: { 'codice_catastale': 'E472', 'provincia': 'LT', 'nome': 'Latina', 'nome_traslitterato': 'LATINA', 'codice_istat': '059011'}
  397. name:
  398. type: string
  399. example: Latina
  400. description: Searchable string.
  401. # backref:
  402. # type: string
  403. # format: uri
  404. # description: |-
  405. # XXX Reference to parent dictionary. Do we need it?
  406. # example: http://dictionaries-beta.api.example.com/dictionaries/cities/137
  407. Entries:
  408. required:
  409. - items
  410. - offset
  411. - offset_next
  412. properties:
  413. item:
  414. type: array
  415. items:
  416. $ref: '#/components/schemas/Entry'
  417. table_uri:
  418. type: string
  419. format: uri
  420. example: http://dictionaries-beta.api.example.com/table/2b356821-868e-4274-9c8e-ca119dd097df
  421. offset:
  422. type: integer
  423. format: int32
  424. description: |-
  425. Current offset (eg. entries 50 to 99)
  426. example: 50
  427. offset_next:
  428. type: integer
  429. format: int32
  430. description: |-
  431. Offset for the next page (eg. entries from 100 to 149).
  432. This could be a link too in HATEOAS.
  433. example: 100
Advertisement
Add Comment
Please, Sign In to add comment