fix: improvement response api and docs
This commit is contained in:
parent
81c7a51256
commit
aee94a5c9c
@ -58,7 +58,7 @@ func LoginStaff(
|
||||
return
|
||||
}
|
||||
|
||||
responsePayload := &authdomain.LoginResponse{
|
||||
responsePayload := &authdomain.AuthResponse{
|
||||
Token: token,
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ func LoginUser(
|
||||
return
|
||||
}
|
||||
|
||||
responsePayload := &authdomain.LoginResponse{
|
||||
responsePayload := &authdomain.AuthResponse{
|
||||
Token: token,
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +58,11 @@ func RegisterUser(
|
||||
return
|
||||
}
|
||||
|
||||
response.RespondJsonSuccess(ctx, w, token)
|
||||
responsePayload := &authdomain.AuthResponse{
|
||||
Token: token,
|
||||
}
|
||||
|
||||
response.RespondJsonSuccess(ctx, w, responsePayload)
|
||||
})
|
||||
}
|
||||
|
||||
@ -108,7 +112,9 @@ func RegisterStaff(
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
response.RespondJsonSuccess(ctx, w, token)
|
||||
responsePayload := &authdomain.AuthResponse{
|
||||
Token: token,
|
||||
}
|
||||
response.RespondJsonSuccess(ctx, w, responsePayload)
|
||||
})
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ func CreateSubscribePlan(
|
||||
response.RespondJsonSuccess(ctx, w, struct {
|
||||
Message string
|
||||
}{
|
||||
Message: "success",
|
||||
Message: "subscription plan created successfully.",
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ type LoginReq struct {
|
||||
Password string `json:"password" validate:"required"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
type AuthResponse struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
|
||||
200
openapi.yml
200
openapi.yml
@ -8,6 +8,8 @@ paths:
|
||||
/staff/login:
|
||||
post:
|
||||
summary: Login for staff
|
||||
tags:
|
||||
- Staff
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
@ -26,12 +28,37 @@ paths:
|
||||
responses:
|
||||
"200":
|
||||
description: Successful login
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
data:
|
||||
type: object
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
description: JWT token for staff authentication
|
||||
"400":
|
||||
description: Bad request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
|
||||
/staff/register:
|
||||
post:
|
||||
summary: Register a new staff member
|
||||
tags:
|
||||
- Staff
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
@ -50,14 +77,51 @@ paths:
|
||||
responses:
|
||||
"201":
|
||||
description: Staff member created
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
data:
|
||||
type: object
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
description: JWT token for staff authentication
|
||||
"400":
|
||||
description: Bad request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
"409":
|
||||
description: Conflict (email already registered)
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
|
||||
/user/login:
|
||||
post:
|
||||
summary: Login for user
|
||||
tags:
|
||||
- User
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
@ -76,12 +140,37 @@ paths:
|
||||
responses:
|
||||
"200":
|
||||
description: Successful login
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
data:
|
||||
type: object
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
description: JWT token for user authentication
|
||||
"400":
|
||||
description: Bad request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
|
||||
/user/register:
|
||||
post:
|
||||
summary: Register a new user
|
||||
tags:
|
||||
- User
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
@ -107,14 +196,51 @@ paths:
|
||||
responses:
|
||||
"201":
|
||||
description: User created
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
data:
|
||||
type: object
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
description: JWT token for user authentication
|
||||
"400":
|
||||
description: Bad request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
"409":
|
||||
description: Conflict (email already registered)
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
|
||||
/subscribe-plan/create:
|
||||
post:
|
||||
summary: Create a new subscription plan
|
||||
tags:
|
||||
- Subscribe Plan
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
@ -122,23 +248,91 @@ paths:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
code:
|
||||
type: string
|
||||
required:
|
||||
- code
|
||||
- name
|
||||
responses:
|
||||
"201":
|
||||
description: Subscription plan created
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
data:
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
example: "Subscription plan created successfully."
|
||||
"400":
|
||||
description: Bad request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
"409":
|
||||
description: Conflict (plan code already exists)
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
|
||||
/subscribe-plan/get-all:
|
||||
get:
|
||||
summary: Get all subscription plan
|
||||
summary: Get all subscription plans
|
||||
tags:
|
||||
- Subscribe Plan
|
||||
responses:
|
||||
"201":
|
||||
description: Subscription plan created
|
||||
"200":
|
||||
description: Successfully retrieved all subscription plans
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
data:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
code:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
"400":
|
||||
description: Bad request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user