forked from TooeleTechSoftDev/PizzaTime-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
orderSchema.json
194 lines (194 loc) · 7.73 KB
/
orderSchema.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Individual Order schema",
"examples": [
{
"orderId": 234,
"accountId": 123,
"paymentTransactionId": 456,
"contact": {
"firstName": "Ms. Foobar",
"lastName": "O'Neil, the 3rd",
"phone": "(555) 555-5555"
},
"address": {
"street1": "",
"street2": "",
"city": "",
"state": "UT",
"zip": "55555-4444"
},
"orderItems": [
{
"productId": 789,
"orderType": "pizza",
"itemName": "Hawaiian",
"size": "Large",
"quantity": 1,
"pricePerItem": 12
},
{
"productId": 345,
"orderType": "drink",
"itemName": "Coke",
"size": "Small",
"quantity": 1,
"pricePerItem": 1.5
},
{
"productId": 654,
"orderType": "sides",
"itemName": "Breadsticks",
"quantity": 1,
"pricePerItem": 5.99
},
{
"productId": 567,
"orderType": "coupons",
"itemName": "July2019Promo",
"quantity": 1,
"pricePerItem": -3.0
},
{
"productId": 678,
"orderType": "fees",
"itemName": "Delivery Charge",
"quantity": 1,
"pricePerItem": 2.0
}
]
}
],
"type": "object",
"required": [ "orderId", "accountId", "paymentTransactionId", "contact", "orderItems"],
"additionalProperties": false,
"properties": {
"orderId": {
"type": "integer",
"description": "orderId must be an integer"
},
"accountId": {
"type": "integer",
"description": "accountId must be an integer"
},
"paymentTransactionId": {
"type": "integer",
"description": "paymentTransactionId must be an integer"
},
"contact": {
"type": "object",
"required": [ "firstName", "lastName", "phone" ],
"additionalProperties": false,
"properties": {
"firstName": {
"type": "string",
"maxLength": 30,
"pattern": "^[\\w \\.,']*$",
"description": "First name must be no more than 30 characters, may contain spaces, and can only contain alphanumerics or these symbols: _,.'"
},
"lastName": {
"type": "string",
"maxLength": 30,
"pattern": "^[\\w \\.,']*$",
"description": "Last name must be no more than 30 characters, may contain spaces, and can only contain alphanumerics or these symbols: _,.'"
},
"phone": {
"type": "string",
"maxLength": 15,
"pattern": "1?\\W*([2-9][0-8][0-9])\\W*([2-9][0-9]{2})\\W*([0-9]{4})(\\se?x?t?(\\d*))?",
"description": "Phone number must look like a North American number and include the area code"
},
"email": {
"type": "string",
"maxLength": 50,
"format": "email",
"description": "E-mail address must look valid, like [email protected]"
}
}
},
"address": {
"type": "object",
"required": [ "street1", "city", "state", "zip" ],
"additionalProperties": false,
"properties": {
"street1": {
"type": "string",
"maxLength": 50,
"pattern": "^[\\w \\.,']*$",
"description": "Street address must be no more than 50 characters and contain alphanumerics or these symbols: _.,'"
},
"street2": {
"type": "string",
"maxLength": 50,
"pattern": "^[\\w \\.,']*$",
"description": "Street address (line 2) must be no more than 50 characters and contain alphanumerics or these symbols: _.,'"
},
"city": {
"type": "string",
"maxLength": 50,
"pattern": "^[\\w \\.,']*$",
"description": "City must be no more than 50 characters, must start with an alphanumeric, and otherwise contain only alphanumerics or these symbols: _.'"
},
"state": {
"type": "string",
"maxLength": 20,
"pattern": "^[\\w \\.']*$",
"description": "State must be no more than 20 characters, must start with an alphanumeric, and otherwise contain only alphanumerics or these symbols: _.'"
},
"zip": {
"type": "string",
"maxLength": 15,
"pattern": "^(?!00000)(?<zip>(?<zip5>\\d{5})(?:[ -](?=\\d))?(?<zip4>\\d{4})?)$",
"description": "Zip code must look like a U.S. code, like 55555 or 55555-4444"
}
}
},
"orderItems": {
"type": "array",
"minItems": 1,
"maxItems": 1000,
"uniqueItems": true,
"items": {
"type": "object",
"required": [ "productId", "orderType", "itemName", "quantity", "pricePerItem"],
"additionalProperties": false,
"properties": {
"productId": {
"type": "integer",
"description": "productId must be an integer"
},
"orderType": {
"type": "string",
"maxLength": 50,
"pattern": "^[\\w \\.,']*$",
"description": "Order type must be no more than 50 characters and contain alphanumerics or these symbols: _.,'"
},
"itemName": {
"type": "string",
"maxLength": 50,
"pattern": "^[\\w \\.,']*$",
"description": "Item's name must be no more than 50 characters and contain alphanumerics or these symbols: _.,'"
},
"size": {
"type": "string",
"maxLength": 20,
"pattern": "^[\\w \\.,']*$",
"description": "Item's size must be no more than 20 characters and contain alphanumerics or these symbols: _.,'"
},
"quantity": {
"type": "integer",
"minimum": 1,
"maximum": 1000,
"description": "quantity must be an integer from 1 to 1000"
},
"pricePerItem": {
"type": "number",
"minimum": -1000,
"maximum": 1000,
"description": "pricePerItem must be a number between -1000 and +1000"
}
}
}
}
}
}