Closed
Description
Schema
"responses": {
"200": {
"description": "",
"schema": {
"type": "object",
"properties": {
"booking_events": {
"$ref": "#/definitions/booking_event"
},
"event_creators": {
"$ref": "#/definitions/event_creator"
},
"venues": {
"$ref": "#/definitions/venue"
},
"booking_event_details": {
"$ref": "#/definitions/booking_event_details"
},
"booking_event_packages": {
"type": "array",
"items": {
"type": "object"
}
},
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <------------ this section
"downloads": {
"type": "array",
"items": {
"$ref": "#/definitions/download_file"
}
},
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
"highlights": {
"type": "array",
"items": {
"type": "string"
}
},
"to_brings": {
"type": "array",
"items": {
"type": "string"
}
},
"to_wears": {
"type": "array",
"items": {
"type": "string"
}
},
"pricings": {
"type": "object",
"properties": {
"low": {
"type": "boolean"
},
"high": {
"type": "boolean"
},
"total": {
"type": [
"integer",
"string"
]
}
}
}
}
}
},
"201": {
"$ref": "#/responses/trait:success:201"
},
"401": {
"$ref": "#/responses/trait:success:401"
}
}
........................................
"definitions": {
...........................
"download_file": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"owner_id": {
"type": "integer"
},
"active": {
"type": "integer"
},
"type": {
"type": "string"
},
"key": {
"type": "string"
},
"is_main": {
"type": "string"
},
"name": {
"type": "string"
},
"filename": {
"type": "string"
},
"created": {
"type": "string",
"pattern": "^(2[0-9]{3})-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]) (0[0-9]|1[0-9]|2[0123])\\:([012345][0-9])\\:([012345][0-9])$"
},
"modified": {
"type": "string",
"pattern": "^(2[0-9]{3})-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]) (0[0-9]|1[0-9]|2[0123])\\:([012345][0-9])\\:([012345][0-9])$"
},
"encrypted_key": {
"type": "string"
},
"filepath": {
"type": "string"
},
"path": {
"type": "string"
},
"url": {
"type": "string"
},
"exists": {
"type": "boolean"
},
"size": {
"type": "integer"
},
"size_string": {
"type": "string"
},
"extension": {
"type": "string"
}
}
},
.........................................
}
Response
{
"success": true,
...........................................................................
"booking_event_packages": [],
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <---------- this section
"downloads": [
{
"Doc": {
"id": "123",
"owner_id": "100",
"active": "1",
"type": "doc",
"key": "dg46bv1i36uekrjq",
"is_main": "0",
"name": "bookings endpoint",
"filename": "aus39y0rqvrzxsj8u423.txt",
"created": "2016-10-17 15:50:50",
"modified": "2016-10-17 15:50:50",
"encrypted_key": "S9vLirwnAZB2WoSuVsnfOksSJ96zUdI9EuN31zQ_t1M5dA_W8F4GWOUGDEwGLzSho74ZaSL_9KrpJWM5r1e5osFBlwOrYB6Vyin-F2X4qAVGY57oV8wEPitQ25dGckTt",
"filepath": "https:\/\/s3-ap-southeast-2.amazonaws.com\/emc-dev\/e0a64-docs\/100\/aus39y0rqvrzxsj8u423.txt",
"path": "s3:\/\/emc-dev\/e0a64-docs\/100\/aus39y0rqvrzxsj8u423.txt",
"url": "https:\/\/s3-ap-southeast-2.amazonaws.com\/emc-dev\/e0a64-docs\/100\/aus39y0rqvrzxsj8u423.txt",
"exists": false,
"size": 0,
"size_string": "0 bytes",
"extension": "txt"
}
}
],
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
"highlights": [
"one",
"two"
],
"to_brings": [
"hello",
"goodbye"
],
"to_wears": [
"apples",
"pears"
],
"pricings": {
"low": false,
"high": false,
"total": 0
}
}
This is the code to validate the above schema and response.
$validator = new Validator
$validator->reset();
$validator->check($jsonResponse, $expectedSchema);
$validator->isValid();
As you can see above, the download section's structure is definately different. In the schema, downloads have an array of object while the response have an object with key name Doc. Thus, I believe that json-schema library should detect this error. But it seems to only detect the data type errors.
How can I detect this type of error? or is this type of error impossible to detect in json-schema library?
Please give me a small clue to resolve this issue.
Thank you.
Metadata
Metadata
Assignees
Labels
No labels