-
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.
* added support for v3.1-RC * update package * snapshot tests updated
- Loading branch information
1 parent
203896f
commit 9e2e7a2
Showing
24 changed files
with
3,541 additions
and
2 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
225 changes: 225 additions & 0 deletions
225
gbfs-validator/__test__/fixtures/conditional_default_reserve_time.js
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,225 @@ | ||
const fastify = require('fastify') | ||
|
||
function build(opts = {}) { | ||
const app = fastify(opts) | ||
|
||
app.get('/gbfs.json', async function(request, reply) { | ||
return { | ||
last_updated: "2024-05-23T15:30:00Z", | ||
ttl: 0, | ||
version: '3.1-RC', | ||
data: { | ||
feeds: [ | ||
{ | ||
name: 'system_information', | ||
url: `http://${request.hostname}/system_information.json` | ||
}, | ||
{ | ||
name: 'station_information', | ||
url: `http://${request.hostname}/station_information.json` | ||
}, | ||
{ | ||
name: 'vehicle_types', | ||
url: `http://${request.hostname}/vehicle_types.json` | ||
}, | ||
{ | ||
name: 'system_pricing_plans', | ||
url: `http://${request.hostname}/system_pricing_plans.json` | ||
}, | ||
] | ||
|
||
} | ||
} | ||
}) | ||
|
||
app.get('/system_information.json', async function(request, reply) { | ||
return { | ||
last_updated: "2024-05-23T15:30:00Z", | ||
ttl: 0, | ||
version: '3.1-RC', | ||
data: { | ||
system_id: 'shared_bike', | ||
name: [ | ||
{ | ||
text: 'Shared Bike USA', | ||
language: 'en' | ||
} | ||
], | ||
timezone: 'Etc/UTC', | ||
opening_hours: "Mo-Fr 08:00-17:00", | ||
feed_contact_email: "[email protected]", | ||
languages: ["en"] | ||
} | ||
} | ||
}) | ||
|
||
app.get('/vehicle_types.json', async function(request, reply) { | ||
return { | ||
last_updated: "2024-05-23T15:30:00Z", | ||
ttl: 0, | ||
version: '3.1-RC', | ||
data: { | ||
vehicle_types: [ | ||
{ | ||
// default_reserve_time is required | ||
vehicle_type_id: 'abc123', | ||
form_factor: 'scooter', | ||
propulsion_type: 'human', | ||
name: [ | ||
{ | ||
text: 'Example Bicycle', | ||
language: 'en' | ||
} | ||
], | ||
//default_reserve_time: 30, // should throw error | ||
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: 'car_plan_2', | ||
pricing_plan_ids: ['car_plan_2', 'car_plan_1'] | ||
}, | ||
{ | ||
// default_reserve_time is required | ||
vehicle_type_id: 'efg456', | ||
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'] | ||
}, | ||
{ | ||
// default_reserve_time is NOT required | ||
vehicle_type_id: 'efg4567', | ||
form_factor: 'car', | ||
propulsion_type: 'electric', | ||
name: [ | ||
{ | ||
text: 'Example Electric Car 2', | ||
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_2', | ||
pricing_plan_ids: ['car_plan_2'] | ||
} | ||
] | ||
} | ||
} | ||
}) | ||
|
||
app.get('/system_pricing_plans.json', async function(request, reply) { | ||
return { | ||
last_updated: "2024-05-23T15:30:00Z", | ||
ttl: 0, | ||
version: '3.1-RC', | ||
data: { | ||
plans: [ | ||
{ | ||
plan_id: 'car_plan_1', | ||
name: [ | ||
{ | ||
text: 'Basic', | ||
language: 'en' | ||
} | ||
], | ||
currency: 'USD', | ||
price: 0, | ||
is_taxable: false, | ||
description: [ | ||
{ | ||
text: 'Basic plan', | ||
language: 'en' | ||
} | ||
], | ||
reservation_price_per_min: 3 | ||
}, | ||
{ | ||
plan_id: 'car_plan_2', | ||
name: [ | ||
{ | ||
text: 'Basic 2', | ||
language: 'en' | ||
} | ||
], | ||
currency: 'USD', | ||
price: 0, | ||
is_taxable: false, | ||
description: [ | ||
{ | ||
text: 'Basic plan', | ||
language: 'en' | ||
} | ||
], | ||
}, | ||
{ | ||
plan_id: 'car_plan_3', | ||
name: [ | ||
{ | ||
text: 'Basic 3', | ||
language: 'en' | ||
} | ||
], | ||
currency: 'USD', | ||
price: 0, | ||
is_taxable: false, | ||
description: [ | ||
{ | ||
text: 'Basic plan', | ||
language: 'en' | ||
} | ||
], | ||
reservation_price_flat_rate: 5 | ||
}, | ||
{ | ||
plan_id: 'car_plan_4', | ||
name: [ | ||
{ | ||
text: 'Basic 4', | ||
language: 'en' | ||
} | ||
], | ||
currency: 'USD', | ||
price: 0, | ||
is_taxable: false, | ||
description: [ | ||
{ | ||
text: 'Basic plan', | ||
language: 'en' | ||
} | ||
], | ||
reservation_price_flat_rate: 5, | ||
reservation_price_per_min: 3 // this should throw an error | ||
} | ||
] | ||
} | ||
} | ||
}) | ||
|
||
return app | ||
} | ||
|
||
module.exports = build |
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
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
47 changes: 47 additions & 0 deletions
47
gbfs-validator/versions/partials/v3.1-RC/station_status/required_vehicle_types_available.js
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,47 @@ | ||
module.exports = ({ vehicleTypes }) => { | ||
return { | ||
$id: 'required_vehicle_types_available.json#', | ||
$merge: { | ||
source: { | ||
$ref: | ||
'https://github.com/MobilityData/gbfs/blob/v3.1-RC/gbfs.md#station_statusjson' | ||
}, | ||
with: { | ||
properties: { | ||
data: { | ||
properties: { | ||
stations: { | ||
items: { | ||
properties: { | ||
vehicle_types_available: { | ||
items: { | ||
properties: { | ||
vehicle_type_id: { | ||
enum: vehicleTypes.map(vt => vt.vehicle_type_id) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
$patch: { | ||
source: { | ||
$ref: | ||
'https://github.com/MobilityData/gbfs/blob/v3.1-RC/gbfs.md#station_statusjson' | ||
}, | ||
with: [ | ||
{ | ||
op: 'add', | ||
path: '/properties/data/properties/stations/items/required/0', | ||
value: 'vehicle_types_available' | ||
} | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.