Skip to content
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

Add conditional requirement #59

Closed
wants to merge 1 commit into from
Closed

Conversation

PierrickP
Copy link
Collaborator

@PierrickP PierrickP commented Nov 10, 2021

Summary

On free_bike_status.json

  • vehicle_type_id if has a vehicle_types.json
  • current_range_meters if the vehicle_type_id has not the human propulsion

Set vehicle_types.json required if free_bike_status.json has vehicle_type_id

issue #54

Updates (in todo)

I made a major change on the core.
Before, for each file we download the body then validate it individualy (with checkFile func).
Now, we download all files (getFile), then after validate it (validationFile). In this way, we can include conditionnal / additionnal validation.

Schemas with dynamic parts

I kept in mind to try keeping json schemas untouched. They are intended to be defined in a remote repository (https://github.com/MobilityData/gbfs-json-schema) and only linked into the validation.
Some conditional validations (like the current_range_meters requirement if the propulsion of the vehicle_type_id is not human) seems not possible on json-schema and generic for all feeds.
To be able to validated it, i "augment" (patch/merge) the json-schema with partials (see https://github.com/MobilityData/gbfs-validator/tree/conditionnal-requirement-54/gbfs-validator/schema/v2.2/partials) dynamically generated for the current feed.

On `free_bike_status.json`
+ `vehicle_type_id` if has a `vehicle_types.json`
+ `current_range_meters` if the vehicle_type_id has not the `human` propulsion

Set `vehicle_types.json` required if `free_bike_status.json` has `vehicle_type_id`

issue #54
@netlify
Copy link

netlify bot commented Nov 10, 2021

❌ Deploy Preview for competent-payne-690ca9 failed.

🔨 Explore the source changes: a0c3c1a

🔍 Inspect the deploy log: https://app.netlify.com/sites/competent-payne-690ca9/deploys/618bded48e6b140008d89b62

@netlify
Copy link

netlify bot commented Nov 10, 2021

❌ Deploy Preview for kind-pike-a3f3f8 failed.

🔨 Explore the source changes: a0c3c1a

🔍 Inspect the deploy log: https://app.netlify.com/sites/kind-pike-a3f3f8/deploys/618bded40afd260008246b50

@netlify
Copy link

netlify bot commented Nov 10, 2021

❌ Deploy Preview for wizardly-engelbart-5c48ca failed.

🔨 Explore the source changes: a0c3c1a

🔍 Inspect the deploy log: https://app.netlify.com/sites/wizardly-engelbart-5c48ca/deploys/618bded4ba9d810008c50f23

@netlify
Copy link

netlify bot commented Nov 10, 2021

✔️ Deploy Preview for unruffled-hugle-914373 ready!

🔨 Explore the source changes: a0c3c1a

🔍 Inspect the deploy log: https://app.netlify.com/sites/unruffled-hugle-914373/deploys/618bded41238240007b943fa

😎 Browse the preview: https://deploy-preview-59--unruffled-hugle-914373.netlify.app

@netlify
Copy link

netlify bot commented Nov 10, 2021

✔️ Deploy Preview for wizardly-lichterman-770f54 canceled.

🔨 Explore the source changes: a0c3c1a

🔍 Inspect the deploy log: https://app.netlify.com/sites/wizardly-lichterman-770f54/deploys/618bded4c57924000748eb58

@isabelle-dr
Copy link
Contributor

👋 @PierrickP. Thanks for working on this!

I had a look at what "Conditionally Required" fields/files in GBFS that aren't covered by the JSON Schema.
Not sure we can write custom rules for all of them but here you go:

  • default_pricing_plan_id in vehicle_types.json
  • vehicle_types_available in station_status.json
  • num_docks_available in station_status.json
  • vehicle_docks_availablein station_status.json
  • system_id in free_bike_status.json
  • lat in free_bike_status.json
  • lon in free_bike_status.json
  • vehicle_type_id in free_bike_status.json (mentioned in this PR already)
  • current_range_meters in free_bike_status.json (mentioned in this PR already)
  • the file vehicle_types.json (mentioned in this PR already)

@PierrickP
Copy link
Collaborator Author

closed for #63

@PierrickP PierrickP closed this Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write a custom rule to check conditional requirement of vehicle_types.json file presence
2 participants