-
Notifications
You must be signed in to change notification settings - Fork 12
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
Validating a 1.1 station_status.json doesn't flag presence of incorrect 'num_bikes_available_types' attribute. #50
Comments
While GBFS does allow for extensions outside of the spec, extensions should be prefixed with an underscore, which would make it possible to distinguish them from mis-named or mis-used attributes. |
Hi @richtaylor-ito, thanks for opening this issue! "additionalProperties": false But this would flag the extensions outside the spec as well... |
After trying it with an online Json Schema Validator, using Here is the modified {
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "https://github.com/NABSA/gbfs/blob/master/gbfs.md#station_statusjson",
"description":
"Describes the capacity and rental availablility of the station",
"type": "object",
"properties": {
"last_updated": {
"description":
"Last time the data in the feed was updated in POSIX time.",
"type": "integer",
"minimum": 1450155600
},
"ttl": {
"description":
"Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).",
"type": "integer",
"minimum": 0
},
"version": {
"description":
"GBFS version number to which the feed conforms, according to the versioning framework (added in v1.1).",
"type": "string",
"const": "1.1"
},
"data": {
"description":
"Array that contains one object per station as defined below.",
"type": "object",
"properties": {
"stations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"station_id": {
"description": "Identifier of a station.",
"type": "string"
},
"num_bikes_available": {
"description":
"Number of vehicles of any type physically available for rental at the station.",
"type": "number",
"minimum": 0
},
"num_bikes_disabled": {
"description":
"Number of disabled vehicles of any type at the station.",
"type": "number",
"minimum": 0
},
"num_docks_available": {
"description":
"Number of functional docks physically at the station.",
"type": "number",
"minimum": 0
},
"num_docks_disabled": {
"description":
"Number of empty but disabled docks at the station.",
"type": "number",
"minimum": 0
},
"is_installed": {
"description": "Is the station currently on the street?",
"type": "number",
"minimum": 0,
"maximum": 1
},
"is_renting": {
"description": "Is the station currently renting vehicles?",
"type": "number",
"minimum": 0,
"maximum": 1
},
"is_returning": {
"description": "Is the station accepting vehicle returns?",
"type": "number",
"minimum": 0,
"maximum": 1
},
"last_reported": {
"description":
"The last time this station reported its status to the operator's backend.",
"type": "number",
"minimum": 1450155600
}
},
"required": [
"station_id",
"num_bikes_available",
"num_docks_available",
"is_installed",
"is_renting",
"is_returning",
"last_reported"
],
"additionalProperties": false
}
}
},
"required": ["stations"],
}
},
"required": ["last_updated", "ttl", "version", "data"],
} |
Hello |
The spec"Field names of extensions SHOULD be prefixed with an underscore (_) character." (reference) Expected outcome:The validator should return a WARNING when an additional property does not start with an underscore (_). Potential solution described above by PierrickP:
JSON Schema example with station_status.json
|
When validating a v1.1 station_status.json which uses 'num_bike_available_types' in place of 'vehicles_types_available' (as per the 1.1 schema), the validator doesn't flag this.
An example of this can be seen in Bcycle's feed https://gbfs.bcycle.com/bcycle_lametro/gbfs.json :
{ is_returning: 1, is_renting: 1, is_installed: 1, num_docks_available: 23, num_bikes_available: 8, last_reported: 1635497046, num_bikes_available_types: { electric: 4, smart: 0, classic: 4 }, station_id: "bcycle_lametro_3005" }
The text was updated successfully, but these errors were encountered: