-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update JSON Schema to handle optional fields #128
Comments
On the second point: I agree that the last field should be |
I think the major concern @hunterowens raises with point two is, having to update that regex every time there is a new point release is one more thing to remember to do. And it would be a bad thing to forget. Edit: hopefully the results of #129 will make this process a little less error-prone. |
Additional thing to fix is that |
Should |
That field is not in the list of required properties in the Trips schema: "trips": {
"$id": "#/properties/data/properties/trips",
"type": "array",
"title": "The Trips Schema",
"items": {
"$id": "#/properties/data/properties/trips/items",
"type": "object",
"title": "The Trip Schema",
"required": [
"provider_name",
"provider_id",
"device_id",
"vehicle_id",
"vehicle_type",
"propulsion_type",
"trip_id",
"trip_duration",
"trip_distance",
"route",
"accuracy",
"start_time",
"end_time"
],
}
} However that property does have a validation regex pattern that forces "parking_verification_url": {
"$id": "#/properties/data/properties/trips/items/properties/parking_verification_url",
"type": "string",
"description": "A URL to a photo (or other evidence) of proper vehicle parking",
"default": "",
"examples": [
"https://data.provider.co/parking_verify/1234.jpg"
],
"pattern": "^(https://.*)$"
} e.g. are you validating data that looks like: {
"etc": "other data",
"parking_verification_url": null
} or {
"etc": "other data",
"parking_verification_url": ""
} This might fail, since @ian-r-rose any insight here? |
The data I'm trying to validate is
|
Ok, that makes sense then. I think this SO post has a way to update the schema to handle null. I'll get that in a branch and we can try. This should also work for the |
@thekaveman I think your proposed solution looks good to me. Unless you want the |
It sounds like we're already seeing it in the wild right @hunterowens? So do we allow data like you pasted above, or should the spec say "optional fields must not be included when they do not have a value"? |
I submitted a PR with the fix to allow There is another fix in that PR related to the Schema, and I targeted a new branch |
@hunterowens was this fixed by #142? |
Yep. |
@hunterowens Question about the {
"links":
{
"next": "https://....",
"prev": null,
"first": null,
"last": null
}
} For the purposes of paging, this is really all we need... but it doesn't pass schema validation. I think we should probably allow an additional exception like in #142 for these |
Running list of JSON validator fixes
0.{version_number}.{anynumber}
regex forversion
to{anynumber}.{anynumber}.{anynumber}-{anystring_or_null}
to more close match semvarThe text was updated successfully, but these errors were encountered: