index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. History: {
  86. properties: {
  87. snapshot: {
  88. $ref: '#/definitions/Snapshot',
  89. },
  90. changes: {
  91. type: 'array',
  92. items: {
  93. $ref: '#/definitions/Change',
  94. },
  95. },
  96. },
  97. },
  98. Snapshot: {
  99. properties: {
  100. files: {
  101. type: 'object',
  102. additionalProperties: {
  103. $ref: '#/definitions/File',
  104. },
  105. },
  106. },
  107. required: ['files'],
  108. },
  109. Change: {
  110. properties: {
  111. timestamp: {
  112. type: 'string',
  113. },
  114. operations: {
  115. type: 'array',
  116. items: {
  117. $ref: '#/definitions/Operation',
  118. },
  119. },
  120. authors: {
  121. type: 'array',
  122. items: {
  123. type: ['integer', 'null'],
  124. },
  125. },
  126. v2Authors: {
  127. type: 'array',
  128. items: {
  129. type: ['string', 'null'],
  130. },
  131. },
  132. projectVersion: {
  133. type: 'string',
  134. },
  135. v2DocVersions: {
  136. type: 'object',
  137. additionalProperties: {
  138. $ref: '#/definitions/V2DocVersions',
  139. },
  140. },
  141. },
  142. required: ['timestamp', 'operations'],
  143. },
  144. V2DocVersions: {
  145. properties: {
  146. pathname: {
  147. type: 'string',
  148. },
  149. v: {
  150. type: 'integer',
  151. },
  152. },
  153. },
  154. ChangeRequest: {
  155. properties: {
  156. baseVersion: {
  157. type: 'integer',
  158. },
  159. untransformable: {
  160. type: 'boolean',
  161. },
  162. operations: {
  163. type: 'array',
  164. items: {
  165. $ref: '#/definitions/Operation',
  166. },
  167. },
  168. authors: {
  169. type: 'array',
  170. items: {
  171. type: ['integer', 'null'],
  172. },
  173. },
  174. },
  175. required: ['baseVersion', 'operations'],
  176. },
  177. ChangeNote: {
  178. properties: {
  179. baseVersion: {
  180. type: 'integer',
  181. },
  182. change: {
  183. $ref: '#/definitions/Change',
  184. },
  185. },
  186. required: ['baseVersion'],
  187. },
  188. Operation: {
  189. properties: {
  190. pathname: {
  191. type: 'string',
  192. },
  193. newPathname: {
  194. type: 'string',
  195. },
  196. blob: {
  197. $ref: '#/definitions/Blob',
  198. },
  199. textOperation: {
  200. type: 'array',
  201. items: {},
  202. },
  203. file: {
  204. $ref: '#/definitions/File',
  205. },
  206. },
  207. },
  208. Error: {
  209. properties: {
  210. message: {
  211. type: 'string',
  212. },
  213. },
  214. required: ['message'],
  215. },
  216. Blob: {
  217. properties: {
  218. hash: {
  219. type: 'string',
  220. },
  221. },
  222. required: ['hash'],
  223. },
  224. Author: {
  225. properties: {
  226. id: {
  227. type: 'integer',
  228. },
  229. email: {
  230. type: 'string',
  231. },
  232. name: {
  233. type: 'string',
  234. },
  235. },
  236. required: ['id', 'email', 'name'],
  237. },
  238. SyncState: {
  239. properties: {
  240. synced: {
  241. type: 'boolean',
  242. },
  243. },
  244. },
  245. ZipInfo: {
  246. properties: {
  247. zipUrl: {
  248. type: 'string',
  249. },
  250. },
  251. required: ['zipUrl'],
  252. },
  253. },
  254. }