Project

General

Profile

Download (5.75 KB) Statistics
| Branch: | Tag: | Revision:

hydrilla-json-schemas / common_definitions-1.schema.json @ c72c8438

1
{
2
    "$schema": "http://json-schema.org/draft-07/schema#",
3
    "$id": "https://hydrilla.koszko.org/common_definitions-1.schema.json",
4
    "title": "Common definitions",
5
    "description": "Definitions used by other Hydrilla schemas",
6
    "definitions": {
7
	"version": {
8
	    "description": "Version expressed as an array of integers",
9
	    "type": "array",
10
	    "minItems": 1,
11
	    "items": {
12
		"type": "integer",
13
		"minimum": 0
14
	    },
15
	    "contains": {
16
		"type": "integer",
17
		"minimum": 1
18
	    },
19
	    "minItems": 1
20
	},
21
	"schema_version": {
22
	    "description": "Which version of appropriate schema a JSON document conforms to (major number is assumed to be 1)",
23
	    "allOf": [{
24
		"$ref": "#definitions/version"
25
	    }, {
26
		"type": "array",
27
		"items": [{
28
		    "const": 1
29
		}]
30
	    }]
31
	},
32
	"source_name": {
33
	    "description": "Unique identifier of this source package",
34
	    "type": "string",
35
	    "pattern": "^[-0-9a-z.]+$"
36
	},
37
	"comment": {
38
	    "description": "An optional comment",
39
	    "type": "string"
40
	},
41
        "file_ref_list": {
42
	    "description": "List of simple file references",
43
	    "type": "array",
44
	    "items": {
45
		"type": "object",
46
		"required": ["file"],
47
		"properties": {
48
		    "file": {
49
			"description": "Filename relative to source package main directory; separator is '/'",
50
			"type": "string",
51
			"pattern": "^[^/]"
52
		    }
53
		}
54
	    }
55
        },
56
	"sha256": {
57
	    "description": "An SHA256 sum, in hexadecimal",
58
	    "type": "string",
59
	    "pattern": "^[0-9a-f]{64}$"
60
	},
61
        "file_ref_list_sha256": {
62
	    "description": "List of file references with files' SHA256 sums included",
63
	    "allOf": [{
64
		"$ref": "#/definitions/file_ref_list"
65
	    }, {
66
		"type": "array",
67
		"items": {
68
		    "type": "object",
69
		    "required": ["sha256"],
70
		    "properties": {
71
			"sha256": {
72
			    "$ref": "#/definitions/sha256"
73
			}
74
		    }
75
		}
76
	    }]
77
        },
78
	"item_identifier": {
79
	    "description": "Identifier of an item (shared with other versions of the item, otherwise unique)",
80
	    "type": "string",
81
	    "pattern": "^[-0-9a-z]+$"
82
	},
83
	"item_ref": {
84
	    "description": "An object containing a subset of fields from full item definition",
85
	    "type": "object",
86
	    "required": ["identifier", "long_name", "version"],
87
	    "properties": {
88
		"identifier": {
89
		    "$ref": "#/definitions/item_identifier"
90
		},
91
		"long_name": {
92
		    "description": "User-friendly alternative to the identifier",
93
		    "type": "string"
94
		},
95
		"version": {
96
		    "$ref": "#definitions/version"
97
		}
98
	    }
99
	},
100
	"typed_item_ref": {
101
	    "description": "An object containing a subset of fields from full item definition, including type",
102
	    "allOf": [{
103
		"$ref": "#/definitions/item_ref"
104
	    }, {
105
		"type": "object",
106
		"required": ["type"],
107
		"properties": {
108
		    "type": {
109
			"description": "What kind of item is it (resource or mapping)",
110
			"enum": ["resource", "mapping"]
111
		    }
112
		}
113
	    }]
114
	},
115
	"item_definition_base": {
116
	    "description": "Definition of a resource/mapping (fields common to source definitions and built definitions)",
117
	    "allOf": [{
118
		"$ref": "#/definitions/typed_item_ref"
119
	    }, {
120
		"type": "object",
121
		"required": ["uuid", "description"],
122
		"properties": {
123
		    "uuid": {
124
			"description": "UUIDv4 of this item (shared with other versions of this item, otherwise unique)",
125
			"type": "string",
126
			"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
127
		    },
128
		    "description": {
129
			"description": "Item's description",
130
			"type": "string"
131
		    },
132
		    "comment": {
133
			"$ref": "#/definitions/comment"
134
		    }
135
		}
136
	    }]
137
	},
138
	"resource_definition_base": {
139
	    "description": "Definition of a resource (fields common to source definitions and built definitions)",
140
	    "allOf": [{
141
		"$ref": "#/definitions/item_definition_base"
142
	    }, {
143
		"type": "object",
144
		"required": ["type", "revision"],
145
		"properties": {
146
		    "type": {
147
			"description": "Identify this item as a resource",
148
			"const": "resource"
149
		    },
150
		    "revision": {
151
			"description": "Which revision of a packaging of given version of an upstream resource is this",
152
			"type": "integer",
153
			"minimum": 1
154
		    },
155
		    "scripts": {
156
			"description": "What scripts are included in the resource",
157
			"$ref": "#/definitions/file_ref_list",
158
			"default": []
159
		    }
160
		}
161
	    }]
162
	},
163
	"mapping_definition_base": {
164
	    "description": "Definition of a mapping (fields common to source definitions and built definitions)",
165
	    "allOf": [{
166
		"$ref": "#/definitions/item_definition_base"
167
	    }, {
168
		"type": "object",
169
		"required": ["type"],
170
		"properties": {
171
		    "type": {
172
			"description": "Identify this item as a mapping",
173
			"const": "mapping"
174
		    },
175
		    "payloads": {
176
			"description": "Which payloads are to be applied to which URLs",
177
			"additionalProperties": {
178
			    "description": "Which payload applies to URLs matching given pattern",
179
			    "type": "object",
180
			    "required": ["identifier"],
181
			    "properties": {
182
				"identifier": {
183
				    "$ref": "#/definitions/item_identifier"
184
				}
185
			    }
186
			},
187
			"default": {},
188
			"examples": [{
189
			    "https://hydrillabugs.koszko.org/***": {
190
				"identifier": "helloapple"
191
			    },
192
			    "https://*.koszko.org/***": {
193
				"identifier": "hello-potato"
194
			    }
195
			}]
196
		    }
197
		}
198
	    }]
199
	},
200
	"item_definition": {
201
	    "description": "Definition of a resource/mapping (fields specific to built definitions)",
202
	    "type": "object",
203
	    "required": [
204
		"api_schema_version",
205
		"source_name",
206
		"source_copyright"
207
	    ],
208
	    "properties": {
209
		"api_schema_version": {
210
		    "$ref": "#/definitions/schema_version"
211
		},
212
		"source_name": {
213
		    "$ref": "#/definitions/source_name"
214
		},
215
		"source_copyright": {
216
		    "description": "Which files indicate license terms of the source package and should be installed",
217
		    "$ref": "#/definitions/file_ref_list_sha256"
218
		}
219
	    }
220
	}
221
    }
222
}
(9-9/12)