index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. 'use strict'
  2. const _ = require('lodash')
  3. const paths = _.reduce(
  4. [require('./projects').paths, require('./project_import').paths],
  5. _.extend
  6. )
  7. const securityDefinitions = require('./security_definitions')
  8. module.exports = {
  9. swagger: '2.0',
  10. info: {
  11. title: 'Overleaf Editor API',
  12. description: 'API for the Overleaf editor.',
  13. version: '1.0',
  14. },
  15. produces: ['application/json'],
  16. basePath: '/api',
  17. paths,
  18. securityDefinitions,
  19. security: [
  20. {
  21. jwt: [],
  22. },
  23. ],
  24. definitions: {
  25. Project: {
  26. properties: {
  27. projectId: {
  28. type: 'string',
  29. },
  30. },
  31. required: ['projectId'],
  32. },
  33. File: {
  34. properties: {
  35. hash: {
  36. type: 'string',
  37. },
  38. byteLength: {
  39. type: 'integer',
  40. },
  41. stringLength: {
  42. type: 'integer',
  43. },
  44. },
  45. },
  46. Label: {
  47. properties: {
  48. authorId: {
  49. type: 'integer',
  50. },
  51. text: {
  52. type: 'string',
  53. },
  54. timestamp: {
  55. type: 'string',
  56. },
  57. version: {
  58. type: 'integer',
  59. },
  60. },
  61. },
  62. Chunk: {
  63. properties: {
  64. history: {
  65. $ref: '#/definitions/History',
  66. },
  67. startVersion: {
  68. type: 'number',
  69. },
  70. },
  71. },
  72. ChunkResponse: {
  73. properties: {
  74. chunk: {
  75. $ref: '#/definitions/Chunk',
  76. },
  77. authors: {
  78. type: 'array',
  79. items: {
  80. $ref: '#/definitions/Author',
  81. },
  82. },
  83. },
  84. },
  85. ChunkResponseRaw: {
  86. properties: {
  87. startVersion: {
  88. type: 'number',
  89. },
  90. endVersion: {
  91. type: 'number',
  92. },
  93. endTimestamp: {
  94. type: 'string',
  95. },
  96. },
  97. },
  98. History: {
  99. properties: {
  100. snapshot: {
  101. $ref: '#/definitions/Snapshot',
  102. },
  103. changes: {
  104. type: 'array',
  105. items: {
  106. $ref: '#/definitions/Change',
  107. },
  108. },
  109. },
  110. },
  111. Snapshot: {
  112. properties: {
  113. files: {
  114. type: 'object',
  115. additionalProperties: {
  116. $ref: '#/definitions/File',
  117. },
  118. },
  119. },
  120. required: ['files'],
  121. },
  122. Change: {
  123. properties: {
  124. timestamp: {
  125. type: 'string',
  126. },
  127. operations: {
  128. type: 'array',
  129. items: {
  130. $ref: '#/definitions/Operation',
  131. },
  132. },
  133. authors: {
  134. type: 'array',
  135. items: {
  136. type: ['integer', 'null'],
  137. },
  138. },
  139. v2Authors: {
  140. type: 'array',
  141. items: {
  142. type: ['string', 'null'],
  143. },
  144. },
  145. projectVersion: {
  146. type: 'string',
  147. },
  148. v2DocVersions: {
  149. type: 'object',
  150. additionalProperties: {
  151. $ref: '#/definitions/V2DocVersions',
  152. },
  153. },
  154. },
  155. required: ['timestamp', 'operations'],
  156. },
  157. V2DocVersions: {
  158. properties: {
  159. pathname: {
  160. type: 'string',
  161. },
  162. v: {
  163. type: 'integer',
  164. },
  165. },
  166. },
  167. ChangeRequest: {
  168. properties: {
  169. baseVersion: {
  170. type: 'integer',
  171. },
  172. untransformable: {
  173. type: 'boolean',
  174. },
  175. operations: {
  176. type: 'array',
  177. items: {
  178. $ref: '#/definitions/Operation',
  179. },
  180. },
  181. authors: {
  182. type: 'array',
  183. items: {
  184. type: ['integer', 'null'],
  185. },
  186. },
  187. },
  188. required: ['baseVersion', 'operations'],
  189. },
  190. ChangeNote: {
  191. properties: {
  192. baseVersion: {
  193. type: 'integer',
  194. },
  195. change: {
  196. $ref: '#/definitions/Change',
  197. },
  198. },
  199. required: ['baseVersion'],
  200. },
  201. Operation: {
  202. properties: {
  203. pathname: {
  204. type: 'string',
  205. },
  206. newPathname: {
  207. type: 'string',
  208. },
  209. blob: {
  210. $ref: '#/definitions/Blob',
  211. },
  212. textOperation: {
  213. type: 'array',
  214. items: {},
  215. },
  216. file: {
  217. $ref: '#/definitions/File',
  218. },
  219. },
  220. },
  221. Error: {
  222. properties: {
  223. message: {
  224. type: 'string',
  225. },
  226. },
  227. required: ['message'],
  228. },
  229. Blob: {
  230. properties: {
  231. hash: {
  232. type: 'string',
  233. },
  234. },
  235. required: ['hash'],
  236. },
  237. Author: {
  238. properties: {
  239. id: {
  240. type: 'integer',
  241. },
  242. email: {
  243. type: 'string',
  244. },
  245. name: {
  246. type: 'string',
  247. },
  248. },
  249. required: ['id', 'email', 'name'],
  250. },
  251. SyncState: {
  252. properties: {
  253. synced: {
  254. type: 'boolean',
  255. },
  256. },
  257. },
  258. ZipInfo: {
  259. properties: {
  260. zipUrl: {
  261. type: 'string',
  262. },
  263. },
  264. required: ['zipUrl'],
  265. },
  266. },
  267. }