This repository has been archived by the owner on Oct 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
67 lines (51 loc) · 1.5 KB
/
types.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import type { Literal } from "https://deno.land/x/[email protected]/schemable/schemable.ts";
/***************************************************************************************************
* @section Types
**************************************************************************************************/
type NonEmptyArray<T> = readonly [T, ...T[]];
export type Unknown = {};
export type Boolean = { type: "boolean" };
export type Null = { type: "null" };
export type Enum = { enum: NonEmptyArray<Literal> };
export type AllOf = { allOf: NonEmptyArray<Type> };
export type AnyOf = { anyOf: NonEmptyArray<Type> };
export type OneOf = { oneOf: NonEmptyArray<Type> };
export type Ref = { $ref: string };
export type Definitions = Record<string, Type>;
export type String = {
type: "string";
enum?: NonEmptyArray<string>;
minLength?: number;
maxLength?: number;
};
export type Number =
| { type: "integer"; enum?: NonEmptyArray<number> } // Integer
| { type: "number"; enum?: NonEmptyArray<number> }; // Float
// deno-lint-ignore ban-types
export type Object = {
type: "object";
properties: Record<string, Type>;
required?: NonEmptyArray<string>;
additionalProperties?: false | Type;
};
export type Array = {
type: "array";
items: Type | NonEmptyArray<Type>;
additionalItems?: Type;
};
export type Type =
& { definitions?: Definitions }
& (
| Unknown
| String
| Number
| Object
| Array
| Boolean
| Null
| Enum
| AllOf
| AnyOf
| OneOf
| Ref
);