Skip to content

Commit 1b7b4a2

Browse files
author
Leo Hemsted
committed
separate definitions into separate files to allow reuse
see python-jsonschema/jsonschema#98 took boring generic things (eg uuid) into definitions.json, and also separated email and sms notification objects into respective files
1 parent aebaea1 commit 1b7b4a2

File tree

6 files changed

+243
-243
lines changed

6 files changed

+243
-243
lines changed
Lines changed: 3 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,15 @@
11
{
22
"$schema": "http://json-schema.org/draft-04/schema#",
3-
"description": "GET notification return schema - for SMS notifications",
3+
"description": "GET notification return schema - for email notifications",
44
"type" : "object",
55
"properties": {
66
"data": {
77
"type": "object",
88
"properties": {
9-
"notification": {
10-
"type": "object",
11-
"properties": {
12-
"id": {"$ref": "#/definitions/uuid"},
13-
"to": {"type": "string", "format": "email"},
14-
"job_row_number": {"oneOf":[
15-
{"type": "number"},
16-
{"type": "null"}
17-
]},
18-
"template_version": {"type": "number"},
19-
"billable_units": {"type": "number"},
20-
"notification_type": {
21-
"type": "string",
22-
"enum": ["email"]
23-
},
24-
"created_at": {"$ref": "#/definitions/datetime"},
25-
"sent_at": {"oneOf":[
26-
{"$ref": "#/definitions/datetime"},
27-
{"type": "null"}
28-
]},
29-
"sent_by": {"oneOf":[
30-
{"type": "string"},
31-
{"type": "null"}
32-
]},
33-
"updated_at": {"oneOf":[
34-
{"$ref": "#/definitions/datetime"},
35-
{"type": "null"}
36-
]},
37-
"status": {
38-
"type": "string",
39-
"enum": [
40-
"created",
41-
"sending",
42-
"delivered",
43-
"pending",
44-
"failed",
45-
"technical-failure",
46-
"temporary-failure",
47-
"permanent-failure"
48-
]
49-
},
50-
"reference": {"oneOf":[
51-
{"type": "string"},
52-
{"type": "null"}
53-
]},
54-
"template": {
55-
"type": "object",
56-
"properties": {
57-
"id": {"$ref": "#/definitions/uuid"},
58-
"name": {"type": "string"},
59-
"template_type": {
60-
"type": "string",
61-
"enum": ["email"]
62-
},
63-
"version": {"type": "number"}
64-
},
65-
"additionalProperties": false,
66-
"required": ["id", "name", "template_type", "version"]
67-
},
68-
"service": {"$ref": "#/definitions/uuid"},
69-
"job": {
70-
"oneOf": [
71-
{
72-
"type": "object",
73-
"properties": {
74-
"id": {"$ref": "#/definitions/uuid"},
75-
"original_file_name": {"type": "string"}
76-
},
77-
"additionalProperties": false,
78-
"required": ["id", "original_file_name"]
79-
},
80-
{"type": "null"}
81-
]
82-
},
83-
"api_key": {"oneOf":[
84-
{"$ref": "#/definitions/uuid"},
85-
{"type": "null"}
86-
]},
87-
"body": {"type": "string"},
88-
"content_char_count": {"type": "null"},
89-
"subject": {"type": "string"}
90-
},
91-
"additionalProperties": false,
92-
"required": [
93-
"id",
94-
"to",
95-
"job_row_number",
96-
"template_version",
97-
"billable_units",
98-
"notification_type",
99-
"created_at",
100-
"sent_at",
101-
"sent_by",
102-
"updated_at",
103-
"status",
104-
"reference",
105-
"template",
106-
"service",
107-
"job",
108-
"api_key",
109-
"body",
110-
"content_char_count"
111-
]
112-
}
9+
"notification": {"$ref": "email_notification.json"}
11310
},
11411
"additionalProperties": false
11512
}
11613
},
117-
"additionalProperties": false,
118-
"definitions": {
119-
"uuid": {
120-
"type": "string",
121-
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
122-
},
123-
"datetime": {
124-
"type": "string",
125-
"format": "date-time"
126-
}
127-
}
14+
"additionalProperties": false
12815
}
Lines changed: 3 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,15 @@
11
{
22
"$schema": "http://json-schema.org/draft-04/schema#",
3-
"description": "GET notification return schema - for SMS notifications",
3+
"description": "GET notification return schema - for sms notifications",
44
"type" : "object",
55
"properties": {
66
"data": {
77
"type": "object",
88
"properties": {
9-
"notification": {
10-
"type": "object",
11-
"properties": {
12-
"id": {"$ref": "#/definitions/uuid"},
13-
"to": {"type": "string"},
14-
"job_row_number": {"oneOf":[
15-
{"type": "number"},
16-
{"type": "null"}
17-
]},
18-
"template_version": {"type": "number"},
19-
"billable_units": {"type": "number"},
20-
"notification_type": {
21-
"type": "string",
22-
"enum": ["sms"]
23-
},
24-
"created_at": {"$ref": "#/definitions/datetime"},
25-
"sent_at": {"oneOf":[
26-
{"$ref": "#/definitions/datetime"},
27-
{"type": "null"}
28-
]},
29-
"sent_by": {"oneOf":[
30-
{"type": "string"},
31-
{"type": "null"}
32-
]},
33-
"updated_at": {"oneOf":[
34-
{"$ref": "#/definitions/datetime"},
35-
{"type": "null"}
36-
]},
37-
"status": {
38-
"type": "string",
39-
"enum": [
40-
"created",
41-
"sending",
42-
"delivered",
43-
"pending",
44-
"failed",
45-
"technical-failure",
46-
"temporary-failure",
47-
"permanent-failure"
48-
]
49-
},
50-
"reference": {"oneOf":[
51-
{"type": "string"},
52-
{"type": "null"}
53-
]},
54-
"template": {
55-
"type": "object",
56-
"properties": {
57-
"id": {"$ref": "#/definitions/uuid"},
58-
"name": {"type": "string"},
59-
"template_type": {
60-
"type": "string",
61-
"enum": ["sms"]
62-
},
63-
"version": {"type": "number"}
64-
},
65-
"additionalProperties": false,
66-
"required": ["id", "name", "template_type", "version"]
67-
},
68-
"service": {"$ref": "#/definitions/uuid"},
69-
"job": {
70-
"oneOf": [
71-
{
72-
"type": "object",
73-
"properties": {
74-
"id": {"$ref": "#/definitions/uuid"},
75-
"original_file_name": {"type": "string"}
76-
},
77-
"additionalProperties": false,
78-
"required": ["id", "original_file_name"]
79-
},
80-
{"type": "null"}
81-
]
82-
},
83-
"api_key": {"oneOf":[
84-
{"$ref": "#/definitions/uuid"},
85-
{"type": "null"}
86-
]},
87-
"body": {"type": "string"},
88-
"content_char_count": {"type": "number"}
89-
},
90-
"additionalProperties": false,
91-
"required": [
92-
"id",
93-
"to",
94-
"job_row_number",
95-
"template_version",
96-
"billable_units",
97-
"notification_type",
98-
"created_at",
99-
"sent_at",
100-
"sent_by",
101-
"updated_at",
102-
"status",
103-
"reference",
104-
"template",
105-
"service",
106-
"job",
107-
"api_key",
108-
"body",
109-
"content_char_count"
110-
]
111-
}
9+
"notification": {"$ref": "sms_notification.json"}
11210
},
11311
"additionalProperties": false
11412
}
11513
},
116-
"additionalProperties": false,
117-
"definitions": {
118-
"uuid": {
119-
"type": "string",
120-
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
121-
},
122-
"datetime": {
123-
"type": "string",
124-
"format": "date-time"
125-
}
126-
}
14+
"additionalProperties": false
12715
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"description": "Common definitions - usage example: {'$ref': 'definitions.json#/uuid'} (swap quotes for double quotes)",
4+
"uuid": {
5+
"type": "string",
6+
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
7+
},
8+
"datetime": {
9+
"type": "string",
10+
"format": "date-time"
11+
},
12+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
"email_notification": {
3+
"description": "Single email notification schema - as returned by GET /notification and GET /notification/{}",
4+
"type": "object",
5+
"properties": {
6+
"id": {"$ref": "definitions.json#/uuid"},
7+
"to": {"type": "string", "format": "email"},
8+
"job_row_number": {"oneOf":[
9+
{"type": "number"},
10+
{"type": "null"}
11+
]},
12+
"template_version": {"type": "number"},
13+
"billable_units": {"type": "number"},
14+
"notification_type": {
15+
"type": "string",
16+
"enum": ["email"]
17+
},
18+
"created_at": {"$ref": "definitions.json#/datetime"},
19+
"sent_at": {"oneOf":[
20+
{"$ref": "definitions.json#/datetime"},
21+
{"type": "null"}
22+
]},
23+
"sent_by": {"oneOf":[
24+
{"type": "string"},
25+
{"type": "null"}
26+
]},
27+
"updated_at": {"oneOf":[
28+
{"$ref": "definitions.json#/datetime"},
29+
{"type": "null"}
30+
]},
31+
"status": {
32+
"type": "string",
33+
"enum": [
34+
"created",
35+
"sending",
36+
"delivered",
37+
"pending",
38+
"failed",
39+
"technical-failure",
40+
"temporary-failure",
41+
"permanent-failure"
42+
]
43+
},
44+
"reference": {"oneOf":[
45+
{"type": "string"},
46+
{"type": "null"}
47+
]},
48+
"template": {
49+
"type": "object",
50+
"properties": {
51+
"id": {"$ref": "definitions.json#/uuid"},
52+
"name": {"type": "string"},
53+
"template_type": {
54+
"type": "string",
55+
"enum": ["email"]
56+
},
57+
"version": {"type": "number"}
58+
},
59+
"additionalProperties": false,
60+
"required": ["id", "name", "template_type", "version"]
61+
},
62+
"service": {"$ref": "definitions.json#/uuid"},
63+
"job": {
64+
"oneOf": [
65+
{
66+
"type": "object",
67+
"properties": {
68+
"id": {"$ref": "definitions.json#/uuid"},
69+
"original_file_name": {"type": "string"}
70+
},
71+
"additionalProperties": false,
72+
"required": ["id", "original_file_name"]
73+
},
74+
{"type": "null"}
75+
]
76+
},
77+
"api_key": {"oneOf":[
78+
{"$ref": "definitions.json#/uuid"},
79+
{"type": "null"}
80+
]},
81+
"body": {"type": "string"},
82+
"content_char_count": {"type": "null"},
83+
"subject": {"type": "string"}
84+
},
85+
"additionalProperties": false,
86+
"required": [
87+
"id",
88+
"to",
89+
"job_row_number",
90+
"template_version",
91+
"billable_units",
92+
"notification_type",
93+
"created_at",
94+
"sent_at",
95+
"sent_by",
96+
"updated_at",
97+
"status",
98+
"reference",
99+
"template",
100+
"service",
101+
"job",
102+
"api_key",
103+
"body",
104+
"content_char_count",
105+
"subject"
106+
]
107+
}
108+
}

0 commit comments

Comments
 (0)