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 -315
View File
@@ -3449,7 +3449,7 @@
"application/json"
],
"tags": [
"Admin-Users"
"Admin-Authorization"
],
"summary": "Get authenticated user profile",
"responses": {
@@ -3505,7 +3505,7 @@
"application/json"
],
"tags": [
"Admin-Users"
"Admin-Authorization"
],
"summary": "Update authenticated user profile",
"parameters": [
@@ -3586,7 +3586,7 @@
"application/json"
],
"tags": [
"Admin-Users"
"Admin-Authorization"
],
"summary": "Change user password",
"parameters": [
@@ -4347,12 +4347,6 @@
"name": "role",
"in": "query"
},
{
"type": "string",
"description": "Company ID filter",
"name": "company_id",
"in": "query"
},
{
"type": "integer",
"description": "Limit results",
@@ -4509,178 +4503,6 @@
}
}
},
"/admin/v1/users/company/{company_id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get users belonging to a specific company (admin only)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Users"
],
"summary": "Get users by company ID",
"parameters": [
{
"type": "string",
"description": "Company ID",
"name": "company_id",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "Limit results",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset results",
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "Users with pagination metadata",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "object",
"additionalProperties": true
}
}
}
]
}
},
"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"
}
}
}
}
},
"/admin/v1/users/role/{role}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get users with a specific role (admin only)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Users"
],
"summary": "Get users by role",
"parameters": [
{
"type": "string",
"description": "User role",
"name": "role",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "Limit results",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset results",
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "Users with pagination metadata",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "object",
"additionalProperties": true
}
}
}
]
}
},
"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"
}
}
}
}
},
"/admin/v1/users/{id}": {
"get": {
"security": [
@@ -4911,82 +4733,6 @@
}
}
},
"/admin/v1/users/{id}/role": {
"put": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update user role (admin only)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Users"
],
"summary": "Update user role",
"parameters": [
{
"type": "string",
"description": "User ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Role update data",
"name": "role",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/user.UpdateUserRoleForm"
}
}
],
"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"
}
}
}
}
},
"/admin/v1/users/{id}/status": {
"put": {
"security": [
@@ -8295,12 +8041,12 @@
"new_password": {
"description": "New password (minimum 8 characters)",
"type": "string",
"example": "NewPass456!"
"example": "NewAdmin!1234"
},
"old_password": {
"description": "Current password for verification",
"type": "string",
"example": "OldPassword123!"
"example": "Admin!1234"
}
}
},
@@ -8315,42 +8061,42 @@
"email": {
"description": "Valid email address",
"type": "string",
"example": "john.smith@company.com"
"example": "admin@opplens.com"
},
"full_name": {
"description": "Full name of the user",
"type": "string",
"example": "John Smith"
"example": "Admin User"
},
"password": {
"description": "Password (minimum 8 characters)",
"type": "string",
"example": "SecurePass123!"
"example": "Admin!1234"
},
"phone": {
"description": "Optional phone number",
"type": "string",
"example": "+1234567890"
"example": "+18289784438"
},
"position": {
"description": "Optional job position",
"type": "string",
"example": "Senior Developer"
"example": "Lead"
},
"profile_image": {
"description": "Optional profile image URL",
"type": "string",
"example": "https://example.com/avatar.jpg"
"example": ""
},
"role": {
"description": "User role (admin, manager, operator, viewer)",
"type": "string",
"example": "manager"
"example": "admin"
},
"username": {
"description": "Unique username (alphanumeric only)",
"type": "string",
"example": "johnsmith"
"example": "admin"
}
}
},
@@ -8360,12 +8106,12 @@
"password": {
"description": "User password",
"type": "string",
"example": "Nima.1998"
"example": "Admin!1234"
},
"username": {
"description": "Username or email address",
"type": "string",
"example": "nakhostin"
"example": "admin"
}
}
},
@@ -8385,70 +8131,52 @@
"email": {
"description": "Email address for password reset",
"type": "string",
"example": "john.smith@company.com"
"example": "admin@opplens.com"
}
}
},
"user.UpdateUserForm": {
"type": "object",
"properties": {
"company_id": {
"description": "Updated company ID",
"type": "string",
"example": "123e4567-e89b-12d3-a456-426614174000"
},
"department": {
"description": "Updated department",
"type": "string",
"example": "Product Management"
"example": "Information Technology"
},
"email": {
"description": "Updated email address",
"type": "string",
"example": "john.smith@newcompany.com"
"example": "admin@opplens.com"
},
"full_name": {
"description": "Updated full name",
"type": "string",
"example": "John Smith"
"example": "Admin User"
},
"phone": {
"description": "Updated phone number",
"type": "string",
"example": "+1234567890"
"example": "+18289784438"
},
"position": {
"description": "Updated position",
"type": "string",
"example": "Tech Lead"
"example": "Lead"
},
"profile_image": {
"description": "Updated profile image URL",
"type": "string",
"example": "https://example.com/new-avatar.jpg"
"example": ""
},
"role": {
"description": "Updated user role",
"type": "string",
"example": "admin"
},
"status": {
"description": "Updated account status",
"type": "string",
"example": "active"
},
"username": {
"description": "Updated username",
"type": "string",
"example": "johnsmith"
}
}
},
"user.UpdateUserRoleForm": {
"type": "object",
"properties": {
"role": {
"type": "string"
"example": "admin"
}
}
},
@@ -8463,17 +8191,8 @@
"user.UserListResponse": {
"type": "object",
"properties": {
"limit": {
"type": "integer"
},
"offset": {
"type": "integer"
},
"total": {
"type": "integer"
},
"total_pages": {
"type": "integer"
"meta": {
"$ref": "#/definitions/response.Meta"
},
"users": {
"type": "array",
@@ -8486,15 +8205,9 @@
"user.UserResponse": {
"type": "object",
"properties": {
"company_id": {
"type": "string"
},
"created_at": {
"type": "integer"
},
"created_by": {
"type": "string"
},
"department": {
"type": "string"
},
@@ -8531,9 +8244,6 @@
"updated_at": {
"type": "integer"
},
"updated_by": {
"type": "string"
},
"username": {
"type": "string"
}