add otp swagger
This commit is contained in:
145
lib/openapi.ts
145
lib/openapi.ts
@@ -309,6 +309,37 @@ export const openApiSpec = {
|
||||
budget: { type: "number", format: "float" },
|
||||
},
|
||||
},
|
||||
FantasyNews: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "string" },
|
||||
icon: { type: "string" },
|
||||
title: { type: "string" },
|
||||
description: { type: "string" },
|
||||
newsTime: { type: "string", format: "date-time" },
|
||||
createdAt: { type: "string", format: "date-time" },
|
||||
updatedAt: { type: "string", format: "date-time", nullable: true },
|
||||
},
|
||||
},
|
||||
FantasyNewsListResponse: {
|
||||
type: "object",
|
||||
properties: {
|
||||
data: {
|
||||
type: "array",
|
||||
items: { $ref: "#/components/schemas/FantasyNews" },
|
||||
},
|
||||
},
|
||||
},
|
||||
FantasyNewsCreateRequest: {
|
||||
type: "object",
|
||||
properties: {
|
||||
icon: { type: "string", example: "info" },
|
||||
title: { type: "string", example: "Lineup update" },
|
||||
description: { type: "string", example: "Confirmed team news before kickoff." },
|
||||
newsTime: { type: "string", format: "date-time", example: "2026-06-10T12:00:00.000Z" },
|
||||
},
|
||||
required: ["icon", "title", "description", "newsTime"],
|
||||
},
|
||||
PaymentRequestPayload: {
|
||||
type: "object",
|
||||
properties: {
|
||||
@@ -401,6 +432,46 @@ export const openApiSpec = {
|
||||
id: { type: "string" },
|
||||
},
|
||||
},
|
||||
MobileOtpRequestCodeRequest: {
|
||||
type: "object",
|
||||
properties: {
|
||||
phone: { type: "string", example: "09123456789" },
|
||||
},
|
||||
required: ["phone"],
|
||||
},
|
||||
MobileOtpRequestCodeResponse: {
|
||||
type: "object",
|
||||
properties: {
|
||||
ok: { type: "boolean", example: true },
|
||||
expiresIn: { type: "integer", example: 120 },
|
||||
},
|
||||
},
|
||||
MobileOtpVerifyRequest: {
|
||||
type: "object",
|
||||
properties: {
|
||||
phone: { type: "string", example: "09123456789" },
|
||||
code: { type: "string", example: "123456" },
|
||||
name: { type: "string", nullable: true, example: "Ali" },
|
||||
},
|
||||
required: ["phone", "code"],
|
||||
},
|
||||
MobileOtpVerifyResponse: {
|
||||
type: "object",
|
||||
properties: {
|
||||
token: { type: "string" },
|
||||
tokenType: { type: "string", example: "Bearer" },
|
||||
expiresAt: { type: "string", format: "date-time" },
|
||||
user: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "string" },
|
||||
name: { type: "string", nullable: true },
|
||||
phone: { type: "string", nullable: true },
|
||||
role: { $ref: "#/components/schemas/Role" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
CredentialsLoginRequest: {
|
||||
type: "object",
|
||||
properties: {
|
||||
@@ -547,6 +618,36 @@ export const openApiSpec = {
|
||||
]),
|
||||
},
|
||||
},
|
||||
"/api/auth/mobile/request-code": {
|
||||
post: {
|
||||
tags: ["Auth"],
|
||||
summary: "Request mobile OTP login code",
|
||||
requestBody: requestBody(
|
||||
{ $ref: "#/components/schemas/MobileOtpRequestCodeRequest" },
|
||||
{ phone: "09123456789" }
|
||||
),
|
||||
responses: Object.fromEntries([
|
||||
["200", jsonResponse("OTP code sent", { $ref: "#/components/schemas/MobileOtpRequestCodeResponse" })],
|
||||
errorResponse("400", "Invalid mobile phone", "Invalid mobile phone"),
|
||||
errorResponse("429", "OTP request rate limited", "Please wait before requesting a new code"),
|
||||
errorResponse("502", "SMS provider failed", "SMS send failed"),
|
||||
]),
|
||||
},
|
||||
},
|
||||
"/api/auth/mobile/verify": {
|
||||
post: {
|
||||
tags: ["Auth"],
|
||||
summary: "Verify mobile OTP login code",
|
||||
requestBody: requestBody(
|
||||
{ $ref: "#/components/schemas/MobileOtpVerifyRequest" },
|
||||
{ phone: "09123456789", code: "123456", name: "Ali" }
|
||||
),
|
||||
responses: Object.fromEntries([
|
||||
["200", jsonResponse("OTP verified", { $ref: "#/components/schemas/MobileOtpVerifyResponse" })],
|
||||
errorResponse("400", "Invalid or expired OTP", "Invalid or expired OTP"),
|
||||
]),
|
||||
},
|
||||
},
|
||||
"/api/auth/callback/credentials": {
|
||||
post: {
|
||||
tags: ["Auth"],
|
||||
@@ -1202,6 +1303,50 @@ export const openApiSpec = {
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/fantasy-news": {
|
||||
get: {
|
||||
tags: ["Fantasy News"],
|
||||
summary: "Get fantasy news",
|
||||
parameters: [
|
||||
{
|
||||
in: "header",
|
||||
name: "x-news-mode",
|
||||
required: false,
|
||||
schema: { type: "string", enum: ["latest"] },
|
||||
description: "Use latest to return the latest 4 summarized items",
|
||||
},
|
||||
{
|
||||
in: "header",
|
||||
name: "x-news-summary",
|
||||
required: false,
|
||||
schema: { type: "string", enum: ["true"] },
|
||||
description: "Use true to return the latest 4 summarized items",
|
||||
},
|
||||
],
|
||||
responses: {
|
||||
"200": jsonResponse("Fantasy news list", { $ref: "#/components/schemas/FantasyNewsListResponse" }),
|
||||
},
|
||||
},
|
||||
post: {
|
||||
tags: ["Fantasy News"],
|
||||
summary: "Create fantasy news",
|
||||
security: adminSecurity,
|
||||
requestBody: requestBody(
|
||||
{ $ref: "#/components/schemas/FantasyNewsCreateRequest" },
|
||||
{
|
||||
icon: "info",
|
||||
title: "Lineup update",
|
||||
description: "Confirmed team news before kickoff.",
|
||||
newsTime: "2026-06-10T12:00:00.000Z",
|
||||
}
|
||||
),
|
||||
responses: Object.fromEntries([
|
||||
["201", jsonResponse("Fantasy news created", { $ref: "#/components/schemas/FantasyNews" })],
|
||||
errorResponse("400", "Invalid fantasy news payload", "Invalid fantasy news payload"),
|
||||
errorResponse("401", "Admin access required", "Unauthorized"),
|
||||
]),
|
||||
},
|
||||
},
|
||||
"/api/upload/player-image": {
|
||||
post: {
|
||||
tags: ["Upload"],
|
||||
|
||||
Reference in New Issue
Block a user