mirror of
https://github.com/plankanban/planka.git
synced 2025-12-24 17:25:00 +03:00
docs: Add full Swagger JSDoc coverage
This commit is contained in:
@@ -3,6 +3,107 @@
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/users:
|
||||
* post:
|
||||
* summary: Create user
|
||||
* description: Creates a user account. Requires admin privileges.
|
||||
* tags:
|
||||
* - Users
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - email
|
||||
* - password
|
||||
* - role
|
||||
* - name
|
||||
* properties:
|
||||
* email:
|
||||
* type: string
|
||||
* format: email
|
||||
* maxLength: 256
|
||||
* description: Email address for login and notifications
|
||||
* example: john.doe@example.com
|
||||
* password:
|
||||
* type: string
|
||||
* maxLength: 256
|
||||
* description: Password for user authentication (must meet password requirements)
|
||||
* example: SecurePassword123!
|
||||
* role:
|
||||
* type: string
|
||||
* enum: [admin, projectOwner, boardUser]
|
||||
* description: User role defining access permissions
|
||||
* example: admin
|
||||
* name:
|
||||
* type: string
|
||||
* maxLength: 128
|
||||
* description: Full display name of the user
|
||||
* example: John Doe
|
||||
* username:
|
||||
* type: string
|
||||
* minLength: 3
|
||||
* maxLength: 16
|
||||
* pattern: "^[a-zA-Z0-9]+((_{1}|\\.|){1}[a-zA-Z0-9])*$"
|
||||
* nullable: true
|
||||
* description: Unique username for user identification
|
||||
* example: john_doe
|
||||
* phone:
|
||||
* type: string
|
||||
* maxLength: 128
|
||||
* nullable: true
|
||||
* description: Contact phone number
|
||||
* example: +1234567890
|
||||
* organization:
|
||||
* type: string
|
||||
* maxLength: 128
|
||||
* nullable: true
|
||||
* description: Organization or company name
|
||||
* example: Acme Corporation
|
||||
* language:
|
||||
* type: string
|
||||
* enum: [ar-YE, bg-BG, cs-CZ, da-DK, de-DE, el-GR, en-GB, en-US, es-ES, et-EE, fa-IR, fi-FI, fr-FR, hu-HU, id-ID, it-IT, ja-JP, ko-KR, nl-NL, pl-PL, pt-BR, pt-PT, ro-RO, ru-RU, sk-SK, sr-Cyrl-RS, sr-Latn-RS, sv-SE, tr-TR, uk-UA, uz-UZ, zh-CN, zh-TW]
|
||||
* nullable: true
|
||||
* description: Preferred language for user interface and notifications
|
||||
* example: en-US
|
||||
* subscribeToOwnCards:
|
||||
* type: boolean
|
||||
* description: Whether the user subscribes to their own cards
|
||||
* example: false
|
||||
* subscribeToCardWhenCommenting:
|
||||
* type: boolean
|
||||
* description: Whether the user subscribes to cards when commenting
|
||||
* example: true
|
||||
* turnOffRecentCardHighlighting:
|
||||
* type: boolean
|
||||
* description: Whether recent card highlighting is disabled
|
||||
* example: false
|
||||
* responses:
|
||||
* 200:
|
||||
* description: User created successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - item
|
||||
* properties:
|
||||
* item:
|
||||
* $ref: '#/components/schemas/User'
|
||||
* 400:
|
||||
* $ref: '#/components/responses/ValidationError'
|
||||
* 401:
|
||||
* $ref: '#/components/responses/Unauthorized'
|
||||
* 403:
|
||||
* $ref: '#/components/responses/Forbidden'
|
||||
* 409:
|
||||
* $ref: '#/components/responses/Conflict'
|
||||
*/
|
||||
|
||||
const { isPassword } = require('../../../utils/validators');
|
||||
|
||||
const Errors = {
|
||||
|
||||
@@ -3,6 +3,44 @@
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/users/{id}:
|
||||
* delete:
|
||||
* summary: Delete user
|
||||
* description: Deletes a user account. Cannot delete the default admin user. Requires admin privileges.
|
||||
* tags:
|
||||
* - Users
|
||||
* parameters:
|
||||
* - name: id
|
||||
* in: path
|
||||
* required: true
|
||||
* description: ID of the user to delete
|
||||
* schema:
|
||||
* type: string
|
||||
* example: 1357158568008091264
|
||||
* responses:
|
||||
* 200:
|
||||
* description: User deleted successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - item
|
||||
* properties:
|
||||
* item:
|
||||
* $ref: '#/components/schemas/User'
|
||||
* 400:
|
||||
* $ref: '#/components/responses/ValidationError'
|
||||
* 401:
|
||||
* $ref: '#/components/responses/Unauthorized'
|
||||
* 403:
|
||||
* $ref: '#/components/responses/Forbidden'
|
||||
* 404:
|
||||
* $ref: '#/components/responses/NotFound'
|
||||
*/
|
||||
|
||||
const { idInput } = require('../../../utils/inputs');
|
||||
|
||||
const Errors = {
|
||||
|
||||
@@ -3,6 +3,36 @@
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/users:
|
||||
* get:
|
||||
* summary: Get all users
|
||||
* description: Retrieves a list of all users. Requires admin or project owner privileges.
|
||||
* tags:
|
||||
* - Users
|
||||
* responses:
|
||||
* 200:
|
||||
* description: List of users retrieved successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - items
|
||||
* properties:
|
||||
* items:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/User'
|
||||
* 400:
|
||||
* $ref: '#/components/responses/ValidationError'
|
||||
* 401:
|
||||
* $ref: '#/components/responses/Unauthorized'
|
||||
* 403:
|
||||
* $ref: '#/components/responses/Forbidden'
|
||||
*/
|
||||
|
||||
const Errors = {
|
||||
NOT_ENOUGH_RIGHTS: {
|
||||
notEnoughRights: 'Not enough rights',
|
||||
|
||||
@@ -3,6 +3,60 @@
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/users/{id}:
|
||||
* get:
|
||||
* summary: Get user details
|
||||
* description: Retrieves a user. Use 'me' as ID to get the current user.
|
||||
* tags:
|
||||
* - Users
|
||||
* parameters:
|
||||
* - name: id
|
||||
* in: path
|
||||
* required: true
|
||||
* description: ID of the user or 'me' for current user
|
||||
* schema:
|
||||
* type: string
|
||||
* example: 1357158568008091264
|
||||
* - name: subscribe
|
||||
* in: query
|
||||
* required: false
|
||||
* description: Whether to subscribe to real-time updates for this user (only for socket connections)
|
||||
* schema:
|
||||
* type: boolean
|
||||
* example: true
|
||||
* responses:
|
||||
* 200:
|
||||
* description: User details retrieved successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - item
|
||||
* - included
|
||||
* properties:
|
||||
* item:
|
||||
* $ref: '#/components/schemas/User'
|
||||
* included:
|
||||
* type: object
|
||||
* required:
|
||||
* - notificationServices
|
||||
* properties:
|
||||
* notificationServices:
|
||||
* type: array
|
||||
* description: Related notification services (for current user)
|
||||
* items:
|
||||
* $ref: '#/components/schemas/NotificationService'
|
||||
* 400:
|
||||
* $ref: '#/components/responses/ValidationError'
|
||||
* 401:
|
||||
* $ref: '#/components/responses/Unauthorized'
|
||||
* 404:
|
||||
* $ref: '#/components/responses/NotFound'
|
||||
*/
|
||||
|
||||
const { ID_REGEX, MAX_STRING_ID, isIdInRange } = require('../../../utils/validators');
|
||||
|
||||
const Errors = {
|
||||
|
||||
@@ -3,6 +3,57 @@
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/users/{id}/avatar:
|
||||
* patch:
|
||||
* summary: Update user avatar
|
||||
* description: Updates a user's avatar image. Users can update their own avatar, admins can update any user's avatar.
|
||||
* tags:
|
||||
* - Users
|
||||
* parameters:
|
||||
* - name: id
|
||||
* in: path
|
||||
* required: true
|
||||
* description: ID of the user whose avatar to update
|
||||
* schema:
|
||||
* type: string
|
||||
* example: 1357158568008091264
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* multipart/form-data:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - file
|
||||
* properties:
|
||||
* file:
|
||||
* type: string
|
||||
* format: binary
|
||||
* description: Avatar image file (must be an image format)
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Avatar updated successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - item
|
||||
* properties:
|
||||
* item:
|
||||
* $ref: '#/components/schemas/User'
|
||||
* 400:
|
||||
* $ref: '#/components/responses/ValidationError'
|
||||
* 401:
|
||||
* $ref: '#/components/responses/Unauthorized'
|
||||
* 404:
|
||||
* $ref: '#/components/responses/NotFound'
|
||||
* 422:
|
||||
* $ref: '#/components/responses/UnprocessableEntity'
|
||||
*/
|
||||
|
||||
const { idInput } = require('../../../utils/inputs');
|
||||
|
||||
const Errors = {
|
||||
|
||||
@@ -3,6 +3,66 @@
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/users/{id}/email:
|
||||
* patch:
|
||||
* summary: Update user email
|
||||
* description: Updates a user's email address. Users must provide current password when updating their own email. Admins can update any user's email without a password.
|
||||
* tags:
|
||||
* - Users
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* description: ID of the user whose email to update
|
||||
* schema:
|
||||
* type: string
|
||||
* example: 1357158568008091264
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - email
|
||||
* properties:
|
||||
* email:
|
||||
* type: string
|
||||
* format: email
|
||||
* maxLength: 256
|
||||
* description: Email address for login and notifications
|
||||
* example: john.doe@example.com
|
||||
* currentPassword:
|
||||
* type: string
|
||||
* maxLength: 256
|
||||
* description: Current password (required when updating own email)
|
||||
* example: SecurePassword123!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Email updated successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - item
|
||||
* properties:
|
||||
* item:
|
||||
* $ref: '#/components/schemas/User'
|
||||
* 400:
|
||||
* $ref: '#/components/responses/ValidationError'
|
||||
* 401:
|
||||
* $ref: '#/components/responses/Unauthorized'
|
||||
* 403:
|
||||
* $ref: '#/components/responses/Forbidden'
|
||||
* 404:
|
||||
* $ref: '#/components/responses/NotFound'
|
||||
* 409:
|
||||
* $ref: '#/components/responses/Conflict'
|
||||
*/
|
||||
|
||||
const bcrypt = require('bcrypt');
|
||||
|
||||
const { idInput } = require('../../../utils/inputs');
|
||||
|
||||
@@ -3,6 +3,74 @@
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/users/{id}/password:
|
||||
* patch:
|
||||
* summary: Update user password
|
||||
* description: Updates a user's password. Users must provide a current password when updating their own password. Admins can update any user's password without the current password. Returns a new access token when updating own password.
|
||||
* tags:
|
||||
* - Users
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* description: ID of the user whose password to update
|
||||
* schema:
|
||||
* type: string
|
||||
* example: 1357158568008091264
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - password
|
||||
* properties:
|
||||
* password:
|
||||
* type: string
|
||||
* maxLength: 256
|
||||
* description: Password (must meet password requirements)
|
||||
* example: SecurePassword123!
|
||||
* currentPassword:
|
||||
* type: string
|
||||
* maxLength: 256
|
||||
* description: Current password (required when updating own password)
|
||||
* example: SecurePassword456!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Password updated successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - item
|
||||
* properties:
|
||||
* item:
|
||||
* $ref: '#/components/schemas/User'
|
||||
* included:
|
||||
* type: object
|
||||
* required:
|
||||
* - accessTokens
|
||||
* properties:
|
||||
* accessTokens:
|
||||
* type: array
|
||||
* description: New acces tokens (when updating own password)
|
||||
* items:
|
||||
* type: string
|
||||
* example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ4...
|
||||
* 400:
|
||||
* $ref: '#/components/responses/ValidationError'
|
||||
* 401:
|
||||
* $ref: '#/components/responses/Unauthorized'
|
||||
* 403:
|
||||
* $ref: '#/components/responses/Forbidden'
|
||||
* 404:
|
||||
* $ref: '#/components/responses/NotFound'
|
||||
*/
|
||||
|
||||
const bcrypt = require('bcrypt');
|
||||
|
||||
const { isPassword } = require('../../../utils/validators');
|
||||
|
||||
@@ -3,6 +3,66 @@
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/users/{id}/username:
|
||||
* patch:
|
||||
* summary: Update user username
|
||||
* description: Updates a user's username. Users must provide a current password when updating their own username (unless they are SSO users with `oidcIgnoreUsername` enabled). Admins can update any user's username without the current password.
|
||||
* tags:
|
||||
* - Users
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* description: ID of the user whose username to update
|
||||
* schema:
|
||||
* type: string
|
||||
* example: 1357158568008091264
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* username:
|
||||
* type: string
|
||||
* minLength: 3
|
||||
* maxLength: 16
|
||||
* pattern: '^[a-zA-Z0-9]+((_|\.)?[a-zA-Z0-9])*$'
|
||||
* nullable: true
|
||||
* description: Unique username for user identification
|
||||
* example: john_doe
|
||||
* currentPassword:
|
||||
* type: string
|
||||
* maxLength: 256
|
||||
* description: Current password (required when updating own username)
|
||||
* example: SecurePassword123!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Username updated successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - item
|
||||
* properties:
|
||||
* item:
|
||||
* $ref: '#/components/schemas/User'
|
||||
* 400:
|
||||
* $ref: '#/components/responses/ValidationError'
|
||||
* 401:
|
||||
* $ref: '#/components/responses/Unauthorized'
|
||||
* 403:
|
||||
* $ref: '#/components/responses/Forbidden'
|
||||
* 404:
|
||||
* $ref: '#/components/responses/NotFound'
|
||||
* 409:
|
||||
* $ref: '#/components/responses/Conflict'
|
||||
*/
|
||||
|
||||
const bcrypt = require('bcrypt');
|
||||
|
||||
const { idInput } = require('../../../utils/inputs');
|
||||
|
||||
@@ -3,6 +3,120 @@
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/users/{id}:
|
||||
* patch:
|
||||
* summary: Update user
|
||||
* description: Updates a user. Users can update their own profile, admins can update any user.
|
||||
* tags:
|
||||
* - Users
|
||||
* parameters:
|
||||
* - name: id
|
||||
* in: path
|
||||
* required: true
|
||||
* description: ID of the user to update
|
||||
* schema:
|
||||
* type: string
|
||||
* example: 1357158568008091264
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* role:
|
||||
* type: string
|
||||
* enum: [admin, projectOwner, boardUser]
|
||||
* description: User role defining access permissions
|
||||
* example: admin
|
||||
* name:
|
||||
* type: string
|
||||
* maxLength: 128
|
||||
* description: Full display name of the user
|
||||
* example: John Doe
|
||||
* avatar:
|
||||
* type: object
|
||||
* nullable: true
|
||||
* description: Avatar of the user (only null value to remove avatar)
|
||||
* phone:
|
||||
* type: string
|
||||
* maxLength: 128
|
||||
* nullable: true
|
||||
* description: Contact phone number
|
||||
* example: +1234567890
|
||||
* organization:
|
||||
* type: string
|
||||
* maxLength: 128
|
||||
* nullable: true
|
||||
* description: Organization or company name
|
||||
* example: Acme Corporation
|
||||
* language:
|
||||
* type: string
|
||||
* enum: [ar-YE, bg-BG, cs-CZ, da-DK, de-DE, el-GR, en-GB, en-US, es-ES, et-EE, fa-IR, fi-FI, fr-FR, hu-HU, id-ID, it-IT, ja-JP, ko-KR, nl-NL, pl-PL, pt-BR, pt-PT, ro-RO, ru-RU, sk-SK, sr-Cyrl-RS, sr-Latn-RS, sv-SE, tr-TR, uk-UA, uz-UZ, zh-CN, zh-TW]
|
||||
* nullable: true
|
||||
* description: Preferred language for user interface and notifications
|
||||
* example: en-US
|
||||
* subscribeToOwnCards:
|
||||
* type: boolean
|
||||
* description: Whether the user subscribes to their own cards
|
||||
* example: false
|
||||
* subscribeToCardWhenCommenting:
|
||||
* type: boolean
|
||||
* description: Whether the user subscribes to cards when commenting
|
||||
* example: true
|
||||
* turnOffRecentCardHighlighting:
|
||||
* type: boolean
|
||||
* description: Whether recent card highlighting is disabled
|
||||
* example: false
|
||||
* enableFavoritesByDefault:
|
||||
* type: boolean
|
||||
* description: Whether favorites are enabled by default
|
||||
* example: false
|
||||
* defaultEditorMode:
|
||||
* type: string
|
||||
* enum: [wysiwyg, markup]
|
||||
* description: Default markdown editor mode
|
||||
* example: wysiwyg
|
||||
* defaultHomeView:
|
||||
* type: string
|
||||
* enum: [gridProjects, groupedProjects]
|
||||
* description: Default view mode for the home page
|
||||
* example: groupedProjects
|
||||
* defaultProjectsOrder:
|
||||
* type: string
|
||||
* enum: [byDefault, alphabetically, byCreationTime]
|
||||
* description: Default sort order for projects display
|
||||
* example: byDefault
|
||||
* isDeactivated:
|
||||
* type: boolean
|
||||
* description: Whether the user account is deactivated and cannot log in (for admins)
|
||||
* example: false
|
||||
* responses:
|
||||
* 200:
|
||||
* description: User updated successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - item
|
||||
* properties:
|
||||
* item:
|
||||
* $ref: '#/components/schemas/User'
|
||||
* 400:
|
||||
* $ref: '#/components/responses/ValidationError'
|
||||
* 401:
|
||||
* $ref: '#/components/responses/Unauthorized'
|
||||
* 403:
|
||||
* $ref: '#/components/responses/Forbidden'
|
||||
* 404:
|
||||
* $ref: '#/components/responses/NotFound'
|
||||
* 409:
|
||||
* $ref: '#/components/responses/Conflict'
|
||||
*/
|
||||
|
||||
const { idInput } = require('../../../utils/inputs');
|
||||
|
||||
const Errors = {
|
||||
|
||||
Reference in New Issue
Block a user