Advertisement
ioggstream

openapi-ref-2.yaml

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