user.yaml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. post:
  2. summary: Create a new user
  3. operationId: createUser
  4. tags:
  5. - Users
  6. requestBody:
  7. required: true
  8. content:
  9. application/json:
  10. schema:
  11. type: object
  12. required:
  13. - name
  14. - email
  15. - password
  16. - confirm_password
  17. properties:
  18. name:
  19. type: string
  20. example: Lee
  21. email:
  22. type: string
  23. format: email
  24. example: lee@example.com
  25. password:
  26. type: string
  27. minLength: 12
  28. example: supersecret123
  29. confirm_password:
  30. type: string
  31. minLength: 12
  32. example: supersecret123
  33. responses:
  34. '201':
  35. description: User created successfully.
  36. content:
  37. application/json:
  38. schema:
  39. $ref: '../components/schemas/SuccessResponse.yaml'
  40. '400':
  41. description: Validation error (invalid email, passwords do not match, or password too short).
  42. content:
  43. application/json:
  44. schema:
  45. $ref: '../components/schemas/ErrorResponse.yaml'
  46. examples:
  47. invalidEmail:
  48. summary: Invalid email address
  49. value:
  50. error: Invalid email address
  51. passwordMismatch:
  52. summary: Passwords do not match
  53. value:
  54. error: Passwords do not match
  55. passwordTooShort:
  56. summary: Password too short
  57. value:
  58. error: Password must be at least 12 characters
  59. '409':
  60. description: Email already in use.
  61. content:
  62. application/json:
  63. schema:
  64. $ref: '../components/schemas/ErrorResponse.yaml'
  65. example:
  66. error: Email already in use
  67. '500':
  68. description: Internal server error.
  69. content:
  70. application/json:
  71. schema:
  72. $ref: '../components/schemas/ErrorResponse.yaml'
  73. get:
  74. summary: Get the current user
  75. operationId: getUser
  76. tags:
  77. - Users
  78. security:
  79. - cookieAuth: []
  80. responses:
  81. '200':
  82. description: Current user data.
  83. content:
  84. application/json:
  85. schema:
  86. type: object
  87. required:
  88. - id
  89. - name
  90. - email
  91. properties:
  92. id:
  93. type: string
  94. format: uuid
  95. example: 0191a23b-dead-7000-beef-000000000001
  96. name:
  97. type: string
  98. example: Lee
  99. email:
  100. type: string
  101. format: email
  102. example: lee@example.com
  103. '401':
  104. description: Missing or invalid auth token.
  105. content:
  106. application/json:
  107. schema:
  108. $ref: '../components/schemas/ErrorResponse.yaml'
  109. examples:
  110. missing:
  111. summary: No cookie present
  112. value:
  113. error: Missing auth token
  114. invalid:
  115. summary: Token invalid or expired
  116. value:
  117. error: Invalid auth token