PageRenderTime 58ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/homework_openapi.yaml

https://gitlab.com/ngquocvu/nodejs-hw2
YAML | 481 lines | 481 code | 0 blank | 0 comment | 0 complexity | f6870298ea68225f71ab2e759a74f37f MD5 | raw file
  1. swagger: "2.0"
  2. info:
  3. description: "Homework description"
  4. version: "1.0.0"
  5. title: "LAB FE 14 NodeJS HW #2"
  6. termsOfService: "http://swagger.io/terms/"
  7. contact:
  8. email: "Kyrylo_Yezhov@epam.com"
  9. host: "localhost:8080"
  10. basePath: "/"
  11. tags:
  12. - name: "User"
  13. description: "Everything about your User"
  14. externalDocs:
  15. description: "Find out more"
  16. url: "http://swagger.io"
  17. - name: "Notes"
  18. description: "Access to Users notes"
  19. schemes:
  20. - "http"
  21. paths:
  22. /api/users/me:
  23. get:
  24. tags:
  25. - "User"
  26. summary: "Get user's profile info"
  27. description: "User can request only his own profile info"
  28. operationId: "getProfileInfo"
  29. consumes:
  30. - "application/json"
  31. produces:
  32. - "application/json"
  33. responses:
  34. "200":
  35. description: "Success"
  36. schema:
  37. type: object
  38. properties:
  39. user:
  40. $ref: '#/definitions/User'
  41. "400":
  42. description: "Bad request"
  43. schema:
  44. $ref: '#/definitions/Error'
  45. "500":
  46. description: "Internal server error"
  47. schema:
  48. $ref: '#/definitions/Error'
  49. security:
  50. - jwt_token: []
  51. delete:
  52. tags:
  53. - "User"
  54. summary: "Delete user's profile"
  55. description: "User can delete only his own profile info"
  56. operationId: "deleteProfile"
  57. consumes:
  58. - "application/json"
  59. produces:
  60. - "application/json"
  61. responses:
  62. "200":
  63. description: "Success"
  64. schema:
  65. type: "object"
  66. properties:
  67. message:
  68. type: string
  69. example: "Success"
  70. "400":
  71. description: "Bad request"
  72. schema:
  73. $ref: '#/definitions/Error'
  74. "500":
  75. description: "Internal server error"
  76. schema:
  77. $ref: '#/definitions/Error'
  78. security:
  79. - jwt_token: []
  80. patch:
  81. tags:
  82. - "User"
  83. summary: "Change user's password"
  84. description: "Change user's password"
  85. operationId: "changeProfilePassword"
  86. consumes:
  87. - "application/json"
  88. produces:
  89. - "application/json"
  90. parameters:
  91. - in: "body"
  92. name: "new_password"
  93. schema:
  94. type: "object"
  95. required:
  96. - oldPassword
  97. - newPassword
  98. properties:
  99. oldPassword:
  100. type: string
  101. newPassword:
  102. type: string
  103. responses:
  104. "200":
  105. description: "Success"
  106. schema:
  107. type: "object"
  108. properties:
  109. message:
  110. type: string
  111. example: "Success"
  112. "400":
  113. description: "Bad request"
  114. schema:
  115. $ref: '#/definitions/Error'
  116. "500":
  117. description: "Internal server error"
  118. schema:
  119. $ref: '#/definitions/Error'
  120. security:
  121. - jwt_token: []
  122. /api/auth/register:
  123. post:
  124. tags:
  125. - "Auth"
  126. summary: "Register a new user"
  127. description: "Create new profile"
  128. operationId: "createProfile"
  129. consumes:
  130. - "application/json"
  131. produces:
  132. - "application/json"
  133. parameters:
  134. - in: "body"
  135. name: "credentials"
  136. required: true
  137. schema:
  138. $ref: "#/definitions/Credentials"
  139. responses:
  140. "200":
  141. description: "Success"
  142. schema:
  143. type: "object"
  144. properties:
  145. message:
  146. type: string
  147. example: "Success"
  148. "400":
  149. description: "Bad request"
  150. schema:
  151. $ref: '#/definitions/Error'
  152. "500":
  153. description: "Internal server error"
  154. schema:
  155. $ref: '#/definitions/Error'
  156. /api/auth/login:
  157. post:
  158. tags:
  159. - "Auth"
  160. summary: "Login"
  161. description: "Login into the system"
  162. operationId: "login"
  163. consumes:
  164. - "application/json"
  165. produces:
  166. - "application/json"
  167. parameters:
  168. - in: "body"
  169. name: "credentials"
  170. required: true
  171. schema:
  172. $ref: "#/definitions/Credentials"
  173. responses:
  174. "200":
  175. description: "Success"
  176. schema:
  177. type: "object"
  178. properties:
  179. message:
  180. type: string
  181. example: "Success"
  182. jwt_token:
  183. type: string
  184. example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0b3B0YWwuY29tIiwiZXhwIjoxNDI2NDIwODAwLCJodHRwOi8vdG9wdGFsLmNvbS9qd3RfY2xhaW1zL2lzX2FkbWluIjp0cnVlLCJjb21wYW55IjoiVG9wdGFsIiwiYXdlc29tZSI6dHJ1ZX0.yRQYnWzskCZUxPwaQupWkiUzKELZ49eM7oWxAQK_ZXw"
  185. "400":
  186. description: "Bad request"
  187. schema:
  188. $ref: '#/definitions/Error'
  189. "500":
  190. description: "Internal server error"
  191. schema:
  192. $ref: '#/definitions/Error'
  193. /api/notes:
  194. get:
  195. tags:
  196. - "Notes"
  197. summary: "Get user's notes"
  198. description: "Retrieve the list of notes for authorized user"
  199. operationId: "getUserNotes"
  200. parameters:
  201. - in: query
  202. name: offset
  203. type: integer
  204. description: The number of items to skip before starting to collect the result set.
  205. - in: query
  206. name: limit
  207. type: integer
  208. description: The numbers of items to return.
  209. consumes:
  210. - "application/json"
  211. produces:
  212. - "application/json"
  213. responses:
  214. "200":
  215. description: "Success"
  216. schema:
  217. type: "object"
  218. properties:
  219. offset:
  220. type: integer
  221. limit:
  222. type: integer
  223. count:
  224. type: integer
  225. description: "Total notes value(for user)"
  226. notes:
  227. type: array
  228. items:
  229. $ref: "#/definitions/Note"
  230. "400":
  231. description: "Bad request"
  232. schema:
  233. $ref: '#/definitions/Error'
  234. "500":
  235. description: "Internal server error"
  236. schema:
  237. $ref: '#/definitions/Error'
  238. security:
  239. - jwt_token: []
  240. post:
  241. tags:
  242. - "Notes"
  243. summary: "Add Note for User"
  244. description: "Add Note for User"
  245. operationId: "addUserNotes"
  246. consumes:
  247. - "application/json"
  248. produces:
  249. - "application/json"
  250. parameters:
  251. - in: "body"
  252. name: "Note payload"
  253. schema:
  254. required:
  255. - text
  256. properties:
  257. text:
  258. type: "string"
  259. responses:
  260. "200":
  261. description: "Success"
  262. schema:
  263. type: "object"
  264. properties:
  265. message:
  266. type: string
  267. example: "Success"
  268. "400":
  269. description: "Bad request"
  270. schema:
  271. $ref: '#/definitions/Error'
  272. "500":
  273. description: "Internal server error"
  274. schema:
  275. $ref: '#/definitions/Error'
  276. security:
  277. - jwt_token: []
  278. /api/notes/{id}:
  279. get:
  280. tags:
  281. - "Notes"
  282. summary: "Get user's note by id"
  283. description: "Get user's note by id"
  284. operationId: "getUserNoteById"
  285. consumes:
  286. - "application/json"
  287. produces:
  288. - "application/json"
  289. parameters:
  290. - in: "path"
  291. name: "id"
  292. description: "Note's id"
  293. required: true
  294. type: string
  295. responses:
  296. "200":
  297. description: "Success"
  298. schema:
  299. type: object
  300. properties:
  301. note:
  302. $ref: '#/definitions/Note'
  303. "400":
  304. description: "Bad request"
  305. schema:
  306. $ref: '#/definitions/Error'
  307. "500":
  308. description: "Internal server error"
  309. schema:
  310. $ref: '#/definitions/Error'
  311. security:
  312. - jwt_token: []
  313. put:
  314. tags:
  315. - "Notes"
  316. summary: "Update user's note by id"
  317. description: "Update user's note by id"
  318. operationId: "updateUserNoteById"
  319. consumes:
  320. - "application/json"
  321. produces:
  322. - "application/json"
  323. parameters:
  324. - in: "path"
  325. name: "id"
  326. description: "Note's id"
  327. required: true
  328. type: string
  329. - in: "body"
  330. name: "Note payload"
  331. schema:
  332. required:
  333. - text
  334. properties:
  335. text:
  336. type: "string"
  337. responses:
  338. "200":
  339. description: "Success"
  340. schema:
  341. type: "object"
  342. properties:
  343. message:
  344. type: string
  345. example: "Success"
  346. "400":
  347. description: "Bad request"
  348. schema:
  349. $ref: '#/definitions/Error'
  350. "500":
  351. description: "Internal server error"
  352. schema:
  353. $ref: '#/definitions/Error'
  354. security:
  355. - jwt_token: []
  356. patch:
  357. tags:
  358. - "Notes"
  359. summary: "Check/uncheck user's note by id"
  360. description: "Check/uncheck user's note by id, value for completed field should be changed to opposite"
  361. operationId: "toggleCompletedForUserNoteById"
  362. consumes:
  363. - "application/json"
  364. produces:
  365. - "application/json"
  366. parameters:
  367. - in: "path"
  368. name: "id"
  369. description: "Note's id"
  370. required: true
  371. type: string
  372. responses:
  373. "200":
  374. description: "Success"
  375. schema:
  376. type: "object"
  377. properties:
  378. message:
  379. type: string
  380. example: "Success"
  381. "400":
  382. description: "Bad request"
  383. schema:
  384. $ref: '#/definitions/Error'
  385. "500":
  386. description: "Internal server error"
  387. schema:
  388. $ref: '#/definitions/Error'
  389. security:
  390. - jwt_token: []
  391. delete:
  392. tags:
  393. - "Notes"
  394. summary: "Delete user's note by id"
  395. description: "Delete user's note by id"
  396. operationId: "deleteUserNoteById"
  397. consumes:
  398. - "application/json"
  399. produces:
  400. - "application/json"
  401. parameters:
  402. - in: "path"
  403. name: "id"
  404. description: "Note's id"
  405. required: true
  406. type: string
  407. responses:
  408. "200":
  409. description: "Success"
  410. schema:
  411. type: "object"
  412. properties:
  413. message:
  414. type: string
  415. example: "Success"
  416. "400":
  417. description: "Bad request"
  418. schema:
  419. $ref: '#/definitions/Error'
  420. "500":
  421. description: "Internal server error"
  422. schema:
  423. $ref: '#/definitions/Error'
  424. security:
  425. - jwt_token: []
  426. securityDefinitions:
  427. jwt_token:
  428. type: "apiKey"
  429. name: "Authorization"
  430. in: "header"
  431. definitions:
  432. Error:
  433. type: "object"
  434. properties:
  435. message:
  436. type: "string"
  437. description: "Error message"
  438. Credentials:
  439. type: "object"
  440. properties:
  441. username:
  442. type: "string"
  443. example: "Kyrylo"
  444. password:
  445. type: "string"
  446. example: "ve518dl3"
  447. User:
  448. type: "object"
  449. properties:
  450. _id:
  451. type: "string"
  452. example: "5099803df3f4948bd2f98391"
  453. username:
  454. type: "string"
  455. example: "Kyrylo"
  456. createdDate:
  457. type: "string"
  458. format: "date"
  459. example: "2020-10-28T08:03:19.814Z"
  460. Note:
  461. type: "object"
  462. properties:
  463. _id:
  464. type: "string"
  465. example: "5099803df3f4948bd2f98391"
  466. userId:
  467. type: "string"
  468. example: "5099803df3f4948bd2f98391"
  469. completed:
  470. type: "boolean"
  471. example: false
  472. text:
  473. type: "string"
  474. example: "Complete second homework"
  475. createdDate:
  476. type: "string"
  477. format: "date"
  478. example: "2020-10-28T08:03:19.814Z"
  479. externalDocs:
  480. description: "Find out more about Swagger"
  481. url: "http://swagger.io"