diff --git a/packages/better-auth/src/api/routes/account.ts b/packages/better-auth/src/api/routes/account.ts index efb70aba1d..5cc3dce917 100644 --- a/packages/better-auth/src/api/routes/account.ts +++ b/packages/better-auth/src/api/routes/account.ts @@ -19,6 +19,7 @@ export const listUserAccounts = createAuthEndpoint( use: [sessionMiddleware], metadata: { openapi: { + operationId: "listUserAccounts", description: "List all accounts linked to the user", responses: { "200": { @@ -172,6 +173,7 @@ export const linkSocialAccount = createAuthEndpoint( metadata: { openapi: { description: "Link a social account to the user", + operationId: "linkSocialAccount", responses: { "200": { description: "Success", diff --git a/packages/better-auth/src/api/routes/callback.ts b/packages/better-auth/src/api/routes/callback.ts index 7def7c2921..d5b0fe7766 100644 --- a/packages/better-auth/src/api/routes/callback.ts +++ b/packages/better-auth/src/api/routes/callback.ts @@ -21,6 +21,7 @@ export const callbackOAuth = createAuthEndpoint( "/callback/:id", { method: ["GET", "POST"], + operationId: "handleOAuthCallback", body: schema.optional(), query: schema.optional(), metadata: HIDE_METADATA, diff --git a/packages/better-auth/src/api/routes/email-verification.ts b/packages/better-auth/src/api/routes/email-verification.ts index d1cf039448..dd86461bf8 100644 --- a/packages/better-auth/src/api/routes/email-verification.ts +++ b/packages/better-auth/src/api/routes/email-verification.ts @@ -69,6 +69,7 @@ export const sendVerificationEmail = createAuthEndpoint( "/send-verification-email", { method: "POST", + operationId: "sendVerificationEmail", body: z.object({ email: z.email().meta({ description: "The email to send the verification email to", @@ -82,6 +83,7 @@ export const sendVerificationEmail = createAuthEndpoint( }), metadata: { openapi: { + operationId: "sendVerificationEmail", description: "Send a verification email to the user", requestBody: { content: { @@ -191,6 +193,7 @@ export const verifyEmail = createAuthEndpoint( "/verify-email", { method: "GET", + operationId: "verifyEmail", query: z.object({ token: z.string().meta({ description: "The token to verify the email", @@ -236,46 +239,7 @@ export const verifyEmail = createAuthEndpoint( properties: { user: { type: "object", - properties: { - id: { - type: "string", - description: "User ID", - }, - email: { - type: "string", - description: "User email", - }, - name: { - type: "string", - description: "User name", - }, - image: { - type: "string", - description: "User image URL", - }, - emailVerified: { - type: "boolean", - description: - "Indicates if the user email is verified", - }, - createdAt: { - type: "string", - description: "User creation date", - }, - updatedAt: { - type: "string", - description: "User update date", - }, - }, - required: [ - "id", - "email", - "name", - "image", - "emailVerified", - "createdAt", - "updatedAt", - ], + $ref: "#/components/schemas/User", }, status: { type: "boolean", diff --git a/packages/better-auth/src/api/routes/reset-password.ts b/packages/better-auth/src/api/routes/reset-password.ts index ed68a0285e..f1f0b172bf 100644 --- a/packages/better-auth/src/api/routes/reset-password.ts +++ b/packages/better-auth/src/api/routes/reset-password.ts @@ -35,6 +35,7 @@ export const requestPasswordReset = createAuthEndpoint( "/request-password-reset", { method: "POST", + operationId: "forgetPassword", body: z.object({ /** * The email address of the user to send a password reset email to. @@ -59,6 +60,7 @@ export const requestPasswordReset = createAuthEndpoint( }), metadata: { openapi: { + operationId: "forgetPassword", description: "Send a password reset email to the user", responses: { "200": { @@ -139,6 +141,7 @@ export const requestPasswordResetCallback = createAuthEndpoint( "/reset-password/:token", { method: "GET", + operationId: "forgetPasswordCallback", query: z.object({ callbackURL: z.string().meta({ description: "The URL to redirect the user to reset their password", @@ -147,7 +150,28 @@ export const requestPasswordResetCallback = createAuthEndpoint( use: [originCheck((ctx) => ctx.query.callbackURL)], metadata: { openapi: { + operationId: "resetPasswordCallback", description: "Redirects the user to the callback URL with the token", + parameters: [ + { + name: "token", + in: "path", + required: true, + description: "The token to reset the password", + schema: { + type: "string", + }, + }, + { + name: "callbackURL", + in: "query", + required: true, + description: "The URL to redirect the user to reset their password", + schema: { + type: "string", + }, + }, + ], responses: { "200": { description: "Success", @@ -194,6 +218,7 @@ export const resetPassword = createAuthEndpoint( "/reset-password", { method: "POST", + operationId: "resetPassword", query: z .object({ token: z.string().optional(), @@ -212,6 +237,7 @@ export const resetPassword = createAuthEndpoint( }), metadata: { openapi: { + operationId: "resetPassword", description: "Reset the password for a user", responses: { "200": { diff --git a/packages/better-auth/src/api/routes/session.ts b/packages/better-auth/src/api/routes/session.ts index a7e8f90c38..3a79d55617 100644 --- a/packages/better-auth/src/api/routes/session.ts +++ b/packages/better-auth/src/api/routes/session.ts @@ -31,10 +31,12 @@ export const getSession =