index.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. ProjectBlobStats: {
  34. properties: {
  35. projectId: {
  36. type: 'string',
  37. },
  38. textBlobBytes: {
  39. type: 'integer',
  40. },
  41. binaryBlobBytes: {
  42. type: 'integer',
  43. },
  44. totalBytes: {
  45. type: 'integer',
  46. },
  47. nTextBlobs: {
  48. type: 'integer',
  49. },
  50. nBinaryBlobs: {
  51. type: 'integer',
  52. },
  53. },
  54. },
  55. File: {
  56. properties: {
  57. hash: {
  58. type: 'string',
  59. },
  60. byteLength: {
  61. type: 'integer',
  62. },
  63. stringLength: {
  64. type: 'integer',
  65. },
  66. },
  67. },
  68. Label: {
  69. properties: {
  70. authorId: {
  71. type: 'integer',
  72. },
  73. text: {
  74. type: 'string',
  75. },
  76. timestamp: {
  77. type: 'string',
  78. },
  79. version: {
  80. type: 'integer',
  81. },
  82. },
  83. },
  84. Chunk: {
  85. properties: {
  86. history: {
  87. $ref: '#/definitions/History',
  88. },
  89. startVersion: {
  90. type: 'number',
  91. },
  92. },
  93. },
  94. ChunkResponse: {
  95. properties: {
  96. chunk: {
  97. $ref: '#/definitions/Chunk',
  98. },
  99. authors: {
  100. type: 'array',
  101. items: {
  102. $ref: '#/definitions/Author',
  103. },
  104. },
  105. },
  106. },
  107. ChunkResponseRaw: {
  108. properties: {
  109. startVersion: {
  110. type: 'number',
  111. },
  112. endVersion: {
  113. type: 'number',
  114. },
  115. endTimestamp: {
  116. type: 'string',
  117. },
  118. },
  119. },
  120. History: {
  121. properties: {
  122. snapshot: {
  123. $ref: '#/definitions/Snapshot',
  124. },
  125. changes: {
  126. type: 'array',
  127. items: {
  128. $ref: '#/definitions/Change',
  129. },
  130. },
  131. },
  132. },
  133. Snapshot: {
  134. properties: {
  135. files: {
  136. type: 'object',
  137. additionalProperties: {
  138. $ref: '#/definitions/File',
  139. },
  140. },
  141. },
  142. required: ['files'],
  143. },
  144. Change: {
  145. properties: {
  146. timestamp: {
  147. type: 'string',
  148. },
  149. operations: {
  150. type: 'array',
  151. items: {
  152. $ref: '#/definitions/Operation',
  153. },
  154. },
  155. authors: {
  156. type: 'array',
  157. items: {
  158. type: ['integer', 'null'],
  159. },
  160. },
  161. v2Authors: {
  162. type: 'array',
  163. items: {
  164. type: ['string', 'null'],
  165. },
  166. },
  167. projectVersion: {
  168. type: 'string',
  169. },
  170. v2DocVersions: {
  171. type: 'object',
  172. additionalProperties: {
  173. $ref: '#/definitions/V2DocVersions',
  174. },
  175. },
  176. },
  177. required: ['timestamp', 'operations'],
  178. },
  179. V2DocVersions: {
  180. properties: {
  181. pathname: {
  182. type: 'string',
  183. },
  184. v: {
  185. type: 'integer',
  186. },
  187. },
  188. },
  189. ChangeRequest: {
  190. properties: {
  191. baseVersion: {
  192. type: 'integer',
  193. },
  194. untransformable: {
  195. type: 'boolean',
  196. },
  197. operations: {
  198. type: 'array',
  199. items: {
  200. $ref: '#/definitions/Operation',
  201. },
  202. },
  203. authors: {
  204. type: 'array',
  205. items: {
  206. type: ['integer', 'null'],
  207. },
  208. },
  209. },
  210. required: ['baseVersion', 'operations'],
  211. },
  212. ChangeNote: {
  213. properties: {
  214. baseVersion: {
  215. type: 'integer',
  216. },
  217. change: {
  218. $ref: '#/definitions/Change',
  219. },
  220. },
  221. required: ['baseVersion'],
  222. },
  223. Operation: {
  224. properties: {
  225. pathname: {
  226. type: 'string',
  227. },
  228. newPathname: {
  229. type: 'string',
  230. },
  231. blob: {
  232. $ref: '#/definitions/Blob',
  233. },
  234. textOperation: {
  235. type: 'array',
  236. items: {},
  237. },
  238. file: {
  239. $ref: '#/definitions/File',
  240. },
  241. },
  242. },
  243. Error: {
  244. properties: {
  245. message: {
  246. type: 'string',
  247. },
  248. },
  249. required: ['message'],
  250. },
  251. Blob: {
  252. properties: {
  253. hash: {
  254. type: 'string',
  255. },
  256. },
  257. required: ['hash'],
  258. },
  259. Author: {
  260. properties: {
  261. id: {
  262. type: 'integer',
  263. },
  264. email: {
  265. type: 'string',
  266. },
  267. name: {
  268. type: 'string',
  269. },
  270. },
  271. required: ['id', 'email', 'name'],
  272. },
  273. SyncState: {
  274. properties: {
  275. synced: {
  276. type: 'boolean',
  277. },
  278. },
  279. },
  280. ZipInfo: {
  281. properties: {
  282. zipUrl: {
  283. type: 'string',
  284. },
  285. },
  286. required: ['zipUrl'],
  287. },
  288. },
  289. }