-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit-analysis-schema.json
93 lines (88 loc) · 3.2 KB
/
unit-analysis-schema.json
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/erikerlandson/unit-analysis-json-schema/master/unit-analysis-schema.json",
"title": "Unit Analysis",
"description": "Defines a list of unit definitions to do unit analysis over",
"definitions": {
"unit_name": {
"type": "string",
"pattern": "^([a-z]|[A-Z])([a-z]|[A-Z]|[0-9])*$"
},
"base_unit": {
"type": "object",
"properties": {
"unit": { "const": "base" },
"name": { "$ref": "#/definitions/unit_name" },
"abbv": { "$ref": "#/definitions/unit_name" }
},
"required": ["unit", "name"]
},
"derived_unit": {
"type": "object",
"properties": {
"unit": { "const": "derived" },
"name": { "$ref": "#/definitions/unit_name" },
"abbv": { "$ref": "#/definitions/unit_name" },
"coef": { "$ref": "#/definitions/unit_coef" },
"expr": { "$ref": "#/definitions/unit_expr" }
},
"required": ["unit", "name", "coef", "expr"]
},
"unit_coef_rational": {
"type": "object",
"properties": {
"coef": { "const": "rational" },
"num": { "type": "integer", "exclusiveMinimum": 0 },
"den": { "type": "integer", "exclusiveMinimum": 0 }
},
"required": ["coef", "num", "den"]
},
"unit_coef": { "anyOf": [
{ "type" : "integer", "exclusiveMinimum": 0 },
{ "type" : "number", "exclusiveMinimum": 0.0 },
{ "$ref": "#/definitions/unit_coef_rational" }
]},
"unit_expr_mul": {
"type": "object",
"properties": {
"op": { "const": "*" },
"lhs": { "$ref": "#/definitions/unit_expr" },
"rhs": { "$ref": "#/definitions/unit_expr" }
},
"required": ["op", "lhs", "rhs"]
},
"unit_expr_div": {
"type": "object",
"properties": {
"op": { "const": "/" },
"lhs": { "$ref": "#/definitions/unit_expr" },
"rhs": { "$ref": "#/definitions/unit_expr" }
},
"required": ["op", "lhs", "rhs"]
},
"unit_expr_pow": {
"type": "object",
"properties": {
"op": { "const": "^" },
"lhs": { "$ref": "#/definitions/unit_expr" },
"rhs": { "type": "integer" }
},
"required": ["op", "lhs", "rhs"]
},
"unitless": { "const": "unitless" },
"unit_expr": { "anyOf": [
{ "$ref": "#/definitions/unitless" },
{ "$ref": "#/definitions/unit_name" },
{ "$ref": "#/definitions/unit_expr_mul" },
{ "$ref": "#/definitions/unit_expr_div" },
{ "$ref": "#/definitions/unit_expr_pow" }
]}
},
"type": "array",
"items": {
"anyOf": [
{ "$ref": "#/definitions/base_unit" },
{ "$ref": "#/definitions/derived_unit" }
]
}
}