Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1-RC of the [JSON Schemas](https://github.com/MobilityData/gbfs-json-schema).
This project validates feeds up to version 3.1-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
2 changes: 1 addition & 1 deletion gbfs-validator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ npm install gbfs-validator
```

## Supported GBFS Versions
- 3.1-RC
- 3.1-RC2
- 3.0
- 2.3
- 2.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function build(opts = {}) {
return {
last_updated: "2024-05-23T15:30:00Z",
ttl: 0,
version: '3.1-RC',
version: '3.1-RC2',
data: {
feeds: [
{
Expand Down Expand Up @@ -36,7 +36,7 @@ function build(opts = {}) {
return {
last_updated: "2024-05-23T15:30:00Z",
ttl: 0,
version: '3.1-RC',
version: '3.1-RC2',
data: {
system_id: 'shared_bike',
name: [
Expand All @@ -57,7 +57,7 @@ function build(opts = {}) {
return {
last_updated: "2024-05-23T15:30:00Z",
ttl: 0,
version: '3.1-RC',
version: '3.1-RC2',
data: {
vehicle_types: [
{
Expand Down Expand Up @@ -135,7 +135,7 @@ function build(opts = {}) {
return {
last_updated: "2024-05-23T15:30:00Z",
ttl: 0,
version: '3.1-RC',
version: '3.1-RC2',
data: {
plans: [
{
Expand Down
78 changes: 39 additions & 39 deletions gbfs-validator/__test__/gbfs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ const pjson = require('../package.json')

const serverOpts = {
port: 0,
host: '127.0.0.1',
host: '127.0.0.1'
}

describe('initialization', () => {

beforeAll(() => {
// mocks process and pacakge.json for consistent tests
const originalProcess = process
global.process = {...originalProcess, versions: {node: '16.0.1'}}
global.process = { ...originalProcess, versions: { node: '16.0.1' } }
pjson.version = '1.1.1'
})

Expand Down Expand Up @@ -125,7 +124,7 @@ describe('checkAutodiscovery method', () => {
}/gbfs.json`
)

return gbfs.checkAutodiscovery().then(result => {
return gbfs.checkAutodiscovery().then((result) => {
expect(result).toMatchObject({
errors: false,
exists: true,
Expand All @@ -147,7 +146,7 @@ describe('checkAutodiscovery method', () => {
}/`
)

return gbfs.checkAutodiscovery().then(result => {
return gbfs.checkAutodiscovery().then((result) => {
expect(result).toMatchObject({
errors: false,
exists: true,
Expand All @@ -169,7 +168,7 @@ describe('checkAutodiscovery method', () => {
}/v2/`
)

return gbfs.checkAutodiscovery().then(result => {
return gbfs.checkAutodiscovery().then((result) => {
expect(result).toMatchObject({
errors: false,
exists: false,
Expand All @@ -192,7 +191,7 @@ describe('checkAutodiscovery method', () => {
{ version: '2.0' }
)

return gbfs.checkAutodiscovery().then(result => {
return gbfs.checkAutodiscovery().then((result) => {
expect(result).toMatchObject({
errors: false,
exists: false,
Expand Down Expand Up @@ -242,14 +241,14 @@ describe('getFile method', () => {
}
}

return gbfs.getFile('system_information', true).then(result => {
return gbfs.getFile('system_information', true).then((result) => {
expect(result).toMatchObject({
body: expect.any(Array),
required: true,
type: 'system_information'
})

result.body.forEach(l => {
result.body.forEach((l) => {
expect(l).toMatchObject({
exists: true,
lang: 'en',
Expand Down Expand Up @@ -278,14 +277,14 @@ describe('getFile method', () => {
}
}

return gbfs.getFile('do_not_exist', true).then(result => {
return gbfs.getFile('do_not_exist', true).then((result) => {
expect(result).toMatchObject({
body: expect.any(Array),
required: true,
type: 'do_not_exist'
})

result.body.forEach(l => {
result.body.forEach((l) => {
expect(l).toMatchObject({
body: null,
exists: false,
Expand All @@ -302,7 +301,7 @@ describe('getFile method', () => {
}`
const gbfs = new GBFS(`${url}`)

return gbfs.getFile('system_information', true).then(result => {
return gbfs.getFile('system_information', true).then((result) => {
expect(result).toMatchObject({
required: true,
exists: true,
Expand All @@ -318,7 +317,7 @@ describe('getFile method', () => {
}`
const gbfs = new GBFS(`${url}/gbfs.json`)

return gbfs.getFile('do_not_exist', true).then(result => {
return gbfs.getFile('do_not_exist', true).then((result) => {
expect(result).toMatchObject({
body: null,
required: true,
Expand Down Expand Up @@ -442,7 +441,7 @@ describe('validationFile method', () => {
hasErrors: false
})

result.languages.forEach(l => {
result.languages.forEach((l) => {
expect(l).toMatchObject({
body: expect.any(Object),
exists: true,
Expand Down Expand Up @@ -476,7 +475,7 @@ describe('validation method', () => {

expect.assertions(1)

return gbfs.validation().then(result => {
return gbfs.validation().then((result) => {
expect(result).toMatchObject({
summary: expect.objectContaining({
version: { detected: '2.2', validated: '2.2' },
Expand Down Expand Up @@ -512,7 +511,7 @@ describe('conditional vehicle_types file', () => {

expect.assertions(1)

return gbfs.validation().then(result => {
return gbfs.validation().then((result) => {
expect(result).toMatchObject({
summary: expect.objectContaining({
version: { detected: '2.2', validated: '2.2' }
Expand All @@ -529,15 +528,14 @@ describe('conditional vehicle_types file', () => {
})
})

describe('required default_reserve_time on reservation price existing v3.1-RC', () => {

describe('required default_reserve_time on reservation price existing v3.1-RC2', () => {
beforeAll(async () => {
gbfsFeedServer = require('./fixtures/conditional_default_reserve_time')()

await gbfsFeedServer.listen(serverOpts)

return gbfsFeedServer
});
})

afterAll(() => {
return gbfsFeedServer.close()
Expand All @@ -547,15 +545,14 @@ describe('required default_reserve_time on reservation price existing v3.1-RC',
const url = `http://${gbfsFeedServer.server.address().address}:${
gbfsFeedServer.server.address().port
}`
const gbfs = new GBFS(`${url}/gbfs.json`);
const gbfs = new GBFS(`${url}/gbfs.json`)

expect.assertions(1);
expect.assertions(1)

return gbfs.validation().then(result => {

return gbfs.validation().then((result) => {
expect(result).toMatchObject({
summary: expect.objectContaining({
version: { detected: '3.1-RC', validated: '3.1-RC' },
version: { detected: '3.1-RC2', validated: '3.1-RC2' },
hasErrors: true,
errorsCount: 3
}),
Expand Down Expand Up @@ -583,13 +580,15 @@ describe('required default_reserve_time on reservation price existing v3.1-RC',
expect.objectContaining(
{
instancePath: '/data/plans/3',
schemaPath: '#/properties/data/properties/plans/items/dependencies/reservation_price_flat_rate/not',
message: "must NOT be valid"
schemaPath:
'#/properties/data/properties/plans/items/dependencies/reservation_price_flat_rate/not',
message: 'must NOT be valid'
},
{
instancePath: '/data/plans/3',
schemaPath: '#/properties/data/properties/plans/items/dependencies/reservation_price_per_min/not',
message: "must NOT be valid"
schemaPath:
'#/properties/data/properties/plans/items/dependencies/reservation_price_per_min/not',
message: 'must NOT be valid'
}
)
])
Expand All @@ -600,8 +599,8 @@ describe('required default_reserve_time on reservation price existing v3.1-RC',
])
})
})
});
});
})
})

describe('conditional required vehicle_type_id', () => {
let gbfsFeedServer
Expand All @@ -626,7 +625,7 @@ describe('conditional required vehicle_type_id', () => {

expect.assertions(1)

return gbfs.validation().then(result => {
return gbfs.validation().then((result) => {
expect(result).toMatchObject({
summary: expect.objectContaining({
version: { detected: '2.2', validated: '2.2' },
Expand Down Expand Up @@ -682,7 +681,7 @@ describe('conditional no required vehicle_type_id', () => {

expect.assertions(1)

return gbfs.validation().then(result => {
return gbfs.validation().then((result) => {
expect(result).toMatchObject({
summary: expect.objectContaining({
version: { detected: '2.2', validated: '2.2' }
Expand All @@ -703,7 +702,8 @@ describe('conditional required vehicle_types_available', () => {
let gbfsFeedServer

beforeAll(async () => {
gbfsFeedServer = require('./fixtures/conditionnal_vehicle_types_available')()
gbfsFeedServer =
require('./fixtures/conditionnal_vehicle_types_available')()

await gbfsFeedServer.listen(serverOpts)

Expand All @@ -722,9 +722,9 @@ describe('conditional required vehicle_types_available', () => {

expect.assertions(1)

return gbfs.validation().then(result => {
const file = result.files.find(f => f.file === 'station_status.json')
const errors = file.languages.map(l => l.errors)
return gbfs.validation().then((result) => {
const file = result.files.find((f) => f.file === 'station_status.json')
const errors = file.languages.map((l) => l.errors)

expect(errors).toMatchObject([
[
Expand Down Expand Up @@ -766,9 +766,9 @@ describe('conditional plan_id', () => {

expect.assertions(1)

return gbfs.validation().then(result => {
const file = result.files.find(f => f.file === 'vehicle_types.json')
const errors = file.languages.map(l => l.errors)
return gbfs.validation().then((result) => {
const file = result.files.find((f) => f.file === 'vehicle_types.json')
const errors = file.languages.map((l) => l.errors)

expect(errors).toMatchObject([
[
Expand Down
2 changes: 1 addition & 1 deletion gbfs-validator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gbfs-validator",
"version": "1.0.13",
"version": "1.0.14",
"author": "MobilityData",
"main": "index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion gbfs-validator/versions/gbfs-json-schema
Submodule gbfs-json-schema updated 52 files
+4 −2 .github/workflows/build_deploy_java_language_bindings.yml
+0 −18 .github/workflows/issues-to-project.yml
+3 −1 .github/workflows/typescript_package_publish.yml
+597 −377 models/golang/v3.0/system_information/system_information.go
+1 −1 models/java/gbfs-java-model/pom.xml
+2 −0 models/typescript/.gitignore
+2 −1 models/typescript/README.md
+3 −2 models/typescript/index.d.ts
+27 −4 models/typescript/package.json
+128 −0 models/typescript/tests/v2.3.spec.ts
+15 −0 models/typescript/v2.3/index.d.ts
+1 −1 scripts/generate_typescript_models.sh
+24 −0 testFixtures/v2.3/free_bike_status.json
+59 −0 testFixtures/v2.3/gbfs.json
+13 −0 testFixtures/v2.3/gbfs_versions.json
+123 −0 testFixtures/v2.3/geofencing_zones.json
+27 −0 testFixtures/v2.3/station_information.json
+67 −0 testFixtures/v2.3/station_status.json
+23 −0 testFixtures/v2.3/system_alerts.json
+17 −0 testFixtures/v2.3/system_calendar.json
+27 −0 testFixtures/v2.3/system_hours.json
+22 −0 testFixtures/v2.3/system_information.json
+24 −0 testFixtures/v2.3/system_pricing_plans.json
+13 −0 testFixtures/v2.3/system_regions.json
+20 −0 testFixtures/v2.3/vehicle_types.json
+6 −0 v1.0/gbfs.json
+6 −0 v1.1/gbfs.json
+6 −0 v2.0/gbfs.json
+6 −0 v2.1/gbfs.json
+6 −0 v2.2/gbfs.json
+6 −0 v2.3/gbfs.json
+1 −1 v2.3/system_information.json
+3 −3 v2.3/vehicle_types.json
+6 −1 v3.0/gbfs.json
+1 −1 v3.0/system_information.json
+3 −3 v3.0/vehicle_types.json
+6 −1 v3.1-RC/gbfs.json
+1 −1 v3.1-RC/system_information.json
+3 −3 v3.1-RC/vehicle_types.json
+70 −0 v3.1-RC2/gbfs.json
+61 −0 v3.1-RC2/gbfs_versions.json
+202 −0 v3.1-RC2/geofencing_zones.json
+114 −0 v3.1-RC2/manifest.json
+282 −0 v3.1-RC2/station_information.json
+145 −0 v3.1-RC2/station_status.json
+161 −0 v3.1-RC2/system_alerts.json
+1,451 −0 v3.1-RC2/system_information.json
+222 −0 v3.1-RC2/system_pricing_plans.json
+68 −0 v3.1-RC2/system_regions.json
+92 −0 v3.1-RC2/vehicle_availability.json
+153 −0 v3.1-RC2/vehicle_status.json
+268 −0 v3.1-RC2/vehicle_types.json

This file was deleted.

Loading