Project

General

Profile

« Previous | Next » 

Revision c72c8438

Added by koszko over 1 year ago

refactor some definitions into a separate file and add schemas for API endpoints

View differences:

api_mapping_description-1.schema.json
1
{
2
    "$schema": "http://json-schema.org/draft-07/schema#",
3
    "$id": "https://hydrilla.koszko.org/api_mapping_description-1.schema.json",
4
    "title": "Mapping description",
5
    "description": "Definition of a Hydrilla mapping, as served through HTTP API",
6
    "allOf": [{
7
	"$ref": "./common_definitions-1.schema.json#/definitions/mapping_definition_base"
8
    }, {
9
	"$ref": "./common_definitions-1.schema.json#/definitions/item_definition"
10
    }]
11
}
api_mapping_description-1.schema.json.license
1
SPDX-License-Identifier: CC0-1.0
2

  
3
Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
4

  
5
Available under the terms of Creative Commons Zero v1.0 Universal.
api_query_result-1.schema.json
1
{
2
    "$schema": "http://json-schema.org/draft-07/schema#",
3
    "$id": "https://hydrilla.koszko.org/api_query_result-1.schema.json",
4
    "title": "Query result",
5
    "description": "Object with a list of references to mappings that contain payloads for requested URL",
6
    "type": "object",
7
    "required": [
8
	"api_schema_version",
9
	"mappings"
10
    ],
11
    "properties": {
12
	"api_schema_version": {
13
	    "$ref": "./common_definitions-1.schema.json#/definitions/schema_version"
14
	},
15
	"mappings": {
16
	    "description": "References to mappings using at least one pattern that matches the requested URL",
17
	    "type": "array",
18
	    "items": {
19
		"$ref": "./common_definitions-1.schema.json#/definitions/item_ref"
20
	    }
21
	}
22
    }
23
}
api_query_result-1.schema.json.license
1
SPDX-License-Identifier: CC0-1.0
2

  
3
Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
4

  
5
Available under the terms of Creative Commons Zero v1.0 Universal.
api_resource_description-1.schema.json
1
{
2
    "$schema": "http://json-schema.org/draft-07/schema#",
3
    "$id": "https://hydrilla.koszko.org/api_resource_description-1.schema.json",
4
    "title": "Resource description",
5
    "description": "Definition of a Hydrilla resource, as served through HTTP API",
6
    "allOf": [{
7
	"$ref": "./common_definitions-1.schema.json#/definitions/resource_definition_base"
8
    }, {
9
	"$ref": "./common_definitions-1.schema.json#/definitions/item_definition"
10
    }, {
11
	"type": "object",
12
	"properties": {
13
	    "scripts": {
14
		"description": "Which files are resource's scripts and need to be installed",
15
		"$ref": "./common_definitions-1.schema.json#/definitions/file_ref_list_sha256",
16
		"default": []
17
	    }
18
	}
19
    }]
20
}
api_resource_description-1.schema.json.license
1
SPDX-License-Identifier: CC0-1.0
2

  
3
Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
4

  
5
Available under the terms of Creative Commons Zero v1.0 Universal.
api_source_description-1.schema.json
1
{
2
    "$schema": "http://json-schema.org/draft-07/schema#",
3
    "$id": "https://hydrilla.koszko.org/api_source_description-1.schema.json",
4
    "title": "Source description",
5
    "description": "Built description of a Hydrilla source package",
6
    "type": "object",
7
    "required": [
8
	"api_schema_version",
9
	"source_name",
10
	"source_copyright",
11
	"source_archives",
12
	"upstream_url",
13
	"definitions"
14
    ],
15
    "properties": {
16
	"api_schema_version": {
17
	    "$ref": "./common_definitions-1.schema.json#/definitions/schema_version"
18
	},
19
	"source_name": {
20
	    "$ref": "./common_definitions-1.schema.json#/definitions/source_name"
21
	},
22
	"source_copyright":  {
23
	    "description": "Which files indicate license terms of the source package",
24
	    "$ref": "./common_definitions-1.schema.json#/definitions/file_ref_list_sha256"
25
	},
26
	"source_archives": {
27
	    "description": "What archive extensions are available for this package's sources",
28
	    "type": "object",
29
	    "required": ["zip"],
30
	    "additionalProperties": {
31
		"description": "What is the SHA256 sum of given source archive",
32
		"type": "object",
33
		"required": ["sha256"],
34
		"properties": {
35
		    "sha256": {
36
			"$ref": "./common_definitions-1.schema.json#/definitions/sha256"
37
		    }
38
		}
39
	    },
40
	    "examples": [{
41
		"zip": {
42
		    "sha256": "688461da362ffe2fc8e85db73e709a5356d41c8aeb7d1eee7170c64ee21dd2a2"
43
		}
44
	    }]
45
	},
46
	"upstream_url": {
47
	    "description": "Where this software/work initially comes from",
48
	    "type": "string"
49
	},
50
	"comment": {
51
	    "$ref": "./common_definitions-1.schema.json#/definitions/comment"
52
	},
53
	"definitions": {
54
	    "description": "References to site resources and pattern->payload mappings",
55
	    "type": "array",
56
	    "items": {
57
		"$ref": "./common_definitions-1.schema.json#/definitions/typed_item_ref"
58
	    }
59
	}
60
    }
61
}
api_source_description-1.schema.json.license
1
SPDX-License-Identifier: CC0-1.0
2

  
3
Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
4

  
5
Available under the terms of Creative Commons Zero v1.0 Universal.
common_definitions-1.schema.json
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
}
common_definitions-1.schema.json.license
1
SPDX-License-Identifier: CC0-1.0
2

  
3
Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
4

  
5
Available under the terms of Creative Commons Zero v1.0 Universal.
package_source-1.schema.json
13 13
    ],
14 14
    "properties": {
15 15
	"source_schema_version": {
16
	    "description": "Which version of Hydrilla source package schema this definition conforms to",
17
	    "type": "array",
18
	    "minItems": 1,
19
	    "items": [{
20
		"const": 1
21
	    }],
22
	    "additionalItems": {
23
		"type": "integer",
24
		"minimum": 0
25
	    },
26
	    "minItems": 1
16
	    "$ref": "./common_definitions-1.schema.json#/definitions/schema_version"
27 17
	},
28 18
	"source_name": {
29
	    "description": "Unique identifier of this source package",
30
	    "type": "string",
31
	    "pattern": "^[-0-9a-z.]+$"
19
	    "$ref": "./common_definitions-1.schema.json#/definitions/source_name"
32 20
	},
33 21
	"copyright":  {
34 22
	    "description": "Which files from the source package indicate its license terms and should be included in the distribution packages",
35
	    "type": "array",
36
	    "items": {
37
		"$ref": "#/definitions/file_ref"
38
	    }
23
	    "$ref": "./common_definitions-1.schema.json#/definitions/file_ref_list"
39 24
	},
40 25
	"upstream_url": {
41 26
	    "description": "Where this software/work initially comes from",
42 27
	    "type": "string"
43 28
	},
44 29
	"comment": {
45
	    "$ref": "#/definitions/comment"
30
	    "$ref": "./common_definitions-1.schema.json#/definitions/comment"
46 31
	},
47 32
	"definitions": {
48 33
	    "description": "Definitions of site resources and pattern->payload mappings",
49 34
	    "type": "array",
50 35
	    "items": {
51
		"allOf": [{
52
		    "description": "Item definition (fields common to both resources and mappings)",
53
		    "type": "object",
54
		    "required": [
55
			"type",
56
			"identifier",
57
			"long_name",
58
			"uuid",
59
			"version",
60
			"description"
61
		    ],
62
		    "properties": {
63
			"type": {
64
			    "description": "What kind of item is being defined (resource or mapping)",
65
			    "enum": ["resource", "mapping"]
66
			},
67
			"identifier": {
68
			    "$ref": "#/definitions/item_identifier"
69
			},
70
			"long_name": {
71
			    "description": "User-friendly alternative to an identifier",
72
			    "type": "string"
73
			},
74
			"uuid": {
75
			    "description": "UUIDv4 of this item (shared with other versions of this item, otherwise unique)",
76
			    "type": "string",
77
			    "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
78
			},
79
			"version": {
80
			    "description": "Item's version number",
81
			    "type": "array",
82
			    "minItems": 1,
83
			    "items": {
84
				"type": "integer",
85
				"minimum": 0
86
			    },
87
			    "contains": {
88
				"type": "integer",
89
				"minimum": 1
90
			    },
91
			    "minItems": 1
92
			},
93
			"description": {
94
			    "description": "Item's description",
95
			    "type": "string"
96
			},
97
			"comment": {
98
			    "$ref": "#/definitions/comment"
99
			}
100
		    }
36
		"anyOf": [{
37
		    "$ref": "./common_definitions-1.schema.json#/definitions/resource_definition_base"
101 38
		}, {
102
		    "anyOf": [{
103
			"$ref": "#/definitions/resource_definition"
104
		    }, {
105
			"$ref": "#/definitions/mapping_definition"
106
		    }]
39
		    "$ref": "./common_definitions-1.schema.json#/definitions/mapping_definition_base"
107 40
		}]
108 41
	    }
109 42
	},
110 43
	"additional_files": {
111 44
	    "description": "Files which should be included in the source archive produced by Hydrilla builder in addition to script and copyright files",
112
	    "type": "array",
113
	    "items": {
114
		"$ref": "#/definitions/file_ref"
115
	    },
45
	    "$ref": "./common_definitions-1.schema.json#/definitions/file_ref_list",
116 46
	    "default": []
117 47
	},
118 48
	"reuse_generate_spdx_report": {
......
120 50
	    "type": "boolean",
121 51
	    "default": false
122 52
	}
123
    },
124
    "definitions": {
125
	"comment": {
126
	    "description": "An optional comment",
127
	    "type": "string"
128
	},
129
        "file_ref": {
130
	    "type": "object",
131
	    "required": ["file"],
132
	    "properties": {
133
		"file": {
134
		    "description": "Filename relative to source package main directory; separator is '/'",
135
		    "type": "string",
136
		    "pattern": "^[^/]"
137
		}
138
	    }
139
        },
140
	"item_identifier": {
141
	    "description": "Identifier of an item (shared with other versions of the item, otherwise unique)",
142
	    "type": "string",
143
	    "pattern": "^[-0-9a-z]+$"
144
	},
145
	"resource_definition": {
146
	    "description": "Resource definition (fields specific to resource)",
147
	    "type": "object",
148
	    "required": [
149
		"type",
150
		"revision"
151
	    ],
152
	    "properties": {
153
		"type": {
154
		    "description": "Identify this item as a resource",
155
		    "const": "resource"
156
		},
157
		"revision": {
158
		    "description": "Which revision of a packaging of given version of an upstream resource is this",
159
		    "type": "integer",
160
		    "minimum": 1
161
		},
162
		"scripts": {
163
		    "description": "Which files from the source package are scripts to be included in the resource",
164
		    "type": "array",
165
		    "items":{
166
			"$ref": "#/definitions/file_ref"
167
		    },
168
		    "default": []
169
		},
170
		"dependencies": {
171
		    "description": "What other resources this one depends on",
172
		    "type": "array",
173
		    "items": {
174
			"$ref": "#/definitions/item_identifier"
175
		    },
176
		    "default": []
177
		}
178
	    }
179
	},
180
	"mapping_definition": {
181
	    "description": "Mapping definition (fields specific to mapping)",
182
	    "type": "object",
183
	    "required": ["type"],
184
	    "properties": {
185
		"type": {
186
		    "description": "Identify this item as a mapping",
187
		    "const": "mapping"
188
		},
189
		"payloads": {
190
		    "description": "Which payloads are to be applied to which URLs",
191
		    "additionalProperties": {
192
			"description": "Which payload applies to URLs matching given pattern",
193
			"type": "object",
194
					    "required": ["identifier"],
195
			"properties": {
196
			    "identifier": {
197
				"$ref": "#/definitions/item_identifier"
198
			    }
199
			}
200
		    },
201
		    "default": {},
202
		    "examples": [{
203
			"https://hydrillabugs.koszko.org/***": {
204
			    "identifier": "helloapple"
205
			},
206
			"https://*.koszko.org/***": {
207
			    "identifier": "hello-potato"
208
			}
209
		    }]
210
		}
211
	    }
212
	}
213 53
    }
214 54
}

Also available in: Unified diff