Refactor User Management API and Update Documentation

- Changed API tags from "Admin-Users" to "Admin-Authorization" for better clarity in user management endpoints.
- Removed unused endpoints for retrieving users by company ID and role, streamlining the user management functionality.
- Updated user entity and forms to reflect new example values for improved clarity in API documentation.
- Enhanced pagination handling in user listing responses, ensuring consistent metadata structure.
- Updated API documentation to reflect changes in endpoint structure and response formats, improving clarity for API consumers.
This commit is contained in:
n.nakhostin
2025-09-06 14:00:22 +03:30
parent eb69a842f0
commit 38844939b5
11 changed files with 567 additions and 1734 deletions
+25 -209
View File
@@ -1121,11 +1121,11 @@ definitions:
properties:
new_password:
description: New password (minimum 8 characters)
example: NewPass456!
example: NewAdmin!1234
type: string
old_password:
description: Current password for verification
example: OldPassword123!
example: Admin!1234
type: string
type: object
user.CreateUserForm:
@@ -1136,46 +1136,46 @@ definitions:
type: string
email:
description: Valid email address
example: john.smith@company.com
example: admin@opplens.com
type: string
full_name:
description: Full name of the user
example: John Smith
example: Admin User
type: string
password:
description: Password (minimum 8 characters)
example: SecurePass123!
example: Admin!1234
type: string
phone:
description: Optional phone number
example: "+1234567890"
example: "+18289784438"
type: string
position:
description: Optional job position
example: Senior Developer
example: Lead
type: string
profile_image:
description: Optional profile image URL
example: https://example.com/avatar.jpg
example: ""
type: string
role:
description: User role (admin, manager, operator, viewer)
example: manager
example: admin
type: string
username:
description: Unique username (alphanumeric only)
example: johnsmith
example: admin
type: string
type: object
user.LoginForm:
properties:
password:
description: User password
example: Nima.1998
example: Admin!1234
type: string
username:
description: Username or email address
example: nakhostin
example: admin
type: string
type: object
user.RefreshTokenForm:
@@ -1189,55 +1189,42 @@ definitions:
properties:
email:
description: Email address for password reset
example: john.smith@company.com
example: admin@opplens.com
type: string
type: object
user.UpdateUserForm:
properties:
company_id:
description: Updated company ID
example: 123e4567-e89b-12d3-a456-426614174000
type: string
department:
description: Updated department
example: Product Management
example: Information Technology
type: string
email:
description: Updated email address
example: john.smith@newcompany.com
example: admin@opplens.com
type: string
full_name:
description: Updated full name
example: John Smith
example: Admin User
type: string
phone:
description: Updated phone number
example: "+1234567890"
example: "+18289784438"
type: string
position:
description: Updated position
example: Tech Lead
example: Lead
type: string
profile_image:
description: Updated profile image URL
example: https://example.com/new-avatar.jpg
example: ""
type: string
role:
description: Updated user role
example: admin
type: string
status:
description: Updated account status
example: active
type: string
username:
description: Updated username
example: johnsmith
type: string
type: object
user.UpdateUserRoleForm:
properties:
role:
example: admin
type: string
type: object
user.UpdateUserStatusForm:
@@ -1247,14 +1234,8 @@ definitions:
type: object
user.UserListResponse:
properties:
limit:
type: integer
offset:
type: integer
total:
type: integer
total_pages:
type: integer
meta:
$ref: '#/definitions/response.Meta'
users:
items:
$ref: '#/definitions/user.UserResponse'
@@ -1262,12 +1243,8 @@ definitions:
type: object
user.UserResponse:
properties:
company_id:
type: string
created_at:
type: integer
created_by:
type: string
department:
type: string
email:
@@ -1292,8 +1269,6 @@ definitions:
type: string
updated_at:
type: integer
updated_by:
type: string
username:
type: string
type: object
@@ -3521,7 +3496,7 @@ paths:
- BearerAuth: []
summary: Get authenticated user profile
tags:
- Admin-Users
- Admin-Authorization
put:
consumes:
- application/json
@@ -3572,7 +3547,7 @@ paths:
- BearerAuth: []
summary: Update authenticated user profile
tags:
- Admin-Users
- Admin-Authorization
/admin/v1/profile/change-password:
put:
consumes:
@@ -3616,7 +3591,7 @@ paths:
- BearerAuth: []
summary: Change user password
tags:
- Admin-Users
- Admin-Authorization
/admin/v1/profile/login:
post:
consumes:
@@ -4070,10 +4045,6 @@ paths:
in: query
name: role
type: string
- description: Company ID filter
in: query
name: company_id
type: string
- description: Limit results
in: query
name: limit
@@ -4322,55 +4293,6 @@ paths:
summary: Update user
tags:
- Admin-Users
/admin/v1/users/{id}/role:
put:
consumes:
- application/json
description: Update user role (admin only)
parameters:
- description: User ID
in: path
name: id
required: true
type: string
- description: Role update data
in: body
name: role
required: true
schema:
$ref: '#/definitions/user.UpdateUserRoleForm'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.APIResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.APIResponse'
"403":
description: Forbidden
schema:
$ref: '#/definitions/response.APIResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Update user role
tags:
- Admin-Users
/admin/v1/users/{id}/status:
put:
consumes:
@@ -4420,112 +4342,6 @@ paths:
summary: Update user status
tags:
- Admin-Users
/admin/v1/users/company/{company_id}:
get:
consumes:
- application/json
description: Get users belonging to a specific company (admin only)
parameters:
- description: Company ID
in: path
name: company_id
required: true
type: string
- description: Limit results
in: query
name: limit
type: integer
- description: Offset results
in: query
name: offset
type: integer
produces:
- application/json
responses:
"200":
description: Users with pagination metadata
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
additionalProperties: true
type: object
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.APIResponse'
"403":
description: Forbidden
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Get users by company ID
tags:
- Admin-Users
/admin/v1/users/role/{role}:
get:
consumes:
- application/json
description: Get users with a specific role (admin only)
parameters:
- description: User role
in: path
name: role
required: true
type: string
- description: Limit results
in: query
name: limit
type: integer
- description: Offset results
in: query
name: offset
type: integer
produces:
- application/json
responses:
"200":
description: Users with pagination metadata
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
additionalProperties: true
type: object
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.APIResponse'
"403":
description: Forbidden
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Get users by role
tags:
- Admin-Users
/api/v1/companies:
get:
consumes: