diff --git a/assets/openapi.json b/assets/openapi.json index 1f5648c86..e7126eb0f 100644 Binary files a/assets/openapi.json and b/assets/openapi.json differ diff --git a/assets/schemas.json b/assets/schemas.json index 82540d363..3c70ca90c 100644 Binary files a/assets/schemas.json and b/assets/schemas.json differ diff --git a/src/schemas/HelperTypes.ts b/src/schemas/HelperTypes.ts index e1e04f612..ef43f97b2 100644 --- a/src/schemas/HelperTypes.ts +++ b/src/schemas/HelperTypes.ts @@ -19,3 +19,15 @@ export type StringStringDictionary = { [key: string]: string; }; + +/** + * @TJS-type: number + * @TJS-format: float + */ +export type float = number; + +/** + * @TJS-type: string + * @TJS-format: byte + */ +export type base64str = string; diff --git a/src/schemas/Validator.ts b/src/schemas/Validator.ts index c719effc9..8b1c855f5 100644 --- a/src/schemas/Validator.ts +++ b/src/schemas/Validator.ts @@ -43,7 +43,7 @@ export const ajv = new Ajv({ allErrors: true, parseDate: true, allowDate: true, - schemas: schemas, + // schemas: schemas, coerceTypes: true, messages: true, strict: true, @@ -52,6 +52,7 @@ export const ajv = new Ajv({ }); addFormats(ajv); +ajv.addSchema(schemas); export function validateSchema(schema: string, data: G): G { const valid = ajv.validate(schema, data); diff --git a/src/schemas/api/messages/Attachments.ts b/src/schemas/api/messages/Attachments.ts index eb0d7194b..e10892c4a 100644 --- a/src/schemas/api/messages/Attachments.ts +++ b/src/schemas/api/messages/Attachments.ts @@ -16,7 +16,7 @@ along with this program. If not, see . */ -import { PartialUser } from "@spacebar/schemas"; +import { base64str, float, PartialUser } from "@spacebar/schemas"; export interface PublicAttachment { filename: string; @@ -39,8 +39,8 @@ export interface PublicAttachment { placeholder?: string; // voice messages - duration_secs?: number; - waveform?: string; // base64 byte array + duration_secs?: float; + waveform?: base64str; // base64 byte array // clips title?: string; // clips only? Documentation kinda sucks... diff --git a/src/schemas/uncategorised/MessageCreateSchema.ts b/src/schemas/uncategorised/MessageCreateSchema.ts index 585b849ea..1ad0cc4a4 100644 --- a/src/schemas/uncategorised/MessageCreateSchema.ts +++ b/src/schemas/uncategorised/MessageCreateSchema.ts @@ -17,14 +17,27 @@ */ import { Snowflake } from "../Identifiers"; -import { InteractionType, AllowedMentions, MessageReference, ApplicationCommandType, BaseMessageComponents, Embed, PollAnswer, PollMedia, PublicUser } from "@spacebar/schemas"; +import { + InteractionType, + AllowedMentions, + MessageReference, + ApplicationCommandType, + BaseMessageComponents, + Embed, + PollAnswer, + PollMedia, + PublicUser, + float, + base64str, +} from "@spacebar/schemas"; export type BaseMessageCreateAttachment = { filename: string; title?: string; // clips only? description?: string; // alt text - duration_secs?: number; //flat - waveform?: string; //base64 byte array + + duration_secs?: float; //flat + waveform?: base64str; //base64 byte array is_clip?: boolean; is_thumbnail?: boolean;