Refactor health check and user management endpoints for improved structure and clarity
- Replaced the existing health check endpoint with a new handler at `/admin/v1/health` to align with the updated API structure. - Introduced a dedicated `health.go` file to encapsulate health check logic and response formatting. - Updated Swagger documentation to reflect the new health check endpoint and its response structure. - Refined user management routes to enhance clarity and maintainability, including changes to login, logout, and profile management endpoints. - Ensured all user-related endpoints are now prefixed appropriately and documented in Swagger for better API usability.
This commit is contained in:
+484
-425
File diff suppressed because it is too large
Load Diff
+484
-425
File diff suppressed because it is too large
Load Diff
+305
-270
@@ -1,5 +1,14 @@
|
||||
basePath: /api/v1
|
||||
basePath: /admin/v1
|
||||
definitions:
|
||||
main.HealthResponse:
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
time:
|
||||
type: integer
|
||||
version:
|
||||
type: string
|
||||
type: object
|
||||
response.APIError:
|
||||
properties:
|
||||
code:
|
||||
@@ -191,7 +200,265 @@ info:
|
||||
title: Tender Management API
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/users/admin:
|
||||
/change-password:
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Change current user password
|
||||
parameters:
|
||||
- description: Password change data
|
||||
in: body
|
||||
name: password
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.ChangePasswordForm'
|
||||
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'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Change password
|
||||
tags:
|
||||
- Users
|
||||
/health:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Get server health status
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/main.HealthResponse'
|
||||
summary: Health check
|
||||
tags:
|
||||
- Health
|
||||
/login:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Authenticate user with username and password
|
||||
parameters:
|
||||
- description: Login credentials
|
||||
in: body
|
||||
name: login
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.LoginForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/user.AuthResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
summary: Login user
|
||||
tags:
|
||||
- Authorization
|
||||
/logout:
|
||||
delete:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Logout current user and invalidate tokens
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Logout user
|
||||
tags:
|
||||
- Users
|
||||
/profile:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Get current user profile information
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/user.UserResponse'
|
||||
type: object
|
||||
"401":
|
||||
description: Unauthorized
|
||||
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: Get user profile
|
||||
tags:
|
||||
- Users
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Update current user profile information
|
||||
parameters:
|
||||
- description: Profile update data
|
||||
in: body
|
||||
name: profile
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.UpdateUserForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/user.UserResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Update user profile
|
||||
tags:
|
||||
- Users
|
||||
/refresh-token:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Refresh access token using refresh token
|
||||
parameters:
|
||||
- description: Refresh token
|
||||
in: body
|
||||
name: refresh
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.RefreshTokenForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/user.AuthResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
summary: Refresh access token
|
||||
tags:
|
||||
- Authorization
|
||||
/reset-password:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Send password reset email to user
|
||||
parameters:
|
||||
- description: Password reset request
|
||||
in: body
|
||||
name: reset
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.ResetPasswordForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
summary: Reset password
|
||||
tags:
|
||||
- Authorization
|
||||
/users:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -261,7 +528,7 @@ paths:
|
||||
- BearerAuth: []
|
||||
summary: List users
|
||||
tags:
|
||||
- users
|
||||
- Users
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -305,8 +572,8 @@ paths:
|
||||
- BearerAuth: []
|
||||
summary: Create user
|
||||
tags:
|
||||
- users
|
||||
/users/admin/{id}:
|
||||
- Users
|
||||
/users/{id}:
|
||||
delete:
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -348,7 +615,7 @@ paths:
|
||||
- BearerAuth: []
|
||||
summary: Delete user
|
||||
tags:
|
||||
- users
|
||||
- Users
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -395,7 +662,7 @@ paths:
|
||||
- BearerAuth: []
|
||||
summary: Get user by ID
|
||||
tags:
|
||||
- users
|
||||
- Users
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -448,8 +715,8 @@ paths:
|
||||
- BearerAuth: []
|
||||
summary: Update user
|
||||
tags:
|
||||
- users
|
||||
/users/admin/{id}/role:
|
||||
- Users
|
||||
/users/{id}/role:
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -497,8 +764,8 @@ paths:
|
||||
- BearerAuth: []
|
||||
summary: Update user role
|
||||
tags:
|
||||
- users
|
||||
/users/admin/{id}/status:
|
||||
- Users
|
||||
/users/{id}/status:
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -546,8 +813,8 @@ paths:
|
||||
- BearerAuth: []
|
||||
summary: Update user status
|
||||
tags:
|
||||
- users
|
||||
/users/admin/company/{company_id}:
|
||||
- Users
|
||||
/users/company/{company_id}:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -570,9 +837,15 @@ paths:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
description: Users with pagination metadata
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
@@ -593,8 +866,8 @@ paths:
|
||||
- BearerAuth: []
|
||||
summary: Get users by company ID
|
||||
tags:
|
||||
- users
|
||||
/users/admin/role/{role}:
|
||||
- Users
|
||||
/users/role/{role}:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -617,9 +890,15 @@ paths:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
description: Users with pagination metadata
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
@@ -640,250 +919,7 @@ paths:
|
||||
- BearerAuth: []
|
||||
summary: Get users by role
|
||||
tags:
|
||||
- users
|
||||
/users/change-password:
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Change current user password
|
||||
parameters:
|
||||
- description: Password change data
|
||||
in: body
|
||||
name: password
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.ChangePasswordForm'
|
||||
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'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Change password
|
||||
tags:
|
||||
- users
|
||||
/users/login:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Authenticate user with email/username and password
|
||||
parameters:
|
||||
- description: Login credentials
|
||||
in: body
|
||||
name: login
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.LoginForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/user.AuthResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
summary: Login user
|
||||
tags:
|
||||
- users
|
||||
/users/logout:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Logout current user and invalidate tokens
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Logout user
|
||||
tags:
|
||||
- users
|
||||
/users/profile:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Get current user profile information
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/user.UserResponse'
|
||||
type: object
|
||||
"401":
|
||||
description: Unauthorized
|
||||
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: Get user profile
|
||||
tags:
|
||||
- users
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Update current user profile information
|
||||
parameters:
|
||||
- description: Profile update data
|
||||
in: body
|
||||
name: profile
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.UpdateUserForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/user.UserResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Update user profile
|
||||
tags:
|
||||
- users
|
||||
/users/refresh-token:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Refresh access token using refresh token
|
||||
parameters:
|
||||
- description: Refresh token
|
||||
in: body
|
||||
name: refresh
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.RefreshTokenForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/user.AuthResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
summary: Refresh access token
|
||||
tags:
|
||||
- users
|
||||
/users/reset-password:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Send password reset email to user
|
||||
parameters:
|
||||
- description: Password reset request
|
||||
in: body
|
||||
name: reset
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.ResetPasswordForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
summary: Reset password
|
||||
tags:
|
||||
- users
|
||||
- Users
|
||||
securityDefinitions:
|
||||
BearerAuth:
|
||||
description: Type "Bearer" followed by a space and JWT token.
|
||||
@@ -892,11 +928,10 @@ securityDefinitions:
|
||||
type: apiKey
|
||||
swagger: "2.0"
|
||||
tags:
|
||||
- description: Customer management operations
|
||||
name: customers
|
||||
- description: User management operations
|
||||
name: users
|
||||
- description: User management operations including authentication, profile management,
|
||||
and admin operations
|
||||
name: Users
|
||||
- description: Authentication operations including login, logout, and token management
|
||||
name: Authorization
|
||||
- description: Health check operations
|
||||
name: health
|
||||
- description: Authentication operations
|
||||
name: auth
|
||||
name: Health
|
||||
|
||||
Reference in New Issue
Block a user