-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprimitive-types.js
78 lines (77 loc) · 1.48 KB
/
primitive-types.js
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
68
69
70
71
72
73
74
75
76
77
78
// copied from: https://raw.githubusercontent.com/vipszx/protobuf-jsonschema/master/types.js
const MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
const MIN_SAFE_INTEGER = -MAX_SAFE_INTEGER;
module.exports = {
bytes: {
type: 'string',
'x-primitive': 'bytes',
},
string: {
type: 'string',
'x-primitive': 'string',
},
bool: {
type: 'boolean',
'x-primitive': 'bool',
},
int32: {
type: 'integer',
minimum: -0x80000000,
maximum: 0x7fffffff,
'x-primitive': 'int32',
},
sint32: {
type: 'integer',
minimum: -0x80000000,
maximum: 0x7fffffff,
'x-primitive': 'sint32',
},
uint32: {
type: 'integer',
minimum: 0,
maximum: 0xffffffff,
'x-primitive': 'uint32',
},
int64: {
type: 'integer',
minimum: MIN_SAFE_INTEGER,
maximum: MAX_SAFE_INTEGER,
'x-primitive': 'int64',
},
sint64: {
type: 'integer',
minimum: MIN_SAFE_INTEGER,
maximum: MAX_SAFE_INTEGER,
'x-primitive': 'sint64',
},
uint64: {
type: 'integer',
minimum: 0,
maximum: MAX_SAFE_INTEGER,
'x-primitive': 'uint64',
},
fixed32: {
type: 'number',
'x-primitive': 'fixed32',
},
fixed64: {
type: 'number',
'x-primitive': 'fixed64',
},
sfixed32: {
type: 'number',
'x-primitive': 'sfixed32',
},
sfixed64: {
type: 'number',
'x-primitive': 'sfixed64',
},
float: {
type: 'number',
'x-primitive': 'float',
},
double: {
type: 'number',
'x-primitive': 'double',
}
};