Document detailed Swagger response schemas for every API
This commit is contained in:
parent
c87ef35390
commit
aa718ae7d0
|
|
@ -304,6 +304,11 @@ make postgres # psql shell into Compose Postgres
|
|||
3. **Postman collections**: `postman/` (FAQ, personas, mobile app versions, dynamic question types, …)
|
||||
4. **Feature integration guides**: `docs/*-admin-panel-integration.md` (see [below](#admin-panel-integration-docs))
|
||||
|
||||
Every API operation documents a concrete response schema, including envelopes,
|
||||
pagination, message-only results, and notification scheduling variants. See
|
||||
[Swagger response contracts](docs/swagger-response-schemas.md) for conventions,
|
||||
intentional JSON extension fields, and the regression checks.
|
||||
|
||||
Regenerate after handler / annotation changes:
|
||||
|
||||
```bash
|
||||
|
|
|
|||
5774
docs/docs.go
5774
docs/docs.go
File diff suppressed because it is too large
Load Diff
68
docs/swagger-response-schemas.md
Normal file
68
docs/swagger-response-schemas.md
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# Swagger response contracts
|
||||
|
||||
Every registered API operation has an explicit success response schema. JSON
|
||||
payloads document their envelope, property names, arrays, nested objects, and
|
||||
pagination. Operations without a data payload use message-only schemas; CSV,
|
||||
HTML, OAuth redirects, and WebSocket upgrades retain their actual media/protocol
|
||||
contracts rather than being described as generic JSON.
|
||||
|
||||
## Response envelopes
|
||||
|
||||
- `domain.Response{data=ConcreteType}` documents `message`, `success`,
|
||||
`status_code`, endpoint-specific `data`, and `metadata`.
|
||||
- `response.APIResponse{data=ConcreteType}` documents legacy account responses
|
||||
with `status`, `message`, typed `data`, `timestamp`, and optional pagination.
|
||||
- `MessageResponse` and `MessageAPIResponse` describe responses that omit `data`.
|
||||
- Some endpoints, such as notification counts/lists and analytics, return a
|
||||
top-level object. Their schemas describe that object without adding an envelope.
|
||||
|
||||
Raw service/domain records retain their existing JSON casing. For example,
|
||||
assessment question sets and raw Vimeo upload results expose PascalCase fields.
|
||||
Their Swagger models use those exact names; this documentation update does not
|
||||
rename existing API properties.
|
||||
|
||||
Both immediately dispatched and scheduled bulk notifications are documented:
|
||||
`200` returns the delivery summary and `201` returns a scheduled notification.
|
||||
Free-plan checkout includes an optional `subscription` in the checkout response.
|
||||
Pagination metadata for staff lists and Vimeo lists has a concrete schema.
|
||||
|
||||
## Extensible JSON and errors
|
||||
|
||||
Activity/notification metadata and template variables are intentionally extensible
|
||||
objects. Their descriptions identify the source of their keys. A dynamic question
|
||||
component's `value` depends on its `kind`; its description and `x-json-types`
|
||||
extension explicitly document the permitted JSON variants. These fields cannot
|
||||
truthfully be represented as one fixed object or as a byte array.
|
||||
|
||||
Reserved response `metadata` is null, or omitted in the legacy envelope, unless
|
||||
the operation supplies a concrete metadata schema. Message-only responses document
|
||||
this null value explicitly.
|
||||
|
||||
Error responses retain their real transport shape: JSON handler errors use
|
||||
`domain.ErrorResponse`; handlers/middleware returning Fiber errors use a plain-text
|
||||
string. The API does not have a universal JSON error envelope. Consumers should
|
||||
respect the response Content-Type, particularly on authentication and service
|
||||
failures. The documentation does not change runtime error handling.
|
||||
|
||||
## Maintaining complete schemas
|
||||
|
||||
When adding an operation:
|
||||
|
||||
1. Reuse an existing response type or add a small tagged payload DTO for maps.
|
||||
2. Specify the complete response envelope and typed `data` in `@Success`.
|
||||
3. Document each success status variant and the actual error bodies.
|
||||
4. Use explicit descriptions for genuinely open JSON extension points.
|
||||
5. Regenerate all artifacts and run the contract checks:
|
||||
|
||||
```powershell
|
||||
swag init -g cmd/main.go
|
||||
go test ./internal/web_server/... ./internal/domain ./internal/apidocs/...
|
||||
go run ./cmd/swagger-export -out exports/swagger-offline
|
||||
```
|
||||
|
||||
`TestEveryAPIResponseHasDetailedSchema` checks response definitions recursively,
|
||||
including item schemas and composed envelope overrides. It rejects generic success
|
||||
envelopes, missing schemas, and unexplained empty fields. Other checks ensure route,
|
||||
security, request-body, and path-parameter coverage, valid references, and parity
|
||||
between `docs.go`, `swagger.json`, and `swagger.yaml`. Representative payload tests
|
||||
also compare documentation-only DTOs with the JSON written by the runtime types.
|
||||
5774
docs/swagger.json
5774
docs/swagger.json
File diff suppressed because it is too large
Load Diff
3590
docs/swagger.yaml
3590
docs/swagger.yaml
File diff suppressed because it is too large
Load Diff
|
|
@ -72,8 +72,8 @@ type ArifpayVerifyByTransactionIDRequest struct {
|
|||
}
|
||||
|
||||
type ARIFPAYPaymentMethod struct {
|
||||
ID int
|
||||
Name string
|
||||
ID int `json:"ID"`
|
||||
Name string `json:"Name"`
|
||||
}
|
||||
|
||||
// Direct Payment Types
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@ type ResponseWDataFactory[T any] struct {
|
|||
|
||||
type Response struct {
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
Data interface{} `json:"data,omitempty" swaggerignore:"true"`
|
||||
Success bool `json:"success"`
|
||||
StatusCode int `json:"status_code"`
|
||||
MetaData interface{} `json:"metadata"`
|
||||
// Optional endpoint-specific metadata; null unless the operation documents a concrete metadata schema.
|
||||
MetaData interface{} `json:"metadata" swaggertype:"object" extensions:"x-nullable"`
|
||||
}
|
||||
|
||||
func NewResponse(message string, data interface{}) Response {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,8 @@ type Notification struct {
|
|||
Timestamp time.Time `json:"timestamp"`
|
||||
Expires time.Time `json:"expires"`
|
||||
Image string `json:"image"`
|
||||
Metadata json.RawMessage `json:"metadata,omitempty"`
|
||||
// Free-form notification metadata supplied by the sending application. Keys are application-defined.
|
||||
Metadata json.RawMessage `json:"metadata,omitempty" swaggertype:"object"`
|
||||
}
|
||||
type CreateNotification struct {
|
||||
RecipientID int64 `json:"recipient_id"`
|
||||
|
|
@ -107,7 +108,8 @@ type CreateNotification struct {
|
|||
Priority int `json:"priority,omitempty"`
|
||||
Expires time.Time `json:"expires"`
|
||||
Image string `json:"image,omitempty"`
|
||||
Metadata json.RawMessage `json:"metadata,omitempty"`
|
||||
// Free-form notification metadata supplied by the sending application. Keys are application-defined.
|
||||
Metadata json.RawMessage `json:"metadata,omitempty" swaggertype:"object"`
|
||||
}
|
||||
|
||||
type NotificationFilter struct {
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ import (
|
|||
type StimulusComponentKind string
|
||||
|
||||
const (
|
||||
StimulusQuestionText StimulusComponentKind = "QUESTION_TEXT"
|
||||
StimulusPrepTime StimulusComponentKind = "PREP_TIME"
|
||||
StimulusInstruction StimulusComponentKind = "INSTRUCTION"
|
||||
StimulusQuestionText StimulusComponentKind = "QUESTION_TEXT"
|
||||
StimulusPrepTime StimulusComponentKind = "PREP_TIME"
|
||||
StimulusInstruction StimulusComponentKind = "INSTRUCTION"
|
||||
// StimulusAudioPrompt is the single stimulus-side audio kind (prompts, clips, listening passages).
|
||||
StimulusAudioPrompt StimulusComponentKind = "AUDIO_PROMPT"
|
||||
StimulusTextPassage StimulusComponentKind = "TEXT_PASSAGE"
|
||||
StimulusAudioPrompt StimulusComponentKind = "AUDIO_PROMPT"
|
||||
StimulusTextPassage StimulusComponentKind = "TEXT_PASSAGE"
|
||||
StimulusImage StimulusComponentKind = "IMAGE"
|
||||
StimulusMatchingInputs StimulusComponentKind = "MATCHING_INPUTS"
|
||||
StimulusSelectMissingWords StimulusComponentKind = "SELECT_MISSING_WORDS"
|
||||
|
|
@ -50,9 +50,10 @@ type DynamicElementDefinition struct {
|
|||
}
|
||||
|
||||
type DynamicElementInstance struct {
|
||||
ID string `json:"id"`
|
||||
Kind string `json:"kind"`
|
||||
Value interface{} `json:"value,omitempty"`
|
||||
ID string `json:"id"`
|
||||
Kind string `json:"kind"`
|
||||
// Component-specific JSON value selected by kind: string, number, boolean, object, array, or null. Use the component catalog and definition schema to interpret it.
|
||||
Value interface{} `json:"value,omitempty" extensions:"x-json-types=string|number|boolean|object|array|null"`
|
||||
Meta map[string]interface{} `json:"meta,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,19 +3,19 @@ package domain
|
|||
import "time"
|
||||
|
||||
type QuestionTypeDefinition struct {
|
||||
ID int64
|
||||
Key string
|
||||
DisplayName string
|
||||
Description *string
|
||||
GroupIDs *[]int64 `json:"group_ids"`
|
||||
StimulusComponentKinds []string
|
||||
ResponseComponentKinds []string
|
||||
StimulusSchema []DynamicElementDefinition
|
||||
ResponseSchema []DynamicElementDefinition
|
||||
IsSystem bool
|
||||
Status string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt *time.Time
|
||||
ID int64 `json:"ID"`
|
||||
Key string `json:"Key"`
|
||||
DisplayName string `json:"DisplayName"`
|
||||
Description *string `json:"Description"`
|
||||
GroupIDs *[]int64 `json:"group_ids"`
|
||||
StimulusComponentKinds []string `json:"StimulusComponentKinds"`
|
||||
ResponseComponentKinds []string `json:"ResponseComponentKinds"`
|
||||
StimulusSchema []DynamicElementDefinition `json:"StimulusSchema"`
|
||||
ResponseSchema []DynamicElementDefinition `json:"ResponseSchema"`
|
||||
IsSystem bool `json:"IsSystem"`
|
||||
Status string `json:"Status"`
|
||||
CreatedAt time.Time `json:"CreatedAt"`
|
||||
UpdatedAt *time.Time `json:"UpdatedAt"`
|
||||
}
|
||||
|
||||
type CreateQuestionTypeDefinitionInput struct {
|
||||
|
|
|
|||
|
|
@ -93,22 +93,22 @@ type QuestionShortAnswer struct {
|
|||
}
|
||||
|
||||
type QuestionSet struct {
|
||||
ID int64
|
||||
Title string
|
||||
Description *string
|
||||
SetType string
|
||||
OwnerType *string
|
||||
OwnerID *int64
|
||||
BannerImage *string
|
||||
Persona *string
|
||||
TimeLimitMinutes *int32
|
||||
PassingScore *int32
|
||||
ShuffleQuestions bool
|
||||
Status string
|
||||
IntroVideoURL *string
|
||||
UserPersonas []UserPersona
|
||||
CreatedAt time.Time
|
||||
UpdatedAt *time.Time
|
||||
ID int64 `json:"ID"`
|
||||
Title string `json:"Title"`
|
||||
Description *string `json:"Description"`
|
||||
SetType string `json:"SetType"`
|
||||
OwnerType *string `json:"OwnerType"`
|
||||
OwnerID *int64 `json:"OwnerID"`
|
||||
BannerImage *string `json:"BannerImage"`
|
||||
Persona *string `json:"Persona"`
|
||||
TimeLimitMinutes *int32 `json:"TimeLimitMinutes"`
|
||||
PassingScore *int32 `json:"PassingScore"`
|
||||
ShuffleQuestions bool `json:"ShuffleQuestions"`
|
||||
Status string `json:"Status"`
|
||||
IntroVideoURL *string `json:"IntroVideoURL"`
|
||||
UserPersonas []UserPersona `json:"UserPersonas"`
|
||||
CreatedAt time.Time `json:"CreatedAt"`
|
||||
UpdatedAt *time.Time `json:"UpdatedAt"`
|
||||
}
|
||||
|
||||
type QuestionSetItem struct {
|
||||
|
|
@ -205,11 +205,11 @@ type CreateQuestionSetInput struct {
|
|||
|
||||
// UserPersona represents a user acting as a persona in a practice session
|
||||
type UserPersona struct {
|
||||
ID int64
|
||||
FirstName *string
|
||||
LastName *string
|
||||
NickName *string
|
||||
ProfilePictureURL *string
|
||||
Role string
|
||||
DisplayOrder int32
|
||||
ID int64 `json:"ID"`
|
||||
FirstName *string `json:"FirstName"`
|
||||
LastName *string `json:"LastName"`
|
||||
NickName *string `json:"NickName"`
|
||||
ProfilePictureURL *string `json:"ProfilePictureURL"`
|
||||
Role string `json:"Role"`
|
||||
DisplayOrder int32 `json:"DisplayOrder"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,17 +55,19 @@ type ScheduledNotification struct {
|
|||
Message string `json:"message"`
|
||||
HTML string `json:"html,omitempty"`
|
||||
|
||||
EmailTemplateSlug string `json:"email_template_slug,omitempty"`
|
||||
EmailTemplateVariables json.RawMessage `json:"email_template_variables,omitempty"`
|
||||
EmailTemplateSlug string `json:"email_template_slug,omitempty"`
|
||||
// Free-form template variable object. Keys are defined by the selected email template.
|
||||
EmailTemplateVariables json.RawMessage `json:"email_template_variables,omitempty" swaggertype:"object"`
|
||||
|
||||
ScheduledAt time.Time `json:"scheduled_at"`
|
||||
Status ScheduledNotificationStatus `json:"status"`
|
||||
|
||||
TargetUserIDs []int64 `json:"target_user_ids,omitempty"`
|
||||
TargetRole string `json:"target_role,omitempty"`
|
||||
TargetTeamMemberIDs []int64 `json:"target_team_member_ids,omitempty"`
|
||||
TargetTeamRole string `json:"target_team_role,omitempty"`
|
||||
TargetRaw json.RawMessage `json:"target_raw,omitempty"`
|
||||
TargetUserIDs []int64 `json:"target_user_ids,omitempty"`
|
||||
TargetRole string `json:"target_role,omitempty"`
|
||||
TargetTeamMemberIDs []int64 `json:"target_team_member_ids,omitempty"`
|
||||
TargetTeamRole string `json:"target_team_role,omitempty"`
|
||||
// Optional extra targets: phones and emails arrays, team_member_ids array, team_role, level, and type strings.
|
||||
TargetRaw json.RawMessage `json:"target_raw,omitempty" swaggertype:"object"`
|
||||
|
||||
AttemptCount int32 `json:"attempt_count"`
|
||||
LastError string `json:"last_error,omitempty"`
|
||||
|
|
|
|||
|
|
@ -226,17 +226,17 @@ type AccountDeletionRequestFilter struct {
|
|||
}
|
||||
|
||||
type AccountDeletionRequest struct {
|
||||
UserID int64
|
||||
FirstName string
|
||||
LastName string
|
||||
Email string
|
||||
PhoneNumber string
|
||||
Role Role
|
||||
Status UserStatus
|
||||
DeletionRequestedAt *time.Time
|
||||
DeletionScheduledAt *time.Time
|
||||
DeletionCancelledAt *time.Time
|
||||
DeletionState AccountDeletionState
|
||||
UserID int64 `json:"UserID"`
|
||||
FirstName string `json:"FirstName"`
|
||||
LastName string `json:"LastName"`
|
||||
Email string `json:"Email"`
|
||||
PhoneNumber string `json:"PhoneNumber"`
|
||||
Role Role `json:"Role"`
|
||||
Status UserStatus `json:"Status"`
|
||||
DeletionRequestedAt *time.Time `json:"DeletionRequestedAt"`
|
||||
DeletionScheduledAt *time.Time `json:"DeletionScheduledAt"`
|
||||
DeletionCancelledAt *time.Time `json:"DeletionCancelledAt"`
|
||||
DeletionState AccountDeletionState `json:"DeletionState"`
|
||||
}
|
||||
|
||||
type RegisterUserReq struct {
|
||||
|
|
|
|||
|
|
@ -12,20 +12,21 @@ import (
|
|||
)
|
||||
|
||||
type activityLogRes struct {
|
||||
ID int64 `json:"id"`
|
||||
ActorID *int64 `json:"actor_id,omitempty"`
|
||||
ActorRole *string `json:"actor_role,omitempty"`
|
||||
ActorName *string `json:"actor_name,omitempty"`
|
||||
ActorEmail *string `json:"actor_email,omitempty"`
|
||||
ActorKind *string `json:"actor_kind,omitempty"`
|
||||
Action string `json:"action"`
|
||||
ResourceType string `json:"resource_type"`
|
||||
ResourceID *int64 `json:"resource_id,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
Metadata json.RawMessage `json:"metadata"`
|
||||
IPAddress *string `json:"ip_address,omitempty"`
|
||||
UserAgent *string `json:"user_agent,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ID int64 `json:"id"`
|
||||
ActorID *int64 `json:"actor_id,omitempty"`
|
||||
ActorRole *string `json:"actor_role,omitempty"`
|
||||
ActorName *string `json:"actor_name,omitempty"`
|
||||
ActorEmail *string `json:"actor_email,omitempty"`
|
||||
ActorKind *string `json:"actor_kind,omitempty"`
|
||||
Action string `json:"action"`
|
||||
ResourceType string `json:"resource_type"`
|
||||
ResourceID *int64 `json:"resource_id,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
// Free-form event metadata; keys depend on action and resource_type. Null when the event has no metadata.
|
||||
Metadata json.RawMessage `json:"metadata" swaggertype:"object"`
|
||||
IPAddress *string `json:"ip_address,omitempty"`
|
||||
UserAgent *string `json:"user_agent,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type activityLogListRes struct {
|
||||
|
|
@ -48,7 +49,7 @@ type activityLogListRes struct {
|
|||
// @Param before query string false "Filter logs before this RFC3339 timestamp"
|
||||
// @Param limit query int false "Limit" default(20)
|
||||
// @Param offset query int false "Offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=activityLogListRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/activity-logs [get]
|
||||
|
|
@ -165,7 +166,7 @@ func (h *Handler) GetActivityLogs(c *fiber.Ctx) error {
|
|||
// @Tags activity-logs
|
||||
// @Produce json
|
||||
// @Param id path int true "Activity Log ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=activityLogRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/activity-logs/{id} [get]
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ type CreateAdminReq struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param manger body CreateAdminReq true "Create admin"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} MessageAPIResponse
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 401 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/admins [post]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -170,10 +170,10 @@ type AdminRes struct {
|
|||
// @Produce json
|
||||
// @Param page query int false "Page number"
|
||||
// @Param page_size query int false "Page size"
|
||||
// @Success 200 {object} AdminRes
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=[]AdminRes}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 401 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/admins [get]
|
||||
// @Security Bearer
|
||||
// @Param query query string false "Query"
|
||||
|
|
@ -292,10 +292,10 @@ func (h *Handler) GetAllAdmins(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "User ID"
|
||||
// @Success 200 {object} AdminRes
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=AdminRes}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 401 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/admins/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -348,10 +348,10 @@ type updateAdminReq struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param admin body updateAdminReq true "Update Admin"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} MessageAPIResponse
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 401 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/admins/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
|
|
@ -442,7 +442,7 @@ func (h *Handler) bulkAccountsRoleFromPath(c *fiber.Ctx) (roleKey string, ok boo
|
|||
// @Produce json
|
||||
// @Param role path string true "Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string)"
|
||||
// @Param body body domain.BulkAccountsByRoleRequest false "Optional exclusions"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.BulkDeactivateAccountsByRoleResult}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 403 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
|
|
@ -567,7 +567,7 @@ func (h *Handler) BulkDeactivateAccountsByRole(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param role path string true "Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string)"
|
||||
// @Param body body domain.BulkAccountsByRoleRequest false "Optional exclusions"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.BulkReactivateAccountsByRoleResult}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 403 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ func csvJSON(raw json.RawMessage) string {
|
|||
// @Security Bearer
|
||||
// @Produce text/csv
|
||||
// @Success 200 {file} file "CSV export; filename is supplied in Content-Disposition"
|
||||
// @Header 200 {string} Content-Disposition "attachment; filename=export.csv"
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
|
|
@ -176,6 +177,7 @@ func (h *Handler) ExportAdminPaymentsCSV(c *fiber.Ctx) error {
|
|||
// @Security Bearer
|
||||
// @Produce text/csv
|
||||
// @Success 200 {file} file "CSV export; filename is supplied in Content-Disposition"
|
||||
// @Header 200 {string} Content-Disposition "attachment; filename=export.csv"
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {string} string "Invalid request"
|
||||
|
|
@ -260,6 +262,7 @@ func (h *Handler) ExportUsersCSV(c *fiber.Ctx) error {
|
|||
// @Security Bearer
|
||||
// @Produce text/csv
|
||||
// @Success 200 {file} file "CSV export; filename is supplied in Content-Disposition"
|
||||
// @Header 200 {string} Content-Disposition "attachment; filename=export.csv"
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
|
|
@ -318,6 +321,7 @@ func (h *Handler) ExportActivityLogsCSV(c *fiber.Ctx) error {
|
|||
// @Security Bearer
|
||||
// @Produce text/csv
|
||||
// @Success 200 {file} file "CSV export; filename is supplied in Content-Disposition"
|
||||
// @Header 200 {string} Content-Disposition "attachment; filename=export.csv"
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
|
|
@ -385,6 +389,7 @@ func (h *Handler) ExportUserSubscriptionsCSV(c *fiber.Ctx) error {
|
|||
// @Security Bearer
|
||||
// @Produce text/csv
|
||||
// @Success 200 {file} file "CSV export; filename is supplied in Content-Disposition"
|
||||
// @Header 200 {string} Content-Disposition "attachment; filename=export.csv"
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ func (r adminApplySubscriptionReq) recordPaymentOrDefault() bool {
|
|||
// @Produce json
|
||||
// @Param user_id path int true "Target learner user ID"
|
||||
// @Param body body adminApplySubscriptionReq true "Plan to grant or extend"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=subscriptionRes}
|
||||
// @Success 201 {object} domain.Response{data=subscriptionRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -160,7 +160,7 @@ func (h *Handler) AdminExtendOrGrantUserSubscription(c *fiber.Ctx) error {
|
|||
// @Tags subscriptions
|
||||
// @Produce json
|
||||
// @Param id path int true "Subscription ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=subscriptionRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ type paymentRes struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body initiatePaymentReq true "Payment request"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.InitiateSubscriptionPaymentResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/subscribe [post]
|
||||
|
|
@ -112,7 +112,7 @@ func (h *Handler) InitiateSubscriptionPayment(c *fiber.Ctx) error {
|
|||
// @Tags payments
|
||||
// @Produce json
|
||||
// @Param session_id path string true "Session ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=paymentRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/verify/{session_id} [get]
|
||||
|
|
@ -155,7 +155,7 @@ func (h *Handler) VerifyPayment(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param limit query int false "Limit" default(20)
|
||||
// @Param offset query int false "Offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=[]paymentRes}
|
||||
// @Router /api/v1/payments [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -197,7 +197,7 @@ func (h *Handler) GetMyPayments(c *fiber.Ctx) error {
|
|||
// @Tags payments
|
||||
// @Produce json
|
||||
// @Param id path int true "Payment ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=paymentRes}
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/{id} [get]
|
||||
// @Security Bearer
|
||||
|
|
@ -244,7 +244,7 @@ func (h *Handler) GetPaymentByID(c *fiber.Ctx) error {
|
|||
// @Tags payments
|
||||
// @Produce json
|
||||
// @Param id path int true "Payment ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/{id}/cancel [post]
|
||||
// @Security Bearer
|
||||
|
|
@ -469,7 +469,7 @@ type verifyOTPReq struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body initiateDirectPaymentReq true "Direct payment request"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.InitiateDirectPaymentResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/direct [post]
|
||||
|
|
@ -525,7 +525,7 @@ func (h *Handler) InitiateDirectPayment(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body verifyOTPReq true "OTP verification request"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.VerifyOTPResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/direct/verify-otp [post]
|
||||
|
|
@ -586,7 +586,7 @@ func (h *Handler) VerifyDirectPaymentOTP(c *fiber.Ctx) error {
|
|||
// @Description Returns list of payment methods that support direct payment (OTP-based)
|
||||
// @Tags payments
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=[]domain.ARIFPAYPaymentMethod}
|
||||
// @Router /api/v1/payments/direct/methods [get]
|
||||
func (h *Handler) GetDirectPaymentMethods(c *fiber.Ctx) error {
|
||||
methods := h.arifpaySvc.GetDirectPaymentMethods()
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ type loginUserRes struct {
|
|||
// @Tags auth
|
||||
// @Param idToken body string true "Google ID Token from Android"
|
||||
// @Router /api/v1/auth/google/android [post]
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=loginUserRes}
|
||||
// @Produce json
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 401 {object} domain.ErrorResponse "Authentication failed"
|
||||
|
|
@ -108,7 +108,7 @@ func (h *Handler) GoogleAndroidLogin(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param body body object true "Apple login payload"
|
||||
// @Router /api/v1/auth/apple [post]
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=loginUserRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 401 {object} domain.ErrorResponse "Authentication failed"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
|
|
@ -184,6 +184,7 @@ func (h *Handler) AppleLogin(c *fiber.Ctx) error {
|
|||
// @Tags auth
|
||||
// @Router /api/v1/auth/google/login [get]
|
||||
// @Success 302 {string} string "Redirect to Google authorization URL; see Location header"
|
||||
// @Header 302 {string} Location "Google authorization URL"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Google OAuth is not configured"
|
||||
// @Produce plain
|
||||
func (h *Handler) GoogleLogin(c *fiber.Ctx) error {
|
||||
|
|
@ -203,7 +204,7 @@ func (h *Handler) GoogleLogin(c *fiber.Ctx) error {
|
|||
// @Tags auth
|
||||
// @Router /api/v1/auth/google/callback [get]
|
||||
// @Param code query string false "Code"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=loginUserRes}
|
||||
// @Produce json
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 401 {object} domain.ErrorResponse "Authentication failed"
|
||||
|
|
@ -271,10 +272,10 @@ func (h *Handler) GoogleCallback(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param login body domain.LoginRequest true "Login user"
|
||||
// @Success 200 {object} loginUserRes
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} domain.Response{data=loginUserRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 401 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/auth/customer-login [post]
|
||||
// @Failure 403 {object} domain.ErrorResponse "Access denied"
|
||||
func (h *Handler) LoginUser(c *fiber.Ctx) error {
|
||||
|
|
@ -421,10 +422,10 @@ type LoginAdminRes struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param login body domain.LoginRequest true "Login admin"
|
||||
// @Success 200 {object} LoginAdminRes
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=loginUserRes}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 401 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/auth/admin-login [post]
|
||||
// @Failure 403 {string} string "Access denied"
|
||||
func (h *Handler) LoginAdmin(c *fiber.Ctx) error {
|
||||
|
|
@ -524,10 +525,10 @@ func (h *Handler) LoginAdmin(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param login body domain.LoginRequest true "Login super-admin"
|
||||
// @Success 200 {object} LoginAdminRes
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=loginUserRes}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 401 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/auth/super-login [post]
|
||||
// @Failure 403 {string} string "Access denied"
|
||||
func (h *Handler) LoginSuper(c *fiber.Ctx) error {
|
||||
|
|
@ -631,10 +632,10 @@ type refreshToken struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param refresh body refreshToken true "tokens"
|
||||
// @Success 200 {object} loginUserRes
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} domain.Response{data=loginUserRes}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 401 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/auth/refresh [post]
|
||||
// @Failure 403 {string} string "Access denied"
|
||||
func (h *Handler) RefreshToken(c *fiber.Ctx) error {
|
||||
|
|
@ -772,10 +773,10 @@ type logoutReq struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param logout body logoutReq true "Logout user"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} MessageAPIResponse
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 401 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/auth/logout [post]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import (
|
|||
// @Tags payments
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/webhook [post]
|
||||
// @Accept json
|
||||
|
|
@ -88,7 +88,7 @@ func (h *Handler) logChapaWebhookActivity(c *fiber.Ctx, payload domain.ChapaWebh
|
|||
// @Param trx_ref query string false "Transaction reference"
|
||||
// @Param ref_id query string false "Chapa reference ID"
|
||||
// @Param status query string false "Payment status"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Router /api/v1/payments/chapa/callback [get]
|
||||
// @Param tx_ref query string false "Tx ref"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
|
|
@ -181,7 +181,7 @@ func (h *Handler) HandleChapaSuccessPage(c *fiber.Ctx) error {
|
|||
// @Description Returns payment methods available on Chapa checkout
|
||||
// @Tags payments
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=[]domain.ChapaPaymentMethod}
|
||||
// @Router /api/v1/payments/methods [get]
|
||||
func (h *Handler) GetChapaPaymentMethods(c *fiber.Ctx) error {
|
||||
return c.JSON(domain.Response{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ type authorizeChapaDirectPaymentReq struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body initiateChapaDirectPaymentReq true "Chapa direct charge request"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.InitiateChapaDirectChargeResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/chapa/direct [post]
|
||||
|
|
@ -79,7 +79,7 @@ func (h *Handler) InitiateChapaDirectPayment(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body authorizeChapaDirectPaymentReq true "Chapa direct charge authorization request"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.AuthorizeChapaDirectChargeResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/chapa/direct/authorize [post]
|
||||
|
|
@ -142,7 +142,7 @@ func (h *Handler) AuthorizeChapaDirectPayment(c *fiber.Ctx) error {
|
|||
// @Description Returns wallet methods supported by Chapa Direct Charge API (USSD push and OTP flows).
|
||||
// @Tags payments
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=[]domain.ChapaDirectChargeMethod}
|
||||
// @Router /api/v1/payments/chapa/direct/methods [get]
|
||||
func (h *Handler) GetChapaDirectPaymentMethods(c *fiber.Ctx) error {
|
||||
return c.JSON(domain.Response{
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ func (h *Handler) UpdateChapterQuizFull(c *fiber.Ctx) error {
|
|||
// @Security Bearer
|
||||
// @Produce json
|
||||
// @Param id path int true "Quiz shell ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 401 {object} domain.ErrorResponse "Missing or invalid access token"
|
||||
// @Failure 403 {object} domain.ErrorResponse "Permission, subscription, or sequence access denied"
|
||||
|
|
@ -143,7 +143,7 @@ func (h *Handler) GetChapterQuizQuestions(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Quiz shell ID"
|
||||
// @Accept json
|
||||
// @Param body body domain.CompletePracticeInput false "Optional chapter scope"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 401 {object} domain.ErrorResponse "Missing or invalid access token"
|
||||
// @Failure 403 {object} domain.ErrorResponse "Permission, subscription, or sequence access denied"
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ func mapEmailTemplateToRes(t domain.EmailTemplate) emailTemplateRes {
|
|||
// @Param query query string false "Search by slug, name, or subject"
|
||||
// @Param limit query int false "Limit (default 20)"
|
||||
// @Param offset query int false "Offset (default 0)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listEmailTemplatesRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/email-templates [get]
|
||||
|
|
@ -149,7 +149,7 @@ func (h *Handler) ListEmailTemplatesAdmin(c *fiber.Ctx) error {
|
|||
// @Tags email-templates
|
||||
// @Produce json
|
||||
// @Param id path int true "Email template ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=emailTemplateRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -191,7 +191,7 @@ func (h *Handler) GetEmailTemplateByIDAdmin(c *fiber.Ctx) error {
|
|||
// @Tags email-templates
|
||||
// @Produce json
|
||||
// @Param slug path string true "Email template slug"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=emailTemplateRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -234,7 +234,7 @@ func (h *Handler) GetEmailTemplateBySlugAdmin(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body createEmailTemplateReq true "Create email template payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=emailTemplateRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/email-templates [post]
|
||||
|
|
@ -288,7 +288,7 @@ func (h *Handler) CreateEmailTemplate(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Email template ID"
|
||||
// @Param body body updateEmailTemplateReq true "Update email template payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=emailTemplateRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -347,7 +347,7 @@ func (h *Handler) UpdateEmailTemplate(c *fiber.Ctx) error {
|
|||
// @Tags email-templates
|
||||
// @Produce json
|
||||
// @Param id path int true "Email template ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=DeleteEmailTemplateData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -392,7 +392,7 @@ func (h *Handler) DeleteEmailTemplate(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param slug path string true "Email template slug"
|
||||
// @Param body body previewEmailTemplateReq true "Preview variables"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.RenderedEmail}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -442,7 +442,7 @@ func (h *Handler) PreviewEmailTemplateBySlug(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Email template ID"
|
||||
// @Param body body previewEmailTemplateReq true "Preview variables"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.RenderedEmail}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ func assessmentParentFromQuery(c *fiber.Ctx) (domain.ExamPrepAssessmentParent, e
|
|||
// @Router /api/v1/admin/assessments [get]
|
||||
// @Router /api/v1/assessments [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=ListExamPrepAssessmentsData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -50,7 +50,7 @@ func (h *Handler) ListExamPrepAssessments(c *fiber.Ctx) error {
|
|||
// @Security Bearer
|
||||
// @Accept json
|
||||
// @Param body body domain.LinkExamPrepAssessmentInput true "Request payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=LinkExamPrepAssessmentData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -79,7 +79,7 @@ func (h *Handler) LinkExamPrepAssessment(c *fiber.Ctx) error {
|
|||
// @Param parentId path int64 true "Parent id"
|
||||
// @Param parentKind path string true "Parent kind"
|
||||
// @Param questionSetId path int64 true "Question set id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ func (h *Handler) ListExamPrepCatalogCourses(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.ReorderIDsRequest true "ordered_ids: every course id exactly once"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Router /api/v1/admin/courses/reorder [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -257,7 +257,7 @@ func (h *Handler) UpdateExamPrepCatalogCourse(c *fiber.Ctx) error {
|
|||
// @Summary Delete course
|
||||
// @Tags learning
|
||||
// @Param id path int true "Course ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Router /api/v1/admin/courses/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Produce json
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ func (h *Handler) ListExamPrepLessonsByUnitModule(c *fiber.Ctx) error {
|
|||
// @Param chapterId path int64 true "Chapter id"
|
||||
// @Accept json
|
||||
// @Param body body domain.ReorderIDsRequest true "Request payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -321,7 +321,7 @@ func (h *Handler) UpdateExamPrepLesson(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/lessons/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import (
|
|||
// @Param body body domain.CreateExamPrepPracticeInput true "Practice"
|
||||
// @Router /api/v1/admin/practices [post]
|
||||
// @Security Bearer
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=domain.ExamPrepPractice}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -64,7 +64,7 @@ func (h *Handler) CreateExamPrepPracticeFromInput(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/practices [get]
|
||||
// @Router /api/v1/practices [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=ListAllExamPrepPracticesData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -147,7 +147,7 @@ func (h *Handler) CreateExamPrepPractice(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/lessons/{lessonId}/practices [get]
|
||||
// @Router /api/v1/lessons/{lessonId}/practices [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=ListExamPrepPracticesByLessonData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -189,7 +189,7 @@ func (h *Handler) ListExamPrepPracticesByLesson(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/practices/{id} [get]
|
||||
// @Router /api/v1/practices/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.ExamPrepPractice}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -238,7 +238,7 @@ func (h *Handler) GetExamPrepPracticeByID(c *fiber.Ctx) error {
|
|||
// @Param body body domain.UpdateExamPrepPracticeInput true "Fields to update"
|
||||
// @Router /api/v1/admin/practices/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.ExamPrepPractice}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -298,7 +298,7 @@ func (h *Handler) UpdateExamPrepPractice(c *fiber.Ctx) error {
|
|||
// @Param body body domain.UpdateExamPrepPracticeParentsInput true "Parent links (replaces all; use empty array to detach)"
|
||||
// @Router /api/v1/admin/practices/{id}/parents [put]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.ExamPrepPractice}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -362,7 +362,7 @@ func (h *Handler) UpdateExamPrepPracticeParents(c *fiber.Ctx) error {
|
|||
// @Param parentId path int true "Parent entity ID"
|
||||
// @Router /api/v1/admin/practices/{id}/parents/{parentKind}/{parentId} [delete]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.ExamPrepPractice}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -424,7 +424,7 @@ func (h *Handler) UnlinkExamPrepPracticeParent(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Exam prep practice ID"
|
||||
// @Router /api/v1/admin/practices/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -522,7 +522,7 @@ func (h *Handler) listExamPrepPracticesResponse(c *fiber.Ctx, items []domain.Exa
|
|||
// @Param body body domain.CreateExamPrepPracticeInput true "Practice"
|
||||
// @Router /api/v1/admin/courses/{courseId}/practices [post]
|
||||
// @Security Bearer
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=domain.ExamPrepPractice}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -562,7 +562,7 @@ func (h *Handler) CreateExamPrepPracticeForCatalogCourse(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/courses/{courseId}/practices [get]
|
||||
// @Router /api/v1/courses/{courseId}/practices [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=ListExamPrepPracticesByCatalogCourseData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -598,7 +598,7 @@ func (h *Handler) ListExamPrepPracticesByCatalogCourse(c *fiber.Ctx) error {
|
|||
// @Param body body domain.CreateExamPrepPracticeInput true "Practice"
|
||||
// @Router /api/v1/admin/chapters/{chapterId}/practices [post]
|
||||
// @Security Bearer
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=domain.ExamPrepPractice}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -638,7 +638,7 @@ func (h *Handler) CreateExamPrepPracticeForUnit(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/chapters/{chapterId}/practices [get]
|
||||
// @Router /api/v1/chapters/{chapterId}/practices [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=ListExamPrepPracticesByUnitData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ func (h *Handler) ListExamPrepUnitsByCatalogCourse(c *fiber.Ctx) error {
|
|||
// @Param body body domain.ReorderIDsRequest true "ordered_ids: every chapter id in this course, new order"
|
||||
// @Router /api/v1/admin/courses/{courseId}/chapters/reorder [put]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -321,7 +321,7 @@ func (h *Handler) UpdateExamPrepUnit(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Chapter ID"
|
||||
// @Router /api/v1/admin/chapters/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ func mapFAQToRes(f domain.FAQ) faqRes {
|
|||
// @Param category query string false "Filter by category"
|
||||
// @Param limit query int false "Limit (default 50)"
|
||||
// @Param offset query int false "Offset (default 0)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listFAQsRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/faqs [get]
|
||||
|
|
@ -124,7 +124,7 @@ func (h *Handler) ListPublicFAQs(c *fiber.Ctx) error {
|
|||
// @Tags faqs
|
||||
// @Produce json
|
||||
// @Param id path int true "FAQ ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=faqRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/faqs/{id} [get]
|
||||
|
|
@ -166,7 +166,7 @@ func (h *Handler) GetPublicFAQByID(c *fiber.Ctx) error {
|
|||
// @Param category query string false "Filter by category"
|
||||
// @Param limit query int false "Limit (default 20)"
|
||||
// @Param offset query int false "Offset (default 0)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listFAQsRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/faqs [get]
|
||||
|
|
@ -228,7 +228,7 @@ func (h *Handler) ListFAQsAdmin(c *fiber.Ctx) error {
|
|||
// @Tags faqs
|
||||
// @Produce json
|
||||
// @Param id path int true "FAQ ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=faqRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -271,7 +271,7 @@ func (h *Handler) GetFAQByIDAdmin(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body createFAQReq true "Create FAQ payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=faqRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/faqs [post]
|
||||
|
|
@ -323,7 +323,7 @@ func (h *Handler) CreateFAQ(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "FAQ ID"
|
||||
// @Param body body updateFAQReq true "Update FAQ payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=faqRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -381,7 +381,7 @@ func (h *Handler) UpdateFAQ(c *fiber.Ctx) error {
|
|||
// @Tags faqs
|
||||
// @Produce json
|
||||
// @Param id path int true "FAQ ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=DeleteFAQData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ func mapFieldOptionToRes(o domain.ProfileFieldOption) fieldOptionRes {
|
|||
// @Tags field-options
|
||||
// @Produce json
|
||||
// @Param field_key query string false "Filter by field key"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.ProfileFieldOptionsGrouped}
|
||||
// @Router /api/v1/field-options [get]
|
||||
func (h *Handler) ListPublicFieldOptions(c *fiber.Ctx) error {
|
||||
var fieldKeyPtr *string
|
||||
|
|
@ -91,7 +91,7 @@ func (h *Handler) ListPublicFieldOptions(c *fiber.Ctx) error {
|
|||
// @Tags field-options
|
||||
// @Produce json
|
||||
// @Param active_only query bool false "If true, only keys with active options"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=ListFieldKeysData}
|
||||
// @Router /api/v1/field-options/fields [get]
|
||||
func (h *Handler) ListFieldKeys(c *fiber.Ctx) error {
|
||||
activeOnly := c.Query("active_only", "true") == "true"
|
||||
|
|
@ -117,7 +117,7 @@ func (h *Handler) ListFieldKeys(c *fiber.Ctx) error {
|
|||
// @Param status query string false "ACTIVE or INACTIVE"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Param offset query int false "Offset"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listFieldOptionsRes}
|
||||
// @Router /api/v1/admin/field-options [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -159,7 +159,7 @@ func (h *Handler) ListFieldOptionsAdmin(c *fiber.Ctx) error {
|
|||
// @Tags field-options
|
||||
// @Produce json
|
||||
// @Param id path int true "Option ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=fieldOptionRes}
|
||||
// @Router /api/v1/admin/field-options/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -191,7 +191,7 @@ func (h *Handler) GetFieldOptionByIDAdmin(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body createFieldOptionReq true "Create option"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=fieldOptionRes}
|
||||
// @Router /api/v1/admin/field-options [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -239,7 +239,7 @@ func (h *Handler) CreateFieldOption(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Option ID"
|
||||
// @Param body body updateFieldOptionReq true "Update option"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=fieldOptionRes}
|
||||
// @Router /api/v1/admin/field-options/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -284,7 +284,7 @@ func (h *Handler) UpdateFieldOption(c *fiber.Ctx) error {
|
|||
// @Tags field-options
|
||||
// @Produce json
|
||||
// @Param id path int true "Option ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Router /api/v1/admin/field-options/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func (h *Handler) resolveFileURL(c *fiber.Ctx, storedPath string) string {
|
|||
// @Summary Get presigned URL for a file
|
||||
// @Tags files
|
||||
// @Param key query string true "MinIO object key (e.g. profile_pictures/uuid.jpg)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=GetFileURLData}
|
||||
// @Router /api/v1/admin/files/url [get]
|
||||
// @Router /api/v1/files/url [get]
|
||||
// @Security Bearer
|
||||
|
|
@ -128,7 +128,7 @@ func (h *Handler) extractObjectKeyFromReference(reference string) (string, error
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body refreshFileURLReq true "reference (object key, minio://..., or existing presigned URL)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=RefreshFileURLData}
|
||||
// @Router /api/v1/admin/files/refresh-url [post]
|
||||
// @Router /api/v1/files/refresh-url [post]
|
||||
// @Security Bearer
|
||||
|
|
@ -187,7 +187,7 @@ func (h *Handler) RefreshFileURL(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body presignedUploadReq true "Presigned upload request"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=presignedUploadRes}
|
||||
// @Router /api/v1/admin/files/presign-upload [post]
|
||||
// @Router /api/v1/files/presign-upload [post]
|
||||
// @Security Bearer
|
||||
|
|
@ -284,7 +284,7 @@ func (h *Handler) CreatePresignedUpload(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body completePresignedUploadReq true "Complete upload request"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=uploadMediaRes}
|
||||
// @Router /api/v1/admin/files/complete-upload [post]
|
||||
// @Router /api/v1/files/complete-upload [post]
|
||||
// @Security Bearer
|
||||
|
|
@ -412,7 +412,7 @@ func objectKeyMatchesMediaType(objectKey, mediaType string) bool {
|
|||
// @Accept multipart/form-data
|
||||
// @Param media_type formData string true "Media type: image|audio|video|pdf"
|
||||
// @Param file formData file true "Media file"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=uploadMediaRes}
|
||||
// @Router /api/v1/admin/files/upload [post]
|
||||
// @Router /api/v1/files/upload [post]
|
||||
// @Security Bearer
|
||||
|
|
@ -663,7 +663,7 @@ func normalizeAndValidateMediaContentType(mediaType, contentType, fileName strin
|
|||
// @Tags files
|
||||
// @Accept multipart/form-data
|
||||
// @Param file formData file true "Audio file (mp3, wav, ogg, m4a, aac, webm)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=UploadAudioData}
|
||||
// @Router /api/v1/admin/files/audio [post]
|
||||
// @Router /api/v1/files/audio [post]
|
||||
// @Security Bearer
|
||||
|
|
@ -790,7 +790,7 @@ func (h *Handler) UploadAudio(c *fiber.Ctx) error {
|
|||
// @Param question_id formData int true "Question ID"
|
||||
// @Param question_set_id formData int true "Question Set ID"
|
||||
// @Param file formData file true "Audio recording"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=SubmitAudioAnswerData}
|
||||
// @Router /api/v1/questions/audio-answer [post]
|
||||
// @Security Bearer
|
||||
// @Produce json
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ func (h *Handler) GetAllIssues(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Issue ID"
|
||||
// @Param body body updateIssueStatusReq true "Status update payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/issues/{id}/status [patch]
|
||||
|
|
@ -393,7 +393,7 @@ func (h *Handler) UpdateIssueStatus(c *fiber.Ctx) error {
|
|||
// @Tags issues
|
||||
// @Produce json
|
||||
// @Param id path int true "Issue ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/issues/{id} [delete]
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ type listPersonasData struct {
|
|||
// @Tags personas
|
||||
// @Accept json
|
||||
// @Param body body domain.CreateLmsPersonaInput true "Persona"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=domain.LmsPersona}
|
||||
// @Router /api/v1/admin/personas [post]
|
||||
// @Security Bearer
|
||||
// @Produce json
|
||||
|
|
@ -70,7 +70,7 @@ func (h *Handler) CreatePersona(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/personas [get]
|
||||
// @Router /api/v1/personas [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listPersonasData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -112,7 +112,7 @@ func (h *Handler) ListPersonas(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/personas/{id} [get]
|
||||
// @Router /api/v1/personas/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.LmsPersona}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -145,7 +145,7 @@ func (h *Handler) GetPersona(c *fiber.Ctx) error {
|
|||
// @Param body body domain.UpdateLmsPersonaInput true "Fields to update"
|
||||
// @Router /api/v1/admin/personas/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.LmsPersona}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -185,7 +185,7 @@ func (h *Handler) UpdatePersona(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Persona ID"
|
||||
// @Router /api/v1/admin/personas/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ func (h *Handler) GetMyLMSProgress(c *fiber.Ctx) error {
|
|||
// @Description Returns progress for the course → unit → module → lesson learning hierarchy.
|
||||
// @Tags learning
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.ExamPrepProgressSummary}
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/progress-summary [get]
|
||||
// @Security Bearer
|
||||
|
|
@ -115,7 +115,7 @@ func (h *Handler) AdminGetUserLMSLearningActivity(c *fiber.Ctx) error {
|
|||
// @Param user_id path int true "Target user ID"
|
||||
// @Param limit query int false "Max items after merge (default 40, max 120)"
|
||||
// @Param include_practices query bool false "Include completed LMS practices (more verbose)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.UserRecentActivityFeed}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ func mapMobileAppVersionToRes(v domain.MobileAppVersion) mobileAppVersionRes {
|
|||
// @Produce json
|
||||
// @Param platform query string true "Platform: ANDROID or IOS"
|
||||
// @Param version_code query int true "Client build number (Android versionCode / iOS build number)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.MobileAppVersionCheckResult}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/app/version/check [get]
|
||||
|
|
@ -131,7 +131,7 @@ func (h *Handler) CheckMobileAppVersion(c *fiber.Ctx) error {
|
|||
// @Param status query string false "Filter by ACTIVE or INACTIVE"
|
||||
// @Param limit query int false "Limit (default 20)"
|
||||
// @Param offset query int false "Offset (default 0)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listMobileAppVersionsRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/app-versions [get]
|
||||
|
|
@ -196,7 +196,7 @@ func (h *Handler) ListMobileAppVersionsAdmin(c *fiber.Ctx) error {
|
|||
// @Tags app-versions
|
||||
// @Produce json
|
||||
// @Param id path int true "App version ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=mobileAppVersionRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -241,7 +241,7 @@ func (h *Handler) GetMobileAppVersionByIDAdmin(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body createMobileAppVersionReq true "App version payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=mobileAppVersionRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/app-versions [post]
|
||||
|
|
@ -301,7 +301,7 @@ func (h *Handler) CreateMobileAppVersion(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "App version ID"
|
||||
// @Param body body updateMobileAppVersionReq true "App version payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=mobileAppVersionRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -367,7 +367,7 @@ func (h *Handler) UpdateMobileAppVersion(c *fiber.Ctx) error {
|
|||
// @Tags app-versions
|
||||
// @Produce json
|
||||
// @Param id path int true "App version ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ func (w *hijackResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
|||
// @Tags notifications
|
||||
// @Produce json
|
||||
// @Param id path int true "Notification ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.Notification}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 403 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
|
|
@ -226,7 +226,7 @@ func (h *Handler) GetNotificationByID(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/notifications/{id}/read [patch]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.Notification}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -272,7 +272,7 @@ func (h *Handler) MarkNotificationAsRead(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/notifications/mark-all-read [post]
|
||||
// @Router /api/v1/notifications/mark-all-read [post]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -315,7 +315,7 @@ func (h *Handler) MarkAllNotificationsAsRead(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/notifications/{id}/unread [patch]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.Notification}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -361,7 +361,7 @@ func (h *Handler) MarkNotificationAsUnread(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/notifications/mark-all-unread [post]
|
||||
// @Router /api/v1/notifications/mark-all-unread [post]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -403,7 +403,7 @@ func (h *Handler) MarkAllNotificationsAsUnread(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/notifications [delete]
|
||||
// @Router /api/v1/notifications [delete]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -445,7 +445,7 @@ func (h *Handler) DeleteUserNotifications(c *fiber.Ctx) error {
|
|||
// @Tags notifications
|
||||
// @Produce json
|
||||
// @Param id path int true "Notification ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -509,7 +509,7 @@ func (h *Handler) DeleteInAppNotification(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body object true "Notification IDs" example({"ids":[1,2,3]})
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=DeleteInAppNotificationsData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/delete-in-app [post]
|
||||
|
|
@ -756,7 +756,7 @@ func (h *Handler) CreateAndSendNotification(c *fiber.Ctx) error {
|
|||
// @Security Bearer
|
||||
// @Param limit query int false "Limit" default(10)
|
||||
// @Param offset query int false "Offset" default(0) minimum(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} GetUserNotificationResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -829,7 +829,7 @@ func (h *Handler) GetUserNotification(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/notifications/unread [get]
|
||||
// @Router /api/v1/notifications/unread [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} CountUnreadNotificationsResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -876,7 +876,7 @@ func (h *Handler) CountUnreadNotifications(c *fiber.Ctx) error {
|
|||
// @Param is_read query bool false "Is read"
|
||||
// @Param after query string false "After"
|
||||
// @Param before query string false "Before"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} GetAllNotificationsResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -961,9 +961,9 @@ type SendSingleAfroSMSReq struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param sendSMS body SendSingleAfroSMSReq true "Send SMS request"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} domain.Response{data=SendSingleAfroSMSReq}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/sendSMS [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -1036,7 +1036,7 @@ func (h *Handler) SendSingleAfroSMS(c *fiber.Ctx) error {
|
|||
// @Security Bearer
|
||||
// @Accept json
|
||||
// @Param body body handlers.RegisterDeviceToken.Request true "Device token and platform"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -1118,7 +1118,7 @@ func (h *Handler) RegisterDeviceToken(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body object{title=string,message=string} true "Test notification content"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=SendTestPushNotificationData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 401 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -1224,14 +1224,14 @@ func (h *Handler) SendTestPushNotification(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body object{title=string,message=string,image=string,user_ids=[]int64,role=string,scheduled_at=string} true "Bulk push content"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=SendBulkPushNotificationData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/bulk-push [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Success 201 {object} domain.Response "Scheduled notification created when scheduled_at is provided"
|
||||
// @Success 201 {object} domain.Response{data=domain.ScheduledNotification} "Scheduled notification created when scheduled_at is provided"
|
||||
func (h *Handler) SendBulkPushNotification(c *fiber.Ctx) error {
|
||||
title := c.FormValue("title")
|
||||
message := c.FormValue("message")
|
||||
|
|
@ -1435,14 +1435,14 @@ func (h *Handler) SendBulkPushNotification(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body object{message=string,user_ids=[]int64,role=string,phone_numbers=[]string,scheduled_at=string} true "Bulk SMS content"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=SendBulkSMSData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/bulk-sms [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Success 201 {object} domain.Response "Scheduled notification created when scheduled_at is provided"
|
||||
// @Success 201 {object} domain.Response{data=domain.ScheduledNotification} "Scheduled notification created when scheduled_at is provided"
|
||||
func (h *Handler) SendBulkSMS(c *fiber.Ctx) error {
|
||||
type Request struct {
|
||||
Message string `json:"message" validate:"required"`
|
||||
|
|
@ -1623,14 +1623,14 @@ func (h *Handler) SendBulkSMS(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body object{title=string,message=string,user_ids=[]int64,role=string,team_member_ids=[]int64,team_role=string,scheduled_at=string,type=string,level=string} true "Bulk in-app content"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=SendBulkInAppNotificationData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/bulk-in-app [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Success 201 {object} domain.Response "Scheduled notification created when scheduled_at is provided"
|
||||
// @Success 201 {object} domain.Response{data=domain.ScheduledNotification} "Scheduled notification created when scheduled_at is provided"
|
||||
func (h *Handler) SendBulkInAppNotification(c *fiber.Ctx) error {
|
||||
type Request struct {
|
||||
Title string `json:"title" validate:"required"`
|
||||
|
|
@ -1799,7 +1799,7 @@ func (h *Handler) SendBulkInAppNotification(c *fiber.Ctx) error {
|
|||
// @Tags notifications
|
||||
// @Produce json
|
||||
// @Param id path int true "Scheduled Notification ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.ScheduledNotification}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/scheduled/{id} [get]
|
||||
|
|
@ -1842,7 +1842,7 @@ func (h *Handler) GetScheduledNotification(c *fiber.Ctx) error {
|
|||
// @Param before query string false "Filter before date (RFC3339)"
|
||||
// @Param limit query int false "Page size" default(20)
|
||||
// @Param page query int false "Page number" default(1)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} ListScheduledNotificationsResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/scheduled [get]
|
||||
|
|
@ -1914,7 +1914,7 @@ func (h *Handler) ListScheduledNotifications(c *fiber.Ctx) error {
|
|||
// @Tags notifications
|
||||
// @Produce json
|
||||
// @Param id path int true "Scheduled Notification ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.ScheduledNotification}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/scheduled/{id}/cancel [post]
|
||||
|
|
@ -1980,7 +1980,7 @@ func (h *Handler) parseEmailAttachment(c *fiber.Ctx) []*resend.Attachment {
|
|||
// @Tags notifications
|
||||
// @Accept multipart/form-data
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/send-email [post]
|
||||
|
|
@ -2045,7 +2045,7 @@ func (h *Handler) SendSingleEmail(c *fiber.Ctx) error {
|
|||
// @Tags notifications
|
||||
// @Accept multipart/form-data
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=SendBulkEmailData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/bulk-email [post]
|
||||
|
|
@ -2064,7 +2064,7 @@ func (h *Handler) SendSingleEmail(c *fiber.Ctx) error {
|
|||
// @Param team_member_ids formData string false "Comma-separated team-member IDs"
|
||||
// @Param team_role formData string false "Team role used to select recipients"
|
||||
// @Param scheduled_at formData string false "Optional future delivery time in RFC3339 format"
|
||||
// @Success 201 {object} domain.Response "Scheduled notification created when scheduled_at is provided"
|
||||
// @Success 201 {object} domain.Response{data=domain.ScheduledNotification} "Scheduled notification created when scheduled_at is provided"
|
||||
func (h *Handler) SendBulkEmail(c *fiber.Ctx) error {
|
||||
role := c.FormValue("role")
|
||||
userIDsRaw := c.FormValue("user_ids")
|
||||
|
|
@ -2260,7 +2260,7 @@ func (h *Handler) SendBulkEmail(c *fiber.Ctx) error {
|
|||
// @Security Bearer
|
||||
// @Accept json
|
||||
// @Param body body handlers.UnregisterDeviceToken.Request true "Device token to unregister"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ type listAdminPaymentsRes struct {
|
|||
// @Param max_amount query number false "Maximum amount"
|
||||
// @Param limit query int false "Page size" default(20)
|
||||
// @Param offset query int false "Page offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listAdminPaymentsRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/payments [get]
|
||||
// @Security Bearer
|
||||
|
|
@ -134,7 +134,7 @@ func (h *Handler) ListAdminPayments(c *fiber.Ctx) error {
|
|||
// @Tags payments
|
||||
// @Produce json
|
||||
// @Param id path int true "Payment ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=adminPaymentRes}
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/payments/{id} [get]
|
||||
// @Security Bearer
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ func (h *Handler) GetLmsPracticeFull(c *fiber.Ctx) error {
|
|||
// @Tags learning
|
||||
// @Produce json
|
||||
// @Param id path int true "Exam prep practice ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=quizFullData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/practices/{id}/full [get]
|
||||
|
|
@ -381,7 +381,7 @@ func (h *Handler) UpdateLmsPracticeFull(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Exam prep practice ID"
|
||||
// @Param body body domain.FullUpdatePracticeInput true "Full practice update payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=quizFullData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/practices/{id}/full [put]
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ func parseOptionalGroupIDQuery(c *fiber.Ctx) (*int64, error) {
|
|||
// @Description Valid stimulus and response component kind codes for dynamic question-type definitions
|
||||
// @Tags questions
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=componentCatalogRes}
|
||||
// @Router /api/v1/admin/questions/component-catalog [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -126,7 +126,7 @@ func (h *Handler) GetQuestionTypeComponentCatalog(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body validateQuestionTypeDefinitionReq true "Stimulus and response component kinds"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=ValidateQuestionTypeDefinitionData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/validate-question-type-definition [post]
|
||||
// @Security Bearer
|
||||
|
|
@ -161,7 +161,7 @@ func (h *Handler) ValidateQuestionTypeDefinition(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body createQuestionTypeDefinitionReq true "Question type definition payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=domain.QuestionTypeDefinition}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definitions [post]
|
||||
|
|
@ -229,7 +229,7 @@ func (h *Handler) CreateQuestionTypeDefinition(c *fiber.Ctx) error {
|
|||
// @Param include_system query bool false "Include system seeded definitions" default(true)
|
||||
// @Param limit query int false "Page size (default 20, max 200)" default(20)
|
||||
// @Param offset query int false "Page offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listQuestionTypeDefinitionsData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definitions [get]
|
||||
|
|
@ -311,7 +311,7 @@ func (h *Handler) ListQuestionTypeDefinitions(c *fiber.Ctx) error {
|
|||
// @Tags questions
|
||||
// @Produce json
|
||||
// @Param id path int true "Question type definition id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.QuestionTypeDefinition}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definitions/{id} [get]
|
||||
|
|
@ -349,7 +349,7 @@ func (h *Handler) GetQuestionTypeDefinitionByID(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Question type definition id"
|
||||
// @Param limit query int false "Limit" default(20)
|
||||
// @Param offset query int false "Offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.PracticesByQuestionTypeDefinitionSummary}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definitions/{id}/practices [get]
|
||||
|
|
@ -400,7 +400,7 @@ func (h *Handler) ListPracticesByQuestionTypeDefinition(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Question type definition id"
|
||||
// @Param body body updateQuestionTypeDefinitionReq true "Update question type definition payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=UpdateQuestionTypeDefinitionData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definitions/{id} [put]
|
||||
|
|
@ -477,7 +477,7 @@ func (h *Handler) UpdateQuestionTypeDefinition(c *fiber.Ctx) error {
|
|||
// @Tags questions
|
||||
// @Produce json
|
||||
// @Param id path int true "Question type definition id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=DeleteQuestionTypeDefinitionData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definitions/{id} [delete]
|
||||
|
|
@ -517,7 +517,7 @@ func (h *Handler) DeleteQuestionTypeDefinition(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body createQuestionTypeDefinitionGroupReq true "Group payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=domain.QuestionTypeDefinitionGroup}
|
||||
// @Router /api/v1/admin/questions/type-definition-groups [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -569,7 +569,7 @@ func (h *Handler) CreateQuestionTypeDefinitionGroup(c *fiber.Ctx) error {
|
|||
// @Param status query string false "Filter by status (ACTIVE, INACTIVE)"
|
||||
// @Param limit query int false "Page size (default 20, max 200)" default(20)
|
||||
// @Param offset query int false "Page offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listQuestionTypeDefinitionGroupsData}
|
||||
// @Router /api/v1/admin/questions/type-definition-groups [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -627,7 +627,7 @@ func (h *Handler) ListQuestionTypeDefinitionGroups(c *fiber.Ctx) error {
|
|||
// @Tags questions
|
||||
// @Produce json
|
||||
// @Param id path int true "Group id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.QuestionTypeDefinitionGroupDetail}
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definition-groups/{id} [get]
|
||||
// @Security Bearer
|
||||
|
|
@ -671,7 +671,7 @@ func (h *Handler) GetQuestionTypeDefinitionGroupByID(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Group id"
|
||||
// @Param body body updateQuestionTypeDefinitionGroupReq true "Update group payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.QuestionTypeDefinitionGroup}
|
||||
// @Router /api/v1/admin/questions/type-definition-groups/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -732,7 +732,7 @@ func (h *Handler) UpdateQuestionTypeDefinitionGroup(c *fiber.Ctx) error {
|
|||
// @Tags questions
|
||||
// @Produce json
|
||||
// @Param id path int true "Group id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=DeleteQuestionTypeDefinitionGroupData}
|
||||
// @Router /api/v1/admin/questions/type-definition-groups/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ func activityLogQuestionSummary(questionType string, stored string, payload *dom
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body createQuestionReq true "Create question payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=questionRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions [post]
|
||||
|
|
@ -369,7 +369,7 @@ func (h *Handler) CreateQuestion(c *fiber.Ctx) error {
|
|||
// @Tags questions
|
||||
// @Produce json
|
||||
// @Param id path int true "Question ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=questionRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/{id} [get]
|
||||
|
|
@ -419,7 +419,7 @@ func (h *Handler) GetQuestionByID(c *fiber.Ctx) error {
|
|||
// @Param status query string false "Status filter (DRAFT, PUBLISHED, INACTIVE)"
|
||||
// @Param limit query int false "Limit" default(10)
|
||||
// @Param offset query int false "Offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listQuestionsRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions [get]
|
||||
|
|
@ -485,7 +485,7 @@ func (h *Handler) ListQuestions(c *fiber.Ctx) error {
|
|||
// @Param q query string true "Search query"
|
||||
// @Param limit query int false "Limit" default(10)
|
||||
// @Param offset query int false "Offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listQuestionsRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/search [get]
|
||||
|
|
@ -561,7 +561,7 @@ type updateQuestionReq struct {
|
|||
// @Produce json
|
||||
// @Param id path int true "Question ID"
|
||||
// @Param body body updateQuestionReq true "Update question payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/{id} [put]
|
||||
|
|
@ -735,7 +735,7 @@ func (h *Handler) UpdateQuestion(c *fiber.Ctx) error {
|
|||
// @Tags questions
|
||||
// @Produce json
|
||||
// @Param id path int true "Question ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/{id} [delete]
|
||||
|
|
@ -858,7 +858,7 @@ func (h *Handler) enforcePracticeSequenceForStudent(c *fiber.Ctx, set domain.Que
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body createQuestionSetReq true "Create question set payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=questionSetRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets [post]
|
||||
|
|
@ -930,7 +930,7 @@ func (h *Handler) CreateQuestionSet(c *fiber.Ctx) error {
|
|||
// @Tags question-sets
|
||||
// @Produce json
|
||||
// @Param id path int true "Question Set ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=questionSetRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{id} [get]
|
||||
|
|
@ -998,7 +998,7 @@ func (h *Handler) GetQuestionSetByID(c *fiber.Ctx) error {
|
|||
// @Param set_type query string true "Set type (PRACTICE, QUIZ, EXAM, SURVEY, CAPSTONE)"
|
||||
// @Param limit query int false "Limit" default(10)
|
||||
// @Param offset query int false "Offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listQuestionSetsRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets [get]
|
||||
|
|
@ -1064,7 +1064,7 @@ func (h *Handler) GetQuestionSetsByType(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param owner_type query string true "Owner type (SUB_COURSE, COURSE, CATEGORY, STANDALONE)"
|
||||
// @Param owner_id query int true "Owner ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=[]questionSetRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/by-owner [get]
|
||||
|
|
@ -1145,7 +1145,7 @@ type updateQuestionSetReq struct {
|
|||
// @Produce json
|
||||
// @Param id path int true "Question Set ID"
|
||||
// @Param body body updateQuestionSetReq true "Update question set payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{id} [put]
|
||||
|
|
@ -1231,7 +1231,7 @@ func (h *Handler) UpdateQuestionSet(c *fiber.Ctx) error {
|
|||
// @Tags question-sets
|
||||
// @Produce json
|
||||
// @Param id path int true "Question Set ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{id} [delete]
|
||||
|
|
@ -1379,7 +1379,7 @@ func questionSetItemsToRes(
|
|||
// @Produce json
|
||||
// @Param setId path int true "Question Set ID"
|
||||
// @Param body body addQuestionToSetReq true "Add question to set payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=AddQuestionToSetData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/questions [post]
|
||||
|
|
@ -1453,7 +1453,7 @@ func (h *Handler) AddQuestionToSet(c *fiber.Ctx) error {
|
|||
// @Tags question-set-items
|
||||
// @Produce json
|
||||
// @Param setId path int true "Question Set ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.QuestionSetQuestionTypesSummary}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -1676,7 +1676,7 @@ func (h *Handler) GetQuestionsInSet(c *fiber.Ctx) error {
|
|||
// @Param question_type query string false "Question type filter (e.g. AUDIO)"
|
||||
// @Param limit query int false "Limit" default(10)
|
||||
// @Param offset query int false "Offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=paginatedQuestionSetItemsRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -1787,7 +1787,7 @@ func (h *Handler) GetQuestionsByPractice(c *fiber.Ctx) error {
|
|||
// @Tags progression
|
||||
// @Produce json
|
||||
// @Param id path int true "Practice Question Set ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 403 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
|
|
@ -1957,7 +1957,7 @@ func (h *Handler) CompletePractice(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param setId path int true "Question Set ID"
|
||||
// @Param questionId path int true "Question ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/questions/{questionId} [delete]
|
||||
|
|
@ -2020,7 +2020,7 @@ type updateQuestionOrderReq struct {
|
|||
// @Param setId path int true "Question Set ID"
|
||||
// @Param questionId path int true "Question ID"
|
||||
// @Param body body updateQuestionOrderReq true "Update order payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/questions/{questionId}/order [put]
|
||||
|
|
@ -2107,7 +2107,7 @@ type addUserPersonaReq struct {
|
|||
// @Tags question-sets
|
||||
// @Produce json
|
||||
// @Param setId path int true "Question Set ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=[]userPersonaRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/personas [get]
|
||||
|
|
@ -2159,7 +2159,7 @@ func (h *Handler) GetUserPersonasByQuestionSet(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param setId path int true "Question Set ID"
|
||||
// @Param body body addUserPersonaReq true "Add user persona payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/personas [post]
|
||||
|
|
@ -2215,7 +2215,7 @@ func (h *Handler) AddUserPersonaToQuestionSet(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param setId path int true "Question Set ID"
|
||||
// @Param userId path int true "User ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/personas/{userId} [delete]
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ func isValidTargetType(t string) bool {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body submitRatingReq true "Submit rating payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=ratingRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/ratings [post]
|
||||
|
|
@ -112,7 +112,7 @@ func (h *Handler) SubmitRating(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param target_type query string true "Target type (app, course, sub_course)"
|
||||
// @Param target_id query int true "Target ID (0 for app)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=ratingRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -165,7 +165,7 @@ func (h *Handler) GetMyRating(c *fiber.Ctx) error {
|
|||
// @Param target_id query int true "Target ID (0 for app)"
|
||||
// @Param limit query int false "Limit (default 20)"
|
||||
// @Param offset query int false "Offset (default 0)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=[]ratingRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/ratings [get]
|
||||
|
|
@ -235,7 +235,7 @@ func (h *Handler) GetRatingsByTarget(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param target_type query string true "Target type (app, course, sub_course)"
|
||||
// @Param target_id query int true "Target ID (0 for app)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=ratingSummaryRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/ratings/summary [get]
|
||||
|
|
@ -285,7 +285,7 @@ func (h *Handler) GetRatingSummary(c *fiber.Ctx) error {
|
|||
// @Description Returns all ratings submitted by the current user
|
||||
// @Tags ratings
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=[]ratingRes}
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/ratings/me/all [get]
|
||||
// @Security Bearer
|
||||
|
|
@ -319,7 +319,7 @@ func (h *Handler) GetMyRatings(c *fiber.Ctx) error {
|
|||
// @Tags ratings
|
||||
// @Produce json
|
||||
// @Param id path int true "Rating ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/ratings/{id} [delete]
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
// @Param is_system query bool false "Filter by system role (true/false)"
|
||||
// @Param page query int false "Page number (default: 1)"
|
||||
// @Param page_size query int false "Page size (default: 20)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=ListRolesData}
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/roles [get]
|
||||
// @Security Bearer
|
||||
|
|
@ -210,7 +210,7 @@ func (h *Handler) CreateRole(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Role ID"
|
||||
// @Param body body domain.UpdateRoleReq true "Role update payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/roles/{id} [put]
|
||||
|
|
@ -289,7 +289,7 @@ func (h *Handler) UpdateRole(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "Role ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/roles/{id} [delete]
|
||||
|
|
@ -345,7 +345,7 @@ func (h *Handler) DeleteRole(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Role ID"
|
||||
// @Param body body domain.SetRolePermissionsReq true "Permission IDs payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/roles/{id}/permissions [put]
|
||||
|
|
@ -541,7 +541,7 @@ func (h *Handler) ListPermissionGroups(c *fiber.Ctx) error {
|
|||
// @Tags rbac
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/permissions/sync [post]
|
||||
// @Security Bearer
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ func (h *Handler) GetMyReferrals(c *fiber.Ctx) error {
|
|||
// @Description Attributes the authenticated learner to one referrer. Apply within seven days of account creation and before any successful positive payment. Codes are case-insensitive and surrounding whitespace is ignored. Self referral, reassignment, inactive referrers, and invalid codes are rejected.
|
||||
// @Accept json
|
||||
// @Param body body applyReferralReq true "Referral share code"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
|
|||
288
internal/web_server/handlers/response_contracts.go
Normal file
288
internal/web_server/handlers/response_contracts.go
Normal file
|
|
@ -0,0 +1,288 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
domain "Rezina-Backend/internal/domain"
|
||||
time "time"
|
||||
)
|
||||
|
||||
// MessageResponse is returned by operations with no data payload. Metadata is
|
||||
// reserved and currently null; data is omitted by the runtime JSON encoder.
|
||||
type MessageResponse struct {
|
||||
Message string `json:"message"`
|
||||
Success bool `json:"success"`
|
||||
StatusCode int `json:"status_code"`
|
||||
// Always null for message-only domain responses.
|
||||
Metadata *NullResponseValue `json:"metadata" extensions:"x-nullable"`
|
||||
}
|
||||
|
||||
// NullResponseValue represents a reserved null field (never a populated object).
|
||||
// @Description Reserved metadata value. Always null; no object properties are returned.
|
||||
type NullResponseValue struct{}
|
||||
|
||||
// MessageAPIResponse is the alternate envelope used by legacy account operations.
|
||||
type MessageAPIResponse struct {
|
||||
Status string `json:"status" enums:"success,error"`
|
||||
Message string `json:"message"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
}
|
||||
|
||||
// Endpoint-specific payloads mirror the JSON fields returned by handlers.
|
||||
|
||||
type DeleteEmailTemplateData struct {
|
||||
Id int64 `json:"id"`
|
||||
}
|
||||
|
||||
type RawQuestionSetResponse struct {
|
||||
BannerImage *string `json:"BannerImage"`
|
||||
CreatedAt time.Time `json:"CreatedAt"`
|
||||
Description *string `json:"Description"`
|
||||
ID int64 `json:"ID"`
|
||||
IntroVideoURL *string `json:"IntroVideoURL"`
|
||||
OwnerID *int64 `json:"OwnerID"`
|
||||
OwnerType *string `json:"OwnerType"`
|
||||
PassingScore *int32 `json:"PassingScore"`
|
||||
Persona *string `json:"Persona"`
|
||||
SetType string `json:"SetType"`
|
||||
ShuffleQuestions bool `json:"ShuffleQuestions"`
|
||||
Status string `json:"Status"`
|
||||
TimeLimitMinutes *int32 `json:"TimeLimitMinutes"`
|
||||
Title string `json:"Title"`
|
||||
UpdatedAt *time.Time `json:"UpdatedAt"`
|
||||
UserPersonas []domain.UserPersona `json:"UserPersonas"`
|
||||
}
|
||||
|
||||
type ListExamPrepAssessmentsData struct {
|
||||
Assessments []RawQuestionSetResponse `json:"assessments"`
|
||||
}
|
||||
|
||||
type LinkExamPrepAssessmentData struct {
|
||||
Assessment RawQuestionSetResponse `json:"assessment"`
|
||||
ParentId int64 `json:"parent_id"`
|
||||
ParentKind string `json:"parent_kind"`
|
||||
}
|
||||
|
||||
type ListAllExamPrepPracticesData struct {
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
Practices []domain.ExamPrepPractice `json:"practices"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
type ListExamPrepPracticesByLessonData struct {
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
Practices []domain.ExamPrepPractice `json:"practices"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
type ListExamPrepPracticesByCatalogCourseData struct {
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
Practices []domain.ExamPrepPractice `json:"practices"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
type ListExamPrepPracticesByUnitData struct {
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
Practices []domain.ExamPrepPractice `json:"practices"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
type DeleteFAQData struct {
|
||||
Id int64 `json:"id"`
|
||||
}
|
||||
|
||||
type ListFieldKeysData struct {
|
||||
Fields []string `json:"fields"`
|
||||
}
|
||||
|
||||
type GetFileURLData struct {
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type RefreshFileURLData struct {
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
ObjectKey string `json:"object_key"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type UploadAudioData struct {
|
||||
ContentType string `json:"content_type"`
|
||||
ObjectKey string `json:"object_key"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type SubmitAudioAnswerData struct {
|
||||
AudioUrl string `json:"audio_url"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Id int64 `json:"id"`
|
||||
QuestionId int64 `json:"question_id"`
|
||||
QuestionSetId int64 `json:"question_set_id"`
|
||||
}
|
||||
|
||||
type DeleteInAppNotificationsData struct {
|
||||
DeletedCount int64 `json:"deleted_count"`
|
||||
RequestedIds int `json:"requested_ids"`
|
||||
}
|
||||
|
||||
type GetUserNotificationResponse struct {
|
||||
Limit int `json:"limit"`
|
||||
Notifications []domain.Notification `json:"notifications"`
|
||||
Offset int `json:"offset"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
type CountUnreadNotificationsResponse struct {
|
||||
Unread int64 `json:"unread"`
|
||||
}
|
||||
|
||||
type GetAllNotificationsResponse struct {
|
||||
Limit int `json:"limit"`
|
||||
Notifications []domain.Notification `json:"notifications"`
|
||||
Page int `json:"page"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
type SendTestPushNotificationData struct {
|
||||
DevicesCount int `json:"devices_count"`
|
||||
Image string `json:"image"`
|
||||
Message string `json:"message"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type SendBulkPushNotificationData struct {
|
||||
DevicesTargeted int `json:"devices_targeted"`
|
||||
Failed int `json:"failed"`
|
||||
Image string `json:"image"`
|
||||
Sent int `json:"sent"`
|
||||
TargetUsers int `json:"target_users"`
|
||||
}
|
||||
|
||||
type SendBulkSMSData struct {
|
||||
Failed int `json:"failed"`
|
||||
Sent int `json:"sent"`
|
||||
TotalRecipients int `json:"total_recipients"`
|
||||
}
|
||||
|
||||
type SendBulkInAppNotificationData struct {
|
||||
Failed int `json:"failed"`
|
||||
Sent int `json:"sent"`
|
||||
TeamMemberRecipients int `json:"team_member_recipients"`
|
||||
TotalRecipients int `json:"total_recipients"`
|
||||
UserRecipients int `json:"user_recipients"`
|
||||
}
|
||||
|
||||
type ListScheduledNotificationsResponse struct {
|
||||
Limit int `json:"limit"`
|
||||
Page int `json:"page"`
|
||||
ScheduledNotifications []domain.ScheduledNotification `json:"scheduled_notifications"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
type SendBulkEmailData struct {
|
||||
Failed int `json:"failed"`
|
||||
Sent int `json:"sent"`
|
||||
TeamMemberRecipients int `json:"team_member_recipients"`
|
||||
TotalRecipients int `json:"total_recipients"`
|
||||
UserRecipients int `json:"user_recipients"`
|
||||
}
|
||||
|
||||
type ValidateQuestionTypeDefinitionData struct {
|
||||
Valid bool `json:"valid"`
|
||||
}
|
||||
|
||||
type UpdateQuestionTypeDefinitionData struct {
|
||||
Id int64 `json:"id"`
|
||||
}
|
||||
|
||||
type DeleteQuestionTypeDefinitionData struct {
|
||||
Id int64 `json:"id"`
|
||||
}
|
||||
|
||||
type DeleteQuestionTypeDefinitionGroupData struct {
|
||||
Id int64 `json:"id"`
|
||||
}
|
||||
|
||||
type AddQuestionToSetData struct {
|
||||
AssociatedQuestionId *int64 `json:"associated_question_id"`
|
||||
DisplayOrder int32 `json:"display_order"`
|
||||
Id int64 `json:"id"`
|
||||
QuestionId int64 `json:"question_id"`
|
||||
SetId int64 `json:"set_id"`
|
||||
}
|
||||
|
||||
type ListRolesData struct {
|
||||
Page int64 `json:"page"`
|
||||
PageSize int64 `json:"page_size"`
|
||||
Roles []domain.RoleRecord `json:"roles"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
type CheckSubscriptionStatusData struct {
|
||||
HasActiveSubscription bool `json:"has_active_subscription"`
|
||||
}
|
||||
|
||||
type documentAdminGetSampleVideoData struct {
|
||||
Iframe string `json:"iframe"`
|
||||
Video VimeoVideoResponse `json:"video"`
|
||||
}
|
||||
|
||||
type RevokeTeamInvitationData struct {
|
||||
Id int64 `json:"id"`
|
||||
}
|
||||
|
||||
type CheckProfileCompletedData struct {
|
||||
IsProfileCompleted bool `json:"is_profile_completed"`
|
||||
ProfileCompletionPercentage int `json:"profile_completion_percentage"`
|
||||
}
|
||||
|
||||
type CheckUserPendingData struct {
|
||||
IsPending bool `json:"is_pending"`
|
||||
}
|
||||
|
||||
type GetAllUsersData struct {
|
||||
Total int64 `json:"total"`
|
||||
Users []domain.UserProfileResponse `json:"users"`
|
||||
}
|
||||
|
||||
type ListAccountDeletionRequestsData struct {
|
||||
Items []domain.AccountDeletionRequest `json:"items"`
|
||||
Page int64 `json:"page"`
|
||||
PageSize int64 `json:"page_size"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
type DeleteMyUserAccountData struct {
|
||||
CanCancelUntilAt time.Time `json:"can_cancel_until_at"`
|
||||
GracePeriodDays int `json:"grace_period_days"`
|
||||
ScheduledPurgeAt time.Time `json:"scheduled_purge_at"`
|
||||
}
|
||||
|
||||
type PurgeDueDeletedUsersData struct {
|
||||
BatchLimit int32 `json:"batch_limit"`
|
||||
DeletedCount int64 `json:"deleted_count"`
|
||||
}
|
||||
|
||||
type UploadProfilePictureData struct {
|
||||
ProfilePictureUrl string `json:"profile_picture_url"`
|
||||
}
|
||||
|
||||
type GetSampleVideoData struct {
|
||||
Iframe string `json:"iframe"`
|
||||
Video VimeoVideoResponse `json:"video"`
|
||||
}
|
||||
|
||||
// VimeoUploadResultData preserves the raw service result's existing JSON names.
|
||||
type VimeoUploadResultData struct {
|
||||
VimeoID string `json:"VimeoID"`
|
||||
URI string `json:"URI"`
|
||||
Link string `json:"Link"`
|
||||
UploadLink string `json:"UploadLink"`
|
||||
Status string `json:"Status"`
|
||||
}
|
||||
|
||||
type VimeoTranscodeStatusData struct {
|
||||
VideoID string `json:"video_id"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
49
internal/web_server/handlers/response_contracts_test.go
Normal file
49
internal/web_server/handlers/response_contracts_test.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"Rezina-Backend/internal/domain"
|
||||
vimeoservice "Rezina-Backend/internal/services/vimeo"
|
||||
"Rezina-Backend/internal/web_server/response"
|
||||
)
|
||||
|
||||
func responseJSONFields(t *testing.T, value any) map[string]any {
|
||||
t.Helper()
|
||||
raw, err := json.Marshal(value)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var fields map[string]any
|
||||
if err = json.Unmarshal(raw, &fields); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
// Documentation-only payloads must preserve existing wire names, including the
|
||||
// PascalCase fields returned by raw service/domain structs. This prevents a
|
||||
// documentation improvement from silently advertising a new JSON API contract.
|
||||
func TestResponseDocumentationMatchesRuntimeJSONFields(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
runtime, documented any
|
||||
}{
|
||||
{"message domain envelope", domain.Response{}, MessageResponse{}},
|
||||
{"message legacy envelope", response.APIResponse{}, MessageAPIResponse{}},
|
||||
{"raw assessment question set", domain.QuestionSet{}, RawQuestionSetResponse{}},
|
||||
{"raw Vimeo upload result", vimeoservice.UploadResult{}, VimeoUploadResultData{}},
|
||||
{"notification count", map[string]int{"unread": 0}, CountUnreadNotificationsResponse{}},
|
||||
{"video status", map[string]string{"video_id": "", "status": ""}, VimeoTranscodeStatusData{}},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
runtime := responseJSONFields(t, tc.runtime)
|
||||
documented := responseJSONFields(t, tc.documented)
|
||||
if !reflect.DeepEqual(runtime, documented) {
|
||||
t.Fatalf("runtime JSON=%v; documented JSON=%v", runtime, documented)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ import (
|
|||
// @Tags settings
|
||||
// @Router /api/v1/admin/settings [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} response.APIResponse{data=domain.SettingListRes}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -46,7 +46,7 @@ func (h *Handler) GetGlobalSettingList(c *fiber.Ctx) error {
|
|||
// @Router /api/v1/admin/settings/{key} [get]
|
||||
// @Security Bearer
|
||||
// @Param key path string true "Key"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} response.APIResponse{data=domain.SettingRes}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -85,7 +85,7 @@ func (h *Handler) GetGlobalSettingByKey(c *fiber.Ctx) error {
|
|||
// @Security Bearer
|
||||
// @Accept json
|
||||
// @Param body body domain.SaveSettingListReq true "Request payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} response.APIResponse{data=domain.SettingListRes}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ type requestCheckoutLinkRes struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body requestCheckoutLinkReq false "Optional plan or category for deep link"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=requestCheckoutLinkRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 409 {object} domain.ErrorResponse
|
||||
// @Failure 429 {object} domain.ErrorResponse
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ type autoRenewReq struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body createPlanReq true "Create plan payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=planRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/subscription-plans [post]
|
||||
|
|
@ -207,7 +207,7 @@ func (h *Handler) CreateSubscriptionPlan(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param active_only query bool false "Customer requests always return active plans; false is honored only by the admin endpoint" default(true)
|
||||
// @Param category query string false "Filter by plan category (EDUCATION)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=[]planRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/subscription-plans [get]
|
||||
|
|
@ -254,7 +254,7 @@ func (h *Handler) ListSubscriptionPlans(c *fiber.Ctx) error {
|
|||
// @Tags subscriptions
|
||||
// @Produce json
|
||||
// @Param id path int true "Plan ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=planRes}
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/subscription-plans/{id} [get]
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
|
|
@ -291,7 +291,7 @@ func (h *Handler) GetSubscriptionPlan(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Plan ID"
|
||||
// @Param body body updatePlanReq true "Update plan payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/subscription-plans/{id} [put]
|
||||
|
|
@ -398,7 +398,7 @@ func (h *Handler) UpdateSubscriptionPlan(c *fiber.Ctx) error {
|
|||
// @Tags subscriptions
|
||||
// @Produce json
|
||||
// @Param id path int true "Plan ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/subscription-plans/{id} [delete]
|
||||
// @Security Bearer
|
||||
|
|
@ -458,7 +458,7 @@ func (h *Handler) DeleteSubscriptionPlan(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body subscribeReq true "Subscribe payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=subscriptionRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @deprecated Use POST /api/v1/payments/subscribe for user subscriptions with payment
|
||||
|
|
@ -529,7 +529,7 @@ func (h *Handler) Subscribe(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body subscribeWithPaymentReq true "Subscribe with payment payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=subscriptionCheckoutRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 409 {object} domain.ErrorResponse "User already has active subscription"
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -644,7 +644,7 @@ func (h *Handler) SubscribeWithPayment(c *fiber.Ctx) error {
|
|||
// @Description Returns all active subscriptions for the authenticated user (one per plan category)
|
||||
// @Tags subscriptions
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=[]subscriptionRes}
|
||||
// @Router /api/v1/subscriptions/me [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -684,7 +684,7 @@ func (h *Handler) GetMySubscription(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param limit query int false "Limit" default(20)
|
||||
// @Param offset query int false "Offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=[]subscriptionRes}
|
||||
// @Router /api/v1/subscriptions/history [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -725,7 +725,7 @@ func (h *Handler) GetMySubscriptionHistory(c *fiber.Ctx) error {
|
|||
// @Description Returns whether the authenticated user has an active subscription
|
||||
// @Tags subscriptions
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=CheckSubscriptionStatusData}
|
||||
// @Router /api/v1/subscriptions/status [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -761,7 +761,7 @@ func (h *Handler) CheckSubscriptionStatus(c *fiber.Ctx) error {
|
|||
// @Tags subscriptions
|
||||
// @Produce json
|
||||
// @Param id path int true "Subscription ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/subscriptions/{id}/cancel [post]
|
||||
// @Security Bearer
|
||||
|
|
@ -819,7 +819,7 @@ func (h *Handler) CancelSubscription(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Subscription ID"
|
||||
// @Param body body autoRenewReq true "Auto-renew payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/subscriptions/{id}/auto-renew [put]
|
||||
// @Security Bearer
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ package handlers
|
|||
// @Produce json
|
||||
// @Param active_only query bool false "Return only active plans (default true)"
|
||||
// @Param category query string false "Filter by plan category (EDUCATION)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=[]planRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -25,7 +25,7 @@ func documentAdminListSubscriptionPlans() {}
|
|||
// @Tags subscriptions
|
||||
// @Produce json
|
||||
// @Param id path int true "Plan ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=planRes}
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -42,7 +42,7 @@ func documentAdminGetSubscriptionPlan() {}
|
|||
// @Param video_id query string false "Vimeo Video ID to use as sample" default(76979871)
|
||||
// @Param width query int false "Player width" default(640)
|
||||
// @Param height query int false "Player height" default(360)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=documentAdminGetSampleVideoData}
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -59,7 +59,7 @@ func documentAdminGetSampleVideo() {}
|
|||
// @Param url query string true "Vimeo video URL"
|
||||
// @Param width query int false "Desired width"
|
||||
// @Param height query int false "Desired height"
|
||||
// @Success 200 {object} vimeo.OEmbedResponse
|
||||
// @Success 200 {object} domain.Response{data=vimeo.OEmbedResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
|
|||
30
internal/web_server/handlers/swagger_service_info.go
Normal file
30
internal/web_server/handlers/swagger_service_info.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package handlers
|
||||
|
||||
// Documentation-only declarations for the anonymous service discovery handlers
|
||||
// registered in routes.go. These functions are not runtime handlers.
|
||||
|
||||
type serviceInfoResponse struct {
|
||||
Message string `json:"message" example:"Welcome to Rezina Backend API"`
|
||||
Version string `json:"version" example:"1.0.1"`
|
||||
}
|
||||
|
||||
type apiIndexResponse struct {
|
||||
AdminAPI string `json:"admin_api" example:"/api/v1/admin"`
|
||||
ClientAPI string `json:"client_api" example:"/api/v1"`
|
||||
}
|
||||
|
||||
// documentServiceInfo godoc
|
||||
// @Summary Service welcome and version
|
||||
// @Tags discovery
|
||||
// @Produce json
|
||||
// @Success 200 {object} serviceInfoResponse
|
||||
// @Router / [get]
|
||||
func documentServiceInfo() {}
|
||||
|
||||
// documentAPIIndex godoc
|
||||
// @Summary Discover the admin and customer API roots
|
||||
// @Tags discovery
|
||||
// @Produce json
|
||||
// @Success 200 {object} apiIndexResponse
|
||||
// @Router /api/v1/ [get]
|
||||
func documentAPIIndex() {}
|
||||
|
|
@ -500,7 +500,7 @@ func (h *Handler) GetAllTeamMembers(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Team Member ID"
|
||||
// @Param body body domain.UpdateTeamMemberReq true "Team member update payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 401 {object} domain.ErrorResponse
|
||||
// @Failure 403 {object} domain.ErrorResponse
|
||||
|
|
@ -590,7 +590,7 @@ func (h *Handler) UpdateTeamMember(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Team Member ID"
|
||||
// @Param body body domain.UpdateTeamMemberStatusReq true "Status update payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 401 {object} domain.ErrorResponse
|
||||
// @Failure 403 {object} domain.ErrorResponse
|
||||
|
|
@ -691,7 +691,7 @@ func (h *Handler) UpdateTeamMemberStatus(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "Team Member ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 401 {object} domain.ErrorResponse
|
||||
// @Failure 403 {object} domain.ErrorResponse
|
||||
|
|
@ -789,7 +789,7 @@ func (h *Handler) GetTeamMemberStats(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param id path int true "Team Member ID"
|
||||
// @Param body body changePasswordReq true "Password change payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 401 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ func mapTeamInvitationListItem(row domain.TeamInvitationWithMember) teamInvitati
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.InviteTeamMemberReq true "Invite payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Success 201 {object} domain.Response{data=domain.InviteTeamMemberRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/members/invite [post]
|
||||
|
|
@ -115,7 +115,7 @@ func (h *Handler) InviteTeamMember(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Produce json
|
||||
// @Param id path int true "Team member ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.InviteTeamMemberRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/members/{id}/resend-invite [post]
|
||||
|
|
@ -163,7 +163,7 @@ func (h *Handler) ResendTeamInvitation(c *fiber.Ctx) error {
|
|||
// @Param status query string false "pending, accepted, expired, or revoked"
|
||||
// @Param limit query int false "Limit (default 20)"
|
||||
// @Param offset query int false "Offset (default 0)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=listTeamInvitationsRes}
|
||||
// @Router /api/v1/admin/team/invitations [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -208,7 +208,7 @@ func (h *Handler) ListTeamInvitations(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Produce json
|
||||
// @Param id path int true "Invitation ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=RevokeTeamInvitationData}
|
||||
// @Router /api/v1/admin/team/invitations/{id}/revoke [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -242,7 +242,7 @@ func (h *Handler) RevokeTeamInvitation(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Produce json
|
||||
// @Param token query string true "Invitation token"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.VerifyTeamInvitationRes}
|
||||
// @Router /api/v1/admin/team/invitations/verify [get]
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
|
|
@ -276,7 +276,7 @@ func (h *Handler) VerifyTeamInvitation(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.AcceptTeamInvitationReq true "Accept invitation payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.TeamMemberResponse}
|
||||
// @Router /api/v1/admin/team/invitations/accept [post]
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) AcceptTeamInvitation(c *fiber.Ctx) error {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import (
|
|||
// @Produce json
|
||||
// @Param email query string true "Team member email"
|
||||
// @Param otp query string true "Reset OTP from the email link"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=domain.TeamVerifyPasswordResetRes}
|
||||
// @Router /api/v1/admin/team/verifyResetCode [get]
|
||||
func (h *Handler) VerifyTeamPasswordReset(c *fiber.Ctx) error {
|
||||
email := c.Query("email")
|
||||
|
|
@ -35,7 +35,7 @@ func (h *Handler) VerifyTeamPasswordReset(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.TeamSendPasswordResetReq true "Email"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -72,7 +72,7 @@ func (h *Handler) SendTeamPasswordReset(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.TeamResetPasswordReq true "Reset payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ func (h *Handler) GetUserSummary(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param user_id path int true "User ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=CheckProfileCompletedData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -115,7 +115,7 @@ func (h *Handler) CheckProfileCompleted(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.UpdateUserReq true "Update user payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -196,7 +196,7 @@ func (h *Handler) UpdateUser(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param knowledge_level body domain.UpdateKnowledgeLevelReq true "Knowledge level"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 401 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
|
|
@ -252,9 +252,9 @@ func (h *Handler) UpdateUserKnowledgeLevel(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param resendOtp body domain.ResendOtpReq true "Resend OTP"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/user/resend-otp [post]
|
||||
func (h *Handler) ResendOtp(c *fiber.Ctx) error {
|
||||
var req domain.ResendOtpReq
|
||||
|
|
@ -390,7 +390,7 @@ func (h *Handler) ResendOtp(c *fiber.Ctx) error {
|
|||
// @Tags user
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=CheckUserPendingData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
|
|
@ -449,9 +449,9 @@ func (h *Handler) CheckUserPending(c *fiber.Ctx) error {
|
|||
// @Param country query string false "Country filter (case-insensitive match on stored value)"
|
||||
// @Param region query string false "Region filter (case-insensitive match on stored value)"
|
||||
// @Param subscription_status query string false "Derived subscription filter: ACTIVE, PENDING, or Unsubscribed (matches response subscription_status semantics)"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=GetAllUsersData}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/users [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -599,9 +599,9 @@ func (h *Handler) GetAllUsers(c *fiber.Ctx) error {
|
|||
// @Param scheduled_after query string false "Scheduled after (RFC3339)"
|
||||
// @Param page query int false "Page number (default 1)"
|
||||
// @Param page_size query int false "Page size (default 10, max 100)"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=ListAccountDeletionRequestsData}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/users/deletion-requests [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -686,9 +686,9 @@ func (h *Handler) ListAccountDeletionRequests(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body object true "Status update payload" example({"user_id": 1, "status": "ACTIVE"})
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/user/status [patch]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -747,9 +747,9 @@ func (h *Handler) UpdateUserStatus(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param verifyOtp body domain.VerifyOtpReq true "Verify OTP"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} domain.Response{data=loginUserRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/user/verify-otp [post]
|
||||
func (h *Handler) VerifyOtp(c *fiber.Ctx) error {
|
||||
var req domain.VerifyOtpReq
|
||||
|
|
@ -933,9 +933,9 @@ type CheckPhoneEmailExistRes struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param checkPhoneEmailExist body CheckPhoneEmailExistReq true "Check phone number or email exist"
|
||||
// @Success 200 {object} CheckPhoneEmailExistRes
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=CheckPhoneEmailExistRes}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/user/checkPhoneEmailExist [post]
|
||||
func (h *Handler) CheckPhoneEmailExist(c *fiber.Ctx) error {
|
||||
// companyID := c.Locals("company_id").(domain.ValidInt64)
|
||||
|
|
@ -991,9 +991,9 @@ type RegisterCodeReq struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param registerCode body RegisterCodeReq true "Send register code"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} MessageAPIResponse
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/user/sendRegisterCode [post]
|
||||
func (h *Handler) SendRegisterCode(c *fiber.Ctx) error {
|
||||
// companyID := c.Locals("company_id").(domain.ValidInt64)
|
||||
|
|
@ -1051,9 +1051,9 @@ func (h *Handler) SendRegisterCode(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param registerUser body domain.RegisterUserReq true "Register user"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/user/register [post]
|
||||
// @Description Registers a learner with email or phone and password. The server assigns the learner role and selects the OTP medium from the contact method. An optional referral_code attributes the new account atomically; invalid or ineligible codes reject registration.
|
||||
func (h *Handler) RegisterUser(c *fiber.Ctx) error {
|
||||
|
|
@ -1183,9 +1183,9 @@ type ResetCodeReq struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param resetCode body ResetCodeReq true "Send reset code"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} MessageAPIResponse
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/user/sendResetCode [post]
|
||||
func (h *Handler) SendResetCode(c *fiber.Ctx) error {
|
||||
var req ResetCodeReq
|
||||
|
|
@ -1318,9 +1318,9 @@ type ResetPasswordReq struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param resetPassword body ResetPasswordReq true "Reset password"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} MessageAPIResponse
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/user/resetPassword [post]
|
||||
func (h *Handler) ResetPassword(c *fiber.Ctx) error {
|
||||
var req ResetPasswordReq
|
||||
|
|
@ -1389,9 +1389,9 @@ func (h *Handler) ResetTenantPassword(c *fiber.Ctx) error {
|
|||
// @Tags user
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} domain.UserProfileResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=domain.UserProfileResponse}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/user/user-profile [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -1513,9 +1513,9 @@ type AdminProfileRes struct {
|
|||
// @Tags user
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} AdminProfileRes
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=domain.UserProfileResponse}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/user/admin-profile [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -1647,9 +1647,9 @@ type SearchUserByNameOrPhoneReq struct {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param searchUserByNameOrPhone body SearchUserByNameOrPhoneReq true "Search for using his name or phone"
|
||||
// @Success 200 {object} domain.UserProfileResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=[]domain.UserProfileResponse}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/user/search [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -1785,10 +1785,10 @@ func (h *Handler) SearchUserByNameOrPhone(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "User ID"
|
||||
// @Success 200 {object} domain.UserProfileResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=domain.UserProfileResponse}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 401 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/user/single/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
|
|
@ -1906,9 +1906,9 @@ func (h *Handler) GetUserByID(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "User ID"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} MessageAPIResponse
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/user/delete/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -1969,10 +1969,10 @@ const (
|
|||
// @Description Starts account deletion with grace period before permanent purge
|
||||
// @Tags user
|
||||
// @Produce json
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 403 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=DeleteMyUserAccountData}
|
||||
// @Failure 401 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 403 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/user/me [delete]
|
||||
// @Security Bearer
|
||||
func (h *Handler) DeleteMyUserAccount(c *fiber.Ctx) error {
|
||||
|
|
@ -2022,10 +2022,10 @@ func (h *Handler) DeleteMyUserAccount(c *fiber.Ctx) error {
|
|||
// @Description Cancels a pending self-deletion request during grace period
|
||||
// @Tags user
|
||||
// @Produce json
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 403 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} MessageAPIResponse
|
||||
// @Failure 401 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 403 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/user/me/deletion/cancel [post]
|
||||
// @Security Bearer
|
||||
func (h *Handler) CancelMyUserAccountDeletion(c *fiber.Ctx) error {
|
||||
|
|
@ -2070,9 +2070,9 @@ func (h *Handler) CancelMyUserAccountDeletion(c *fiber.Ctx) error {
|
|||
// @Tags user
|
||||
// @Produce json
|
||||
// @Param limit query int false "Max users to purge in one run (default 100, max 1000)"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} response.APIResponse{data=PurgeDueDeletedUsersData}
|
||||
// @Failure 400 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Failure 500 {string} string "Plain-text error returned by the handler or authentication middleware"
|
||||
// @Router /api/v1/admin/internal/users/purge-due-deletions [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
|
|
@ -2123,9 +2123,9 @@ type UpdateUserSuspendRes struct {
|
|||
// @Produce json
|
||||
// @Param id path int true "User ID"
|
||||
// @Param file formData file true "Image file (jpg|png|webp)"
|
||||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Success 200 {object} domain.Response{data=UploadProfilePictureData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/user/{id}/profile-picture [post]
|
||||
// @Router /api/v1/user/{id}/profile-picture [post]
|
||||
// @Security Bearer
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ func (h *Handler) ListVimeoVideos(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param video_id path string true "Vimeo Video ID"
|
||||
// @Success 200 {object} VimeoVideoResponse
|
||||
// @Success 200 {object} domain.Response{data=VimeoVideoResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/videos/{video_id} [get]
|
||||
|
|
@ -239,7 +239,7 @@ func (h *Handler) GetVimeoVideo(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body CreatePullUploadRequest true "Pull Upload Request"
|
||||
// @Success 201 {object} VimeoUploadResponse
|
||||
// @Success 201 {object} domain.Response{data=VimeoUploadResultData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/uploads/pull [post]
|
||||
|
|
@ -300,7 +300,7 @@ func (h *Handler) CreatePullUpload(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body CreateTusUploadRequest true "TUS Upload Request"
|
||||
// @Success 201 {object} VimeoUploadResponse
|
||||
// @Success 201 {object} domain.Response{data=VimeoUploadResultData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/uploads/tus [post]
|
||||
|
|
@ -367,7 +367,7 @@ func (h *Handler) CreateTusUpload(c *fiber.Ctx) error {
|
|||
// @Param loop query bool false "Loop video"
|
||||
// @Param muted query bool false "Mute video"
|
||||
// @Param background query bool false "Background mode (no controls)"
|
||||
// @Success 200 {object} VimeoEmbedResponse
|
||||
// @Success 200 {object} domain.Response{data=VimeoEmbedResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/videos/{video_id}/embed [get]
|
||||
|
|
@ -437,7 +437,7 @@ func (h *Handler) GetEmbedCode(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param video_id path string true "Vimeo Video ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} MessageResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/videos/{video_id} [delete]
|
||||
|
|
@ -485,7 +485,7 @@ func (h *Handler) DeleteVimeoVideo(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param video_id path string true "Vimeo Video ID"
|
||||
// @Success 200 {object} map[string]string
|
||||
// @Success 200 {object} domain.Response{data=VimeoTranscodeStatusData}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/videos/{video_id}/status [get]
|
||||
|
|
@ -537,7 +537,7 @@ func (h *Handler) GetTranscodeStatus(c *fiber.Ctx) error {
|
|||
// @Param video_id query string false "Vimeo Video ID to use as sample" default(76979871)
|
||||
// @Param width query int false "Player width" default(640)
|
||||
// @Param height query int false "Player height" default(360)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Success 200 {object} domain.Response{data=GetSampleVideoData}
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/vimeo/sample [get]
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
|
|
@ -581,7 +581,7 @@ func (h *Handler) GetSampleVideo(c *fiber.Ctx) error {
|
|||
// @Param url query string true "Vimeo video URL"
|
||||
// @Param width query int false "Desired width"
|
||||
// @Param height query int false "Desired height"
|
||||
// @Success 200 {object} vimeo.OEmbedResponse
|
||||
// @Success 200 {object} domain.Response{data=vimeo.OEmbedResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/vimeo/oembed [get]
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@ const (
|
|||
)
|
||||
|
||||
type APIResponse struct {
|
||||
Status Status `json:"status"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
Metadata interface{} `json:"metadata,omitempty"`
|
||||
Status Status `json:"status"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data,omitempty" swaggerignore:"true"`
|
||||
// Optional endpoint-specific metadata; omitted when there is no metadata.
|
||||
Metadata interface{} `json:"metadata,omitempty" swaggertype:"object"`
|
||||
Page *int `json:"page,omitempty"`
|
||||
Total *int `json:"total,omitempty"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ func registeredSwaggerContracts(t *testing.T) []swaggerRouteContract {
|
|||
})
|
||||
}
|
||||
result = append(result, swaggerRouteContract{Method: "get", Path: "/payment/success", Handler: "HandleChapaSuccessPage"})
|
||||
result = append(result, swaggerRouteContract{Method: "get", Path: "/", Handler: "documentServiceInfo"})
|
||||
result = append(result, swaggerRouteContract{Method: "get", Path: "/api/v1/", Handler: "documentAPIIndex"})
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
|||
140
internal/web_server/swagger_response_schema_test.go
Normal file
140
internal/web_server/swagger_response_schema_test.go
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
package httpserver
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"Rezina-Backend/docs"
|
||||
)
|
||||
|
||||
// Swagger 2 uses allOf to specialize a shared response envelope. Resolve those
|
||||
// overrides before inspecting data, so an empty base interface cannot hide an
|
||||
// undocumented response and a typed override is not mistaken for an empty field.
|
||||
func responseSchemaObject(t *testing.T, spec, schema map[string]any, seen map[string]bool) map[string]any {
|
||||
t.Helper()
|
||||
if reference, ok := schema["$ref"].(string); ok {
|
||||
if seen[reference] {
|
||||
return map[string]any{"type": "object", "description": "Recursive schema reference"}
|
||||
}
|
||||
seen[reference] = true
|
||||
definitions := spec["definitions"].(map[string]any)
|
||||
definition, ok := definitions[strings.TrimPrefix(reference, "#/definitions/")].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("missing response schema %s", reference)
|
||||
}
|
||||
return responseSchemaObject(t, spec, definition, seen)
|
||||
}
|
||||
result := map[string]any{}
|
||||
merge := func(part map[string]any) {
|
||||
for key, value := range part {
|
||||
if key == "properties" {
|
||||
properties, _ := result[key].(map[string]any)
|
||||
if properties == nil {
|
||||
properties = map[string]any{}
|
||||
result[key] = properties
|
||||
}
|
||||
for name, property := range value.(map[string]any) {
|
||||
properties[name] = property
|
||||
}
|
||||
} else {
|
||||
result[key] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
if parts, ok := schema["allOf"].([]any); ok {
|
||||
for _, part := range parts {
|
||||
merge(responseSchemaObject(t, spec, part.(map[string]any), cloneSchemaSeen(seen)))
|
||||
}
|
||||
}
|
||||
merge(schema)
|
||||
delete(result, "allOf")
|
||||
return result
|
||||
}
|
||||
|
||||
func cloneSchemaSeen(source map[string]bool) map[string]bool {
|
||||
result := map[string]bool{}
|
||||
for k, v := range source {
|
||||
result[k] = v
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func checkResponseSchemaDetail(t *testing.T, spec, schema map[string]any, path string, seen map[string]bool) {
|
||||
t.Helper()
|
||||
schema = responseSchemaObject(t, spec, schema, seen)
|
||||
kind, _ := schema["type"].(string)
|
||||
description, _ := schema["description"].(string)
|
||||
if kind == "" {
|
||||
// Dynamic question components are intentionally polymorphic. Their allowed
|
||||
// JSON types and kind-dependent interpretation must be explicit.
|
||||
if schema["x-json-types"] != nil && description != "" {
|
||||
return
|
||||
}
|
||||
t.Errorf("%s: response field has no type or documented JSON variants", path)
|
||||
return
|
||||
}
|
||||
if kind == "array" {
|
||||
items, ok := schema["items"].(map[string]any)
|
||||
if !ok {
|
||||
t.Errorf("%s: array has no item schema", path)
|
||||
return
|
||||
}
|
||||
checkResponseSchemaDetail(t, spec, items, path+"[]", cloneSchemaSeen(seen))
|
||||
}
|
||||
if kind == "object" {
|
||||
properties, _ := schema["properties"].(map[string]any)
|
||||
additional, hasAdditional := schema["additionalProperties"]
|
||||
if len(properties) == 0 && !hasAdditional && description == "" {
|
||||
t.Errorf("%s: object has no fields or documented extension semantics", path)
|
||||
}
|
||||
if values, ok := additional.(map[string]any); ok {
|
||||
if len(values) == 0 {
|
||||
if description == "" {
|
||||
t.Errorf("%s: arbitrary JSON dictionary needs a description", path)
|
||||
}
|
||||
} else {
|
||||
checkResponseSchemaDetail(t, spec, values, path+"{}", cloneSchemaSeen(seen))
|
||||
}
|
||||
}
|
||||
for name, property := range properties {
|
||||
checkResponseSchemaDetail(t, spec, property.(map[string]any), path+"."+name, cloneSchemaSeen(seen))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEveryAPIResponseHasDetailedSchema(t *testing.T) {
|
||||
var spec map[string]any
|
||||
if err := json.Unmarshal([]byte(docs.SwaggerInfo.ReadDoc()), &spec); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for path, raw := range spec["paths"].(map[string]any) {
|
||||
for method, value := range raw.(map[string]any) {
|
||||
operation := value.(map[string]any)
|
||||
for code, value := range operation["responses"].(map[string]any) {
|
||||
status, err := strconv.Atoi(code)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Redirects and protocol upgrades are described by status/headers,
|
||||
// rather than pretending that they return a JSON document.
|
||||
if status < 200 || (status >= 300 && status < 400) || status == 204 {
|
||||
continue
|
||||
}
|
||||
t.Run(fmt.Sprintf("%s %s %s", method, path, code), func(t *testing.T) {
|
||||
response := value.(map[string]any)
|
||||
schema, ok := response["schema"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatal("response is missing its schema")
|
||||
}
|
||||
if status < 300 && (schema["$ref"] == "#/definitions/domain.Response" || schema["$ref"] == "#/definitions/response.APIResponse") {
|
||||
t.Fatal("success uses an unspecialized generic response envelope")
|
||||
}
|
||||
checkResponseSchemaDetail(t, spec, schema, "response", map[string]bool{})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user