Validation Output - 18F/usdot-jpo-ode-workzone-data-exchange GitHub Wiki
After data is posted to the validate endpoint, one will expect a JSON response.
The response will be a JSON object with the following items:
-
tables- a list oftableJSON objects -
valid- boolean to indicates whether the data is valid or not
-
table- a JSON object with the following items:-
headers- empty[], as this is irrelevant -
whole_table_errors- This is empty[], as this is irrelevant for now -
rows- a list ofrowJSON objects -
valid_row_count- an integer indicates the number of valid rows in the data -
invalid_row_count- an integer indicates the number of invalid rows in the data
-
-
row- a JSON object that indicates the errors each row has:-
row_number- a number to indicate the row. Since data will be coming in as an array, each object in the array will be considered as a row. Please note thatrow_numberstarts at 0. -
errors- a list oferrorJSON objects for this row -
data- a dictionary of key (field name) / value (data for that field) pairs
-
-
error- a JSON object that indicates the details of an error-
severity- severity of this error, right nowErrororWarning -
code- error code. See Error Codes for details -
message- error message that describe what the error is -
fields- a list of all the field names that are associated with this error. It is like an error path to indicate which piece of data triggered an error.
-
{
"tables": [
{
"headers": [],
"whole_table_errors": [],
"rows": [
{
"row_number": 0,
"errors": [
{
"severity": "Error",
"code": "type",
"message": "5220 is not of type 'string'",
"fields": [
"identifier"
]
},
{
"severity": "Error",
"code": "type",
"message": "None is not of type 'string'",
"fields": [
"totalLanes"
]
},
{
"severity": "Error",
"code": "enum",
"message": "None is not one of ['all', 'left-lane', 'right-lane', 'left-2-lanes', 'left-3-lanes', 'right-2-lanes', 'right-3-lanes', 'middle-lane', 'middle-two-lanes', 'right-turning-lane', 'left-turning-lane', 'right-exit-lane', 'left-exit-lane', 'right-merging-lane', 'left-merging-lane', 'right-exit-ramp', 'right-second-exit-ramp', 'right-entrance-ramp', 'right-second-entrance-ramp', 'left-exit-ramp', 'left-second-exit-ramp', 'left-entrance-ramp', 'left-second-entrance-ramp', 'sidewalk', 'bike-lane', 'none', 'unknown', 'alternating-flow-lane', 'left-shift-lanes', 'right-shift-lanes']",
"fields": [
"openLanes"
]
},
{
"severity": "Error",
"code": "enum",
"message": "None is not one of ['all', 'left-lane', 'right-lane', 'left-2-lanes', 'left-3-lanes', 'right-2-lanes', 'right-3-lanes', 'middle-lane', 'middle-two-lanes', 'right-turning-lane', 'left-turning-lane', 'right-exit-lane', 'left-exit-lane', 'right-merging-lane', 'left-merging-lane', 'right-exit-ramp', 'right-second-exit-ramp', 'right-entrance-ramp', 'right-second-entrance-ramp', 'left-exit-ramp', 'left-second-exit-ramp', 'left-entrance-ramp', 'left-second-entrance-ramp', 'sidewalk', 'bike-lane', 'none', 'unknown', 'alternating-flow-lane', 'left-shift-lanes', 'right-shift-lanes']",
"fields": [
"closedLanes"
]
},
{
"severity": "Error",
"code": "enum",
"message": "None is not one of ['outside', 'inside', 'both', 'none', 'unknown']",
"fields": [
"closedShoulders"
]
},
{
"severity": "Error",
"code": "type",
"message": "None is not of type 'boolean'",
"fields": [
"workersPresent"
]
},
{
"severity": "Error",
"code": "required",
"message": "'startDateTime' is a required property",
"fields": []
},
{
"severity": "Error",
"code": "required",
"message": "'endDateTime' is a required property",
"fields": []
},
{
"severity": "Error",
"code": "required",
"message": "'beginLocation' is a required property",
"fields": []
},
{
"severity": "Error",
"code": "required",
"message": "'endLocation' is a required property",
"fields": []
},
{
"severity": "Error",
"code": "additionalProperties",
"message": "Additional properties are not allowed ('RoadRestritions', 'wz-Status', 'timeStampUpdate', 'StartDateTime', 'timeStampCreation', 'EndLocation', 'BeginLocation', 'EndDateTime' were unexpected)",
"fields": []
}
],
"data": {
"identifier": 5220,
"StartDateTime": {
"startDateTime-est": "2017-06-12 16:30:00",
"startDateTime-ver": "2017-06-12 16:30:00",
"startDateTime-cancelled": null,
"timeConfidenceLevel": null
},
"EndDateTime": {
"endDateTime-est": "2021-12-31 17:00:00",
"endDateTime-ver": "2021-12-31 17:00:00",
"endDateTime-cancelled": null,
"timeConfidenceLevel": null
},
"BeginLocation": {
"roadName": "I-1175",
"roadNum": null,
"roadDirection": null,
"latitude-est": -44.350189,
"latitude-ver": -44.350189,
"longitude-est": 28.487378,
"longitude-ver": 28.487378,
"milepost-est": 45.0,
"milepost-ver": 45.0,
"crossStreet": null
},
"EndLocation": {
"roadName": "I-1175",
"roadNum": null,
"roadDirection": null,
"latitude-est": -44.350189,
"latitude-ver": -44.350189,
"longitude-est": 28.487378,
"longitude-ver": 28.487378,
"milepost-est": 54.0,
"milepost-ver": 54.0,
"crossStreet": null
},
"wz-Status": null,
"totalLanes": null,
"openLanes": null,
"closedLanes": null,
"closedShoulders": null,
"workersPresent": null,
"RoadRestritions": null,
"description": "Lanes blocked in both directions between mm 45 - 54 from 8am - 5pm each day for road widening work. Expect delays.",
"issuingOrganization": "CQT",
"timeStampCreation": "2017-06-12 16:54:00",
"timeStampUpdate": "2017-06-12 16:54:00"
}
}
],
"valid_row_count": 0,
"invalid_row_count": 1
}
],
"valid": false
}Error codes are based on the recommended Python JSON Schema Validator: https://github.com/Julian/jsonschema.
JSON Schema validator comes with its own set of error codes. The error code is the "validator" being used by the recommended Python JSONSchema Validation running the data against the specified schema in this project. The validation keywords will be used as the error code.
Based on the sample response above, here are the interpretations on the errors:
"severity": "Error"
"code": "type"
"message": "None is not of type '<data type>'"
- This happens to fields that are optional, and the data supplier decided to put in the fields but give them a value of
null - The validator interpreted that if the field is optional (in the given schema), it needs to not even exist in the data.
nullwould not be an option here.
"severity": "Error",
"code": "required",
"message": "'<field>' is a required property"
- This happens when field is misspelled mostly
- Use xsd as the truth to confirm spelling
"severity": "Error",
"code": "additionalProperties",
"message": "Additional properties are not allowed ('<field1>', '<field2>', ... were unexpected)"
- This happens when field is misspelled mostly
- Use xsd as the truth to confirm spelling
The response will be a JSON object to indicate the error.
i.e. This is to indicate incorrect JSON format when media type is JSON.
{
"detail": "JSON parse error - Expecting value: line 1 column 1 (char 0)"
}