-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Git ignore for schemas subtree Signed-off-by: Tom <[email protected]> * Squashed 'gbfs-validator/versions/schemas/' changes from 5273f96..22b058d 22b058d fix: incorrect spec for "languages" property in system_information.json (#90) e9d891b Refer to later versions in gbfs_versions.json (#87) fbd3ced Add v3.0 to v3.0-RC schemas (#88) ef0d9a6 Fix schemas for v3.0-RC (#85) 2b6ad1e FIX: replaces name field with localized string (#82) abe71f2 Fix invalid json, no trailing commas (#83) f43170e V3.0-RC Schemas (#79) 680df70 Update pr-to-project.yml c2c30a2 Typo fix in geofencing_zones.json (#78) c9be765 Create pr-to-project.yml 0a17875 Create issues-to-project.yml 30e5a3a Update README.md git-subtree-dir: gbfs-validator/versions/schemas git-subtree-split: 22b058dc4a358baf451e006cde74775075929b3d * remove dot files in schemas Signed-off-by: Tom <[email protected]> * v3-RC validation Signed-off-by: Tom <[email protected]> * Remove unused file Signed-off-by: Tom <[email protected]> * Add `serverOpts` required in Windows Signed-off-by: Tom <[email protected]> * Fix typo `recommended` Signed-off-by: Tom <[email protected]> * update test for 3.0-RC , 3.0 and upcoming minor versions Signed-off-by: Tom <[email protected]> * fix after rebase Signed-off-by: Tom <[email protected]> * Recommended. Signed-off-by: Tom <[email protected]> * Squashed 'gbfs-validator/versions/schemas/' changes from 22b058d..5f12243 5f12243 Patch manifest.json (#91) git-subtree-dir: gbfs-validator/versions/schemas git-subtree-split: 5f12243d5735a608eef697212a627b9090eea31a --------- Signed-off-by: Tom <[email protected]>
- Loading branch information
Showing
47 changed files
with
4,398 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,7 @@ coverage | |
functions/*.zip | ||
|
||
.env | ||
|
||
# schemas | ||
|
||
gbfs-validator/versions/schemas/.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
const fastify = require('fastify') | ||
|
||
const version = '3.0-RC' | ||
const last_updated = 1566224400 | ||
const last_updated_fresh = Math.floor(Date.now() / 1000) - 30 | ||
|
||
class MockRequests { | ||
entry_points() { | ||
return { | ||
manifest: this.manifest, | ||
gbfs: this.gbfs, | ||
gbfs_versions: this.gbfs_versions, | ||
system_information: this.system_information, | ||
vehicle_types: this.vehicle_types, | ||
station_status: this.station_status | ||
} | ||
} | ||
|
||
manifest({ basePath }) { | ||
return { | ||
last_updated, | ||
ttl: 0, | ||
version, | ||
data: { | ||
datasets: [ | ||
{ | ||
system_id: 'example_berlin', | ||
versions: [ | ||
{ | ||
version: '3.0-RC', | ||
url: `${basePath}/gbfs.json` | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
gbfs({ basePath }) { | ||
return { | ||
last_updated, | ||
ttl: 0, | ||
version, | ||
data: { | ||
feeds: [ | ||
{ | ||
name: 'system_information', | ||
url: `${basePath}/system_information.json` | ||
}, | ||
{ | ||
name: 'vehicle_types', | ||
url: `${basePath}/vehicle_types.json` | ||
}, | ||
{ | ||
name: 'vehicle_status', | ||
url: `${basePath}/vehicle_status.json` | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
gbfs_versions({ basePath }) { | ||
return { | ||
last_updated, | ||
ttl: 0, | ||
version, | ||
data: { | ||
versions: [ | ||
{ | ||
version: '3.0-RC', | ||
url: `${basePath}/gbfs.json` | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
system_information() { | ||
return { | ||
last_updated, | ||
ttl: 0, | ||
version, | ||
data: { | ||
system_id: 'shared_bike', | ||
languages: ['en'], | ||
name: [ | ||
{ | ||
text: 'Shared Bike USA', | ||
language: 'en' | ||
} | ||
], | ||
timezone: 'Etc/UTC', | ||
opening_hours: 'Mo-Su 00:00-23:59', | ||
feed_contact_email: '[email protected]' | ||
} | ||
} | ||
} | ||
|
||
vehicle_types() { | ||
return { | ||
last_updated, | ||
ttl: 0, | ||
version, | ||
data: { | ||
vehicle_types: [ | ||
{ | ||
vehicle_type_id: 'biketype1', | ||
form_factor: 'bicycle', | ||
propulsion_type: 'human', | ||
name: [ | ||
{ | ||
text: 'Example Basic Bike', | ||
language: 'en' | ||
} | ||
], | ||
default_reserve_time: 30, | ||
return_type: ['any_station', 'free_floating'], | ||
vehicle_assets: { | ||
icon_url: 'https://www.example.com/assets/icon_bicycle.svg', | ||
icon_url_dark: | ||
'https://www.example.com/assets/icon_bicycle_dark.svg', | ||
icon_last_modified: '2021-06-15' | ||
}, | ||
default_pricing_plan_id: 'bike_plan_1', | ||
pricing_plan_ids: ['bike_plan_1', 'bike_plan_2', 'bike_plan_3'] | ||
}, | ||
{ | ||
vehicle_type_id: 'cartype1', | ||
form_factor: 'car', | ||
propulsion_type: 'electric', | ||
name: [ | ||
{ | ||
text: 'Example Electric Car', | ||
language: 'en' | ||
} | ||
], | ||
default_reserve_time: 30, | ||
max_range_meters: 100, | ||
return_type: ['any_station', 'free_floating'], | ||
vehicle_assets: { | ||
icon_url: 'https://www.example.com/assets/icon_car.svg', | ||
icon_url_dark: 'https://www.example.com/assets/icon_car_dark.svg', | ||
icon_last_modified: '2021-06-15' | ||
}, | ||
default_pricing_plan_id: 'car_plan_1', | ||
pricing_plan_ids: ['car_plan_1', 'car_plan_2', 'car_plan_3'] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
vehicle_status() { | ||
return { | ||
last_updated: last_updated_fresh, | ||
ttl: 0, | ||
version, | ||
data: { | ||
vehicles: [ | ||
{ | ||
vehicle_id: 'bike1', | ||
last_reported: 1609866109, | ||
lat: 12.345678, | ||
lon: 56.789012, | ||
is_reserved: false, | ||
is_disabled: false, | ||
vehicle_type_id: 'biketype1' | ||
}, | ||
{ | ||
vehicle_id: 'car1', | ||
last_reported: 1609866109, | ||
lat: 12.345678, | ||
lon: 56.789012, | ||
is_reserved: false, | ||
is_disabled: false, | ||
vehicle_type_id: 'cartype1', | ||
current_range_meters: 10 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
build() { | ||
const app = fastify() | ||
|
||
const data = this.entry_points() | ||
|
||
const keys = Object.keys(data) | ||
|
||
for (const key of keys) { | ||
app.get(`/${key}.json`, async function(request) { | ||
const basePath = `http://${request.hostname}` | ||
|
||
return data[key]({ request, basePath }) | ||
}) | ||
} | ||
|
||
return app | ||
} | ||
} | ||
|
||
module.exports = { | ||
MockRequests | ||
} |
Oops, something went wrong.