-
Notifications
You must be signed in to change notification settings - Fork 537
Expand file tree
/
Copy pathschema-object-metadata.interface.ts
More file actions
53 lines (50 loc) · 1.44 KB
/
schema-object-metadata.interface.ts
File metadata and controls
53 lines (50 loc) · 1.44 KB
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
50
51
52
53
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' | 'pattern'
> {
isArray?: boolean;
name?: string;
pattern?: string | RegExp;
enum?: EnumAllowedTypes;
}
export type SchemaObjectMetadata =
| (SchemaObjectCommonMetadata & {
type?:
| Type<unknown>
| Function
| [Function]
| 'array'
| 'string'
| 'number'
| 'boolean'
| 'integer'
| 'file'
| '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);