diff --git a/assets/openapi.json b/assets/openapi.json index c3e1419dd..0705f4ffe 100644 Binary files a/assets/openapi.json and b/assets/openapi.json differ diff --git a/assets/schemas.json b/assets/schemas.json index b12357ca7..b27dc2c78 100644 Binary files a/assets/schemas.json and b/assets/schemas.json differ diff --git a/src/api/routes/unique-username/username-attempt-unauthed.ts b/src/api/routes/unique-username/username-attempt-unauthed.ts index 3af1fa883..b225a2996 100644 --- a/src/api/routes/unique-username/username-attempt-unauthed.ts +++ b/src/api/routes/unique-username/username-attempt-unauthed.ts @@ -1,5 +1,5 @@ import { route } from "@spacebar/api"; -import { Config, User, UsernameAttemptUnauthedSchema } from "@spacebar/util"; +import { Config, UniqueUsernameAttemptSchema, User } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { HTTPError } from "lambert-server"; const router = Router(); @@ -7,15 +7,16 @@ const router = Router(); router.post( "/", route({ - requestBody: "UsernameAttemptUnauthedSchema", + requestBody: "UniqueUsernameAttemptSchema", responses: { - 200: { body: "UsernameAttemptResponse" }, + 200: { body: "UniqueUsernameAttemptResponse" }, 400: { body: "APIErrorResponse" }, }, - description: "Check if a username is available", + description: + "Checks whether a unique username is available for the user to claim.", }), async (req: Request, res: Response) => { - const body = req.body as UsernameAttemptUnauthedSchema; + const body = req.body as UniqueUsernameAttemptSchema; const { uniqueUsernames } = Config.get().general; if (!uniqueUsernames) { throw new HTTPError( diff --git a/src/api/routes/unique-username/username-suggestions-unauthed.ts b/src/api/routes/unique-username/username-suggestions-unauthed.ts index 9b112b558..2ce09285b 100644 --- a/src/api/routes/unique-username/username-suggestions-unauthed.ts +++ b/src/api/routes/unique-username/username-suggestions-unauthed.ts @@ -1,12 +1,14 @@ import { route } from "@spacebar/api"; +import { Config } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { HTTPError } from "lambert-server"; -import { Config } from "../../../util"; const router = Router(); router.get( "/", route({ + description: + "Returns a suggested unique username string based on the current user's username.", query: { global_name: { type: "string", diff --git a/src/util/schemas/UniqueUsernameAttemptSchema.ts b/src/util/schemas/UniqueUsernameAttemptSchema.ts new file mode 100644 index 000000000..39ebb25f2 --- /dev/null +++ b/src/util/schemas/UniqueUsernameAttemptSchema.ts @@ -0,0 +1,3 @@ +export interface UniqueUsernameAttemptSchema { + username: string; +} diff --git a/src/util/schemas/UsernameAttemptUnauthedSchema.ts b/src/util/schemas/UsernameAttemptUnauthedSchema.ts deleted file mode 100644 index 0ac83dd0e..000000000 --- a/src/util/schemas/UsernameAttemptUnauthedSchema.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface UsernameAttemptUnauthedSchema { - username: string; -} diff --git a/src/util/schemas/index.ts b/src/util/schemas/index.ts index bb449e450..f8fd5365f 100644 --- a/src/util/schemas/index.ts +++ b/src/util/schemas/index.ts @@ -66,13 +66,13 @@ export * from "./TemplateModifySchema"; export * from "./TotpDisableSchema"; export * from "./TotpEnableSchema"; export * from "./TotpSchema"; +export * from "./UniqueUsernameAttemptSchema"; export * from "./UserDeleteSchema"; export * from "./UserGuildSettingsSchema"; export * from "./UserModifySchema"; export * from "./UserNoteUpdateSchema"; export * from "./UserProfileModifySchema"; export * from "./UserSettingsSchema"; -export * from "./UsernameAttemptUnauthedSchema"; export * from "./Validator"; export * from "./VanityUrlSchema"; export * from "./VoiceIdentifySchema"; diff --git a/src/util/schemas/responses/TypedResponses.ts b/src/util/schemas/responses/TypedResponses.ts index fa169c253..0f4f9c79f 100644 --- a/src/util/schemas/responses/TypedResponses.ts +++ b/src/util/schemas/responses/TypedResponses.ts @@ -60,6 +60,9 @@ export type APIDMChannelArray = DmChannelDTO[]; export type APIBackupCodeArray = BackupCode[]; +export type PrivateUserResponse = APIPrivateUser; +export type PublicUserResponse = APIPublicUser; + export interface UserUpdateResponse extends APIPrivateUser { newToken?: string; } diff --git a/src/util/schemas/responses/UniqueUsernameAttemptResponse.ts b/src/util/schemas/responses/UniqueUsernameAttemptResponse.ts new file mode 100644 index 000000000..b9804f9cc --- /dev/null +++ b/src/util/schemas/responses/UniqueUsernameAttemptResponse.ts @@ -0,0 +1,3 @@ +export interface UniqueUsernameAttemptResponse { + taken: boolean; +} diff --git a/src/util/schemas/responses/UsernameAttemptResponse.ts b/src/util/schemas/responses/UsernameAttemptResponse.ts deleted file mode 100644 index 864a3bb00..000000000 --- a/src/util/schemas/responses/UsernameAttemptResponse.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface UsernameAttemptResponse { - taken: boolean; -}