MobilityData / gbfs-validator

The canonical GBFS validator. Maintained by the GBFS community, facilitated by MobilityData.
https://gbfs-validator.mobilitydata.org/
Apache License 2.0
18 stars 12 forks source link

Validating v1.0 feed gives "unimplemented version" error #48

Closed testower closed 3 years ago

testower commented 3 years ago

It seems like this is a bug that is caused by v1.0 feed not having a version field, since this field was introduced in v1.1. Even specifying v1.0 in the options gives the same error.

To reproduce

Try to validate the following feed: https://eu-feeds.joyridecity.bike/api/v1/zvipp/trondheim-2021/gbfs/gbfs.json

Update: I patched the validator locally so that feeds without a version would be validated as v1.0, and this seems to work:

@@ -144,7 +145,7 @@ class GBFS {
         this.autoDiscovery = body

         const errors = this.validateFile(
-          this.options.version || body.version,
+          this.options.version || body.version || '1.0',
           'gbfs',
           this.autoDiscovery
         )
@@ -152,7 +153,7 @@ class GBFS {
         return {
           errors,
           url: this.url,
-          version: body.version,
+          version: body.version || '1.0',
           recommanded: true,
           required: this.isGBFSFileRequire(
             this.options.version || body.version || '1.0'

This may or may not be the correct or optimal solution though.

On top of this, it seems like the schema for 1.0 incorrectly requires the "version" field, despite it not existing in 1.0:

https://github.com/MobilityData/gbfs-validator/blob/master/gbfs-validator/schema/v1.0/gbfs.json#L16 https://github.com/MobilityData/gbfs-validator/blob/master/gbfs-validator/schema/v1.0/gbfs.json#L49