mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
feat(openapi): explicit object-component registration via createNamedObject (#1183)
Signed-off-by: Hampus Kraft <[email protected]>
This commit is contained in:
1 parent
6e87f6e3d1
commit
6d537ef0db
6 files changed
+87
-33
No files matched your search
@@ -13,6 +13,7 @@ import {createBase64StringType} from '@fluxer/schema/src/primitives/FileValidato
|
||||
import {
|
||||
createBitflagInt32Type,
|
||||
createInt32EnumType,
|
||||
createNamedObject,
|
||||
createNamedStringLiteralUnion,
|
||||
createStringType,
|
||||
Int32Type,
|
||||
@@ -324,7 +325,7 @@ export const OAuth2ApplicationsMeResponse = z.union([ApplicationListResponse, Ap
|
||||
|
||||
export type OAuth2ApplicationsMeResponse = z.infer<typeof OAuth2ApplicationsMeResponse>;
|
||||
|
||||
const OAuth2AuthorizationResponse = z.object({
|
||||
const OAuth2AuthorizationResponse = createNamedObject('OAuth2AuthorizationResponse', {
|
||||
application: z
|
||||
.object({
|
||||
id: SnowflakeStringType.describe('The unique identifier of the application'),
|
||||
|
||||
@@ -316,6 +316,11 @@ export function createNamedStringLiteralUnion<T extends string>(
|
||||
.describe(`fluxer:EnumValues:${JSON.stringify(entries)}${descPart}`);
|
||||
}
|
||||
|
||||
export function createNamedObject<T extends z.ZodRawShape>(typeName: string, shape: T, description?: string) {
|
||||
const descPart = description ? ` ${description}` : '';
|
||||
return z.object(shape).describe(`fluxer:NamedObject:${typeName}${descPart}`);
|
||||
}
|
||||
|
||||
type FlexibleStringLiteralUnionOperand<T extends string> = z.ZodLiteral<T> | z.ZodString;
|
||||
type FlexibleStringLiteralUnionOperands<T extends string> = [
|
||||
z.ZodLiteral<T>,
|
||||
|
||||
Reference in new issue
Block a user