-
Notifications
You must be signed in to change notification settings - Fork 484
/
Copy pathschema-object-metadata.interface.ts
49 lines (46 loc) · 1.38 KB
/
schema-object-metadata.interface.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { Type } from '@nestjs/common';
import { EnumSchemaAttributes } from './enum-schema-attributes.interface';
import { ReferenceObject, SchemaObject } from './open-api-spec.interface';
export type EnumAllowedTypes =
| any[]
| Record<string, any>
| (() => any[] | Record<string, any>);
interface SchemaObjectCommonMetadata
extends Omit<SchemaObject, 'type' | 'required' | 'properties' | 'enum'> {
isArray?: boolean;
name?: string;
enum?: EnumAllowedTypes;
}
export type SchemaObjectMetadata =
| (SchemaObjectCommonMetadata & {
type?:
| Type<unknown>
| Function
| [Function]
| 'array'
| 'string'
| 'number'
| 'boolean'
| 'integer'
| 'null';
required?: boolean;
})
| ({
type?: Type<unknown> | Function | [Function] | Record<string, any>;
required?: boolean;
enumName: string;
enumSchema?: EnumSchemaAttributes;
} & SchemaObjectCommonMetadata)
| ({
type: 'object';
properties: Record<string, SchemaObjectMetadata>;
required?: string[];
selfRequired?: boolean;
} & SchemaObjectCommonMetadata)
| ({
type: 'object';
properties?: Record<string, SchemaObjectMetadata>;
additionalProperties: SchemaObject | ReferenceObject | boolean;
required?: string[];
selfRequired?: boolean;
} & SchemaObjectCommonMetadata);