diff --git a/resources/schema/Administrator.json b/resources/schema/Administrator.json new file mode 100644 index 00000000..e95359e8 --- /dev/null +++ b/resources/schema/Administrator.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "allOf": [ + { + "$ref": "User.json#/definitions/user" + }, + { + "type": "object", + "properties": { + "job_title": { + "type": "string", + "minLength": 4 + }, + "is_super_admin": { + "type": "boolean" + } + }, + "required": [ + "job_title" + ] + } + ] +} diff --git a/resources/schema/Client.json b/resources/schema/Client.json new file mode 100644 index 00000000..842b1652 --- /dev/null +++ b/resources/schema/Client.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "allOf": [ + { + "$ref": "User.json#/definitions/user" + }, + { + "type": "object", + "properties": { + "street": { + "type": "string", + "minLength": 4 + }, + "city": { + "type": "string", + "minLength": 3 + }, + "district_id": { + "type": "integer", + "minimum": 1 + } + }, + "required": [ + "street", + "city", + "district_id" + ] + } + ] +} diff --git a/resources/schema/Comment.json b/resources/schema/Comment.json index 155d450f..a6ed716d 100644 --- a/resources/schema/Comment.json +++ b/resources/schema/Comment.json @@ -3,12 +3,32 @@ "title": "Comment", "type": "object", "properties": { - "comment_id": { "type": "integer" }, - "text": { "type": "string", "minLength": 1, "maxLength": 2000 }, - "created_date": { "type": "string", "format": "date-time" }, - "parent_comment_id": { "type": "integer" }, - "user_id": { "type": "integer" }, - "review_id": { "type": "integer" } + "comment_id": { + "type": "integer" + }, + "text": { + "type": "string", + "minLength": 1, + "maxLength": 2000 + }, + "created_date": { + "type": "string", + "format": "date-time" + }, + "parent_comment_id": { + "type": "integer" + }, + "user_id": { + "type": "integer" + }, + "review_id": { + "type": "integer" + } }, - "required": ["comment_id", "text", "created_date", "user_id"] + "required": [ + "comment_id", + "text", + "created_date", + "user_id" + ] } diff --git a/resources/schema/Product.json b/resources/schema/Product.json index d1b0bfde..3c6f3dff 100644 --- a/resources/schema/Product.json +++ b/resources/schema/Product.json @@ -48,7 +48,16 @@ "description": "The date and time when the product was created" } }, - "required": ["name", "calories", "img_url", "img_alt_text", "category", "price", "description", "created_date"], + "required": [ + "name", + "calories", + "img_url", + "img_alt_text", + "category", + "price", + "description", + "created_date" + ], "additionalProperties": false, "patternProperties": { "img_url": { diff --git a/resources/schema/Review.json b/resources/schema/Review.json index c5e2863a..04657aa2 100644 --- a/resources/schema/Review.json +++ b/resources/schema/Review.json @@ -3,12 +3,36 @@ "title": "Review", "type": "object", "properties": { - "review_id": { "type": "integer" }, - "rating": { "type": "integer", "minimum": 1, "maximum": 5 }, - "created_date": { "type": "string", "format": "date-time" }, - "text": { "type": "string", "minLength": 2, "maxLength": 2000 }, - "client_id": { "type": "integer" }, - "product_id": { "type": "integer" } + "review_id": { + "type": "integer" + }, + "rating": { + "type": "integer", + "minimum": 1, + "maximum": 5 + }, + "created_date": { + "type": "string", + "format": "date-time" + }, + "text": { + "type": "string", + "minLength": 2, + "maxLength": 2000 + }, + "client_id": { + "type": "integer" + }, + "product_id": { + "type": "integer" + } }, - "required": ["review_id", "rating", "created_date", "text", "client_id", "product_id"] + "required": [ + "review_id", + "rating", + "created_date", + "text", + "client_id", + "product_id" + ] } diff --git a/resources/schema/User.json b/resources/schema/User.json new file mode 100644 index 00000000..b1c3ac74 --- /dev/null +++ b/resources/schema/User.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "user": { + "type": "object", + "properties": { + "user_id": { + "type": "integer", + "minimum": 1 + }, + "email": { + "type": "string", + "format": "email" + }, + "first_name": { + "type": "string", + "minLength": 3 + }, + "password": { + "type": "string", + "minLength": 8 + }, + "phone_no": { + "type": "string", + "minLength": 7 + }, + "last_name": { + "type": "string", + "minLength": 3 + } + }, + "required": [ + "user_id", + "email", + "first_name", + "password", + "phone_no" + ] + } + } +} \ No newline at end of file