Skip to content

Commit

Permalink
Merge pull request #172 from Divyesh000/json-client-administrator
Browse files Browse the repository at this point in the history
create JSON schemas for client and administrator
  • Loading branch information
creme332 authored May 18, 2024
2 parents c6ac3b5 + a0de758 commit 651f2e7
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 15 deletions.
23 changes: 23 additions & 0 deletions resources/schema/Administrator.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
}
30 changes: 30 additions & 0 deletions resources/schema/Client.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
}
34 changes: 27 additions & 7 deletions resources/schema/Comment.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
11 changes: 10 additions & 1 deletion resources/schema/Product.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
38 changes: 31 additions & 7 deletions resources/schema/Review.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
41 changes: 41 additions & 0 deletions resources/schema/User.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}

0 comments on commit 651f2e7

Please sign in to comment.