Skip to content

Commit

Permalink
Add v3.0-RC2 support (#157)
Browse files Browse the repository at this point in the history
* Add v3.0-RC2 to the UI

* Add v3.0-RC2 JSON Schema

* Add v3.0-RC2 file requirements

* Update tests to v3.0-RC2

* Duplicate v3.0-RC partials for v3.0-RC2

* Copy v1.0 to v3.0-RC JSON Schemas

* Set latest GBFS version in RULES.md

* Rename variables r and res to partial
  • Loading branch information
richfab authored Nov 16, 2023
1 parent a5024e4 commit 6f6ddb5
Show file tree
Hide file tree
Showing 44 changed files with 3,260 additions and 84 deletions.
2 changes: 1 addition & 1 deletion RULES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This project validates feeds up to version 3.0-RC of the [JSON Schemas](https://github.com/MobilityData/gbfs-json-schema).
This project validates feeds up to version 3.0-RC2 of the [JSON Schemas](https://github.com/MobilityData/gbfs-json-schema).
# Files presence
The validator will flag any missing file. It will inform the user if the missing file is required or not, as per the conditions in the GBFS version that it detects.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const fastify = require('fastify')

const version = '3.0-RC'
const last_updated = 1566224400
const last_updated_fresh = Math.floor(Date.now() / 1000) - 30
const version = '3.0-RC2'
const last_updated = '2019-08-19T10:20:00-04:00'
const last_updated_fresh = new Date().toISOString()

class MockRequests {
entry_points() {
Expand All @@ -12,7 +12,8 @@ class MockRequests {
gbfs_versions: this.gbfs_versions,
system_information: this.system_information,
vehicle_types: this.vehicle_types,
station_status: this.station_status
station_status: this.station_status,
vehicle_status: this.vehicle_status
}
}

Expand All @@ -27,7 +28,7 @@ class MockRequests {
system_id: 'example_berlin',
versions: [
{
version: '3.0-RC',
version: '3.0-RC2',
url: `${basePath}/gbfs.json`
}
]
Expand Down Expand Up @@ -69,7 +70,7 @@ class MockRequests {
data: {
versions: [
{
version: '3.0-RC',
version: '3.0-RC2',
url: `${basePath}/gbfs.json`
}
]
Expand Down Expand Up @@ -161,7 +162,7 @@ class MockRequests {
vehicles: [
{
vehicle_id: 'bike1',
last_reported: 1609866109,
last_reported: last_updated,
lat: 12.345678,
lon: 56.789012,
is_reserved: false,
Expand All @@ -170,7 +171,7 @@ class MockRequests {
},
{
vehicle_id: 'car1',
last_reported: 1609866109,
last_reported: last_updated,
lat: 12.345678,
lon: 56.789012,
is_reserved: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const fastify = require('fastify')

const version = '3.0-RC'
const last_updated = 1566224400
const version = '3.0-RC2'
const last_updated = '2019-08-19T10:20:00-04:00'

const last_updated_fresh = Math.floor(Date.now() / 1000) - 30
const last_updated_fresh = new Date().toISOString()

class MockRequests {
entry_points() {
Expand Down Expand Up @@ -34,7 +34,7 @@ class MockRequests {
system_id: 'example_berlin',
versions: [
{
version: '3.0-RC',
version: '3.0-RC2',
url: `${basePath}/gbfs.json`
}
]
Expand Down Expand Up @@ -104,7 +104,7 @@ class MockRequests {
data: {
versions: [
{
version: '3.0-RC',
version: '3.0-RC2',
url: `${basePath}/gbfs.json`
}
]
Expand Down Expand Up @@ -227,7 +227,7 @@ class MockRequests {
cargo_volume_capacity: 50,
cargo_load_capacity: 100,
propulsion_type: 'electric',
eco_label: [
eco_labels: [
{
country_code: 'FR',
eco_sticker: 'critair_1'
Expand Down Expand Up @@ -330,23 +330,23 @@ class MockRequests {
parking_hoop: false,
contact_phone: '+33109874321',
capacity: 10,
vehicle_type_area_capacity: [
vehicle_types_capacity: [
{
vehicle_type_id: 'abc123',
vehicle_type_ids: ['abc123'],
count: 7
},
{
vehicle_type_id: 'def456',
vehicle_type_ids: ['def456'],
count: 3
}
],
vehicle_type_dock_capacity: [
vehicle_docks_capacity: [
{
vehicle_type_id: 'abc123',
vehicle_type_ids: ['abc123'],
count: 7
},
{
vehicle_type_id: 'def456',
vehicle_type_ids: ['def456'],
count: 3
}
],
Expand Down Expand Up @@ -376,7 +376,7 @@ class MockRequests {
is_installed: true,
is_renting: true,
is_returning: true,
last_reported: 1609866125,
last_reported: last_updated,
num_docks_available: 3,
num_docks_disabled: 1,
vehicle_docks_available: [
Expand Down Expand Up @@ -407,7 +407,7 @@ class MockRequests {
is_installed: true,
is_renting: true,
is_returning: true,
last_reported: 1609866106,
last_reported: last_updated,
num_docks_available: 8,
num_docks_disabled: 1,
vehicle_docks_available: [
Expand Down Expand Up @@ -459,7 +459,7 @@ class MockRequests {
web: 'https://www.example.com/app?sid=1234567890'
},
vehicle_type_id: 'biketype1',
last_reported: 1609866109
last_reported: last_updated
},
{
vehicle_id: 'car1',
Expand All @@ -468,7 +468,7 @@ class MockRequests {
is_reserved: false,
is_disabled: false,
vehicle_type_id: 'cartype1',
last_reported: 1609866109,
last_reported: last_updated,
current_range_meters: 10000,
current_fuel_percent: 0.5,
station_id: 'station1',
Expand Down Expand Up @@ -627,8 +627,8 @@ class MockRequests {
type: 'station_closure',
times: [
{
start: 1604448000,
end: 1604674800
start: last_updated,
end: last_updated_fresh
}
],
station_ids: ['123', '456', '789'],
Expand Down Expand Up @@ -658,7 +658,7 @@ class MockRequests {
language: 'en'
}
],
last_updated: 1604198100
last_updated
}
]
}
Expand Down Expand Up @@ -706,11 +706,11 @@ class MockRequests {
language: 'en'
}
],
start: 1593878400,
end: 1593907260,
start: last_updated,
end: last_updated_fresh,
rules: [
{
vehicle_type_id: ['moped1', 'car1'],
vehicle_type_ids: ['moped1', 'car1'],
ride_start_allowed: false,
ride_end_allowed: false,
ride_through_allowed: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('default feed', () => {
let gbfsFeedServer

beforeAll(async () => {
const { MockRequests } = require('./fixtures/v3.0-RC/default')
const { MockRequests } = require('./fixtures/v3.0-RC2/default')
let mockRequests = new MockRequests()

gbfsFeedServer = mockRequests.build()
Expand All @@ -50,7 +50,7 @@ describe('default feed', () => {
return gbfs.validation().then(result => {
expect(result).toMatchObject({
summary: expect.objectContaining({
version: { detected: '3.0-RC', validated: '3.0-RC' },
version: { detected: '3.0-RC2', validated: '3.0-RC2' },
validatorVersion: '1.0.0',
hasErrors: false
}),
Expand All @@ -64,7 +64,7 @@ describe('invalid feed', () => {
let gbfsFeedServer

beforeAll(async () => {
const { MockRequests } = require('./fixtures/v3.0-RC/default')
const { MockRequests } = require('./fixtures/v3.0-RC2/default')
class InvalidMockRequests extends MockRequests {
system_information(...args) {
const json = super.system_information(...args)
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('invalid feed', () => {
return gbfs.validation().then(result => {
expect(result).toMatchObject({
summary: expect.objectContaining({
version: { detected: '3.0-RC', validated: '3.0-RC' },
version: { detected: '3.0-RC2', validated: '3.0-RC2' },
validatorVersion: '1.0.0',
hasErrors: true,
errorsCount: 1
Expand All @@ -116,7 +116,7 @@ describe('exaustive feed', () => {
let gbfsFeedServer

beforeAll(async () => {
const { MockRequests } = require('./fixtures/v3.0-RC/exaustive')
const { MockRequests } = require('./fixtures/v3.0-RC2/exaustive')

let mockRequests = new MockRequests()

Expand All @@ -142,7 +142,7 @@ describe('exaustive feed', () => {

expect(result).toMatchObject({
summary: expect.objectContaining({
version: { detected: '3.0-RC', validated: '3.0-RC' },
version: { detected: '3.0-RC2', validated: '3.0-RC2' },
validatorVersion: '1.0.0',
hasErrors: false
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = ({ vehicleTypes }) => {
const res = {
const partial = {
$id: 'required_vehicle_type_id.json#'
}

Expand All @@ -8,7 +8,7 @@ module.exports = ({ vehicleTypes }) => {
)

if (motorVehicleTypes.length) {
res.$merge = {
partial.$merge = {
source: {
$ref:
'https://github.com/NABSA/gbfs/blob/v2.1/gbfs.md#free_bike_statusjson'
Expand Down Expand Up @@ -46,7 +46,7 @@ module.exports = ({ vehicleTypes }) => {
}
}

res.$patch = {
partial.$patch = {
source: {
$ref:
'https://github.com/NABSA/gbfs/blob/v2.1/gbfs.md#free_bike_statusjson'
Expand All @@ -60,5 +60,5 @@ module.exports = ({ vehicleTypes }) => {
]
}

return res
return partial
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = ({ android = false, ios = false }) => {
const r = {
const partial = {
$id: 'required_ios_store_uri.json#',
$patch: {
source: {
Expand Down Expand Up @@ -42,20 +42,20 @@ module.exports = ({ android = false, ios = false }) => {
}

if (ios) {
r.$merge.with.properties.data.properties.rental_apps.required.push('ios')
r.$merge.with.properties.data.properties.rental_apps.properties.ios.required.push(
partial.$merge.with.properties.data.properties.rental_apps.required.push('ios')
partial.$merge.with.properties.data.properties.rental_apps.properties.ios.required.push(
'store_uri'
)
}

if (android) {
r.$merge.with.properties.data.properties.rental_apps.required.push(
partial.$merge.with.properties.data.properties.rental_apps.required.push(
'android'
)
r.$merge.with.properties.data.properties.rental_apps.properties.android.required.push(
partial.$merge.with.properties.data.properties.rental_apps.properties.android.required.push(
'store_uri'
)
}

return r
return partial
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = ({ vehicleTypes }) => {
const res = {
const partial = {
$id: 'required_vehicle_type_id.json#'
}

Expand All @@ -8,7 +8,7 @@ module.exports = ({ vehicleTypes }) => {
)

if (motorVehicleTypes.length) {
res.$merge = {
partial.$merge = {
source: {
$ref:
'https://github.com/NABSA/gbfs/blob/v2.2/gbfs.md#free_bike_statusjson'
Expand Down Expand Up @@ -46,7 +46,7 @@ module.exports = ({ vehicleTypes }) => {
}
}

res.$patch = {
partial.$patch = {
source: {
$ref:
'https://github.com/NABSA/gbfs/blob/v2.2/gbfs.md#free_bike_statusjson'
Expand All @@ -60,5 +60,5 @@ module.exports = ({ vehicleTypes }) => {
]
}

return res
return partial
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = ({ android = false, ios = false }) => {
const r = {
const partial = {
$id: 'required_ios_store_uri.json#',
$patch: {
source: {
Expand Down Expand Up @@ -42,20 +42,20 @@ module.exports = ({ android = false, ios = false }) => {
}

if (ios) {
r.$merge.with.properties.data.properties.rental_apps.required.push('ios')
r.$merge.with.properties.data.properties.rental_apps.properties.ios.required.push(
partial.$merge.with.properties.data.properties.rental_apps.required.push('ios')
partial.$merge.with.properties.data.properties.rental_apps.properties.ios.required.push(
'store_uri'
)
}

if (android) {
r.$merge.with.properties.data.properties.rental_apps.required.push(
partial.$merge.with.properties.data.properties.rental_apps.required.push(
'android'
)
r.$merge.with.properties.data.properties.rental_apps.properties.android.required.push(
partial.$merge.with.properties.data.properties.rental_apps.properties.android.required.push(
'store_uri'
)
}

return r
return partial
}
Loading

0 comments on commit 6f6ddb5

Please sign in to comment.