Giter Site home page Giter Site logo

Validating a 1.1 station_status.json doesn't flag presence of incorrect 'num_bikes_available_types' attribute. about gbfs-validator HOT 4 OPEN

mobilitydata avatar mobilitydata commented on June 12, 2024
Validating a 1.1 station_status.json doesn't flag presence of incorrect 'num_bikes_available_types' attribute.

from gbfs-validator.

Comments (4)

richtaylor-ito avatar richtaylor-ito commented on June 12, 2024

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.

from gbfs-validator.

isabelle-dr avatar isabelle-dr commented on June 12, 2024

Hi @richtaylor-ito, thanks for opening this issue!
It seems like this can be handled with additional properties.
Adding the following property in the Json Schemas will flag additional properties.

"additionalProperties": false

But this would flag the extensions outside the spec as well...
@PierrickP any thoughts on how to solve this problem?

from gbfs-validator.

isabelle-dr avatar isabelle-dr commented on June 12, 2024

After trying it with an online Json Schema Validator, using "additionalProperties": false works.
We would need to add it to all properties levels in order to flag additional fields in all levels of the JSON file.

Here is the modified station_status file that flags the additional field in Bcycle's feed:

station_status.json

{
  "$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"],
}

from gbfs-validator.

PierrickP avatar PierrickP commented on June 12, 2024

Hello additionalProperties should work and i think there are a tricks with a regex to only accept underscore prefixed key

from gbfs-validator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.