Skip to content

Conversation

@DanielKerger
Copy link
Contributor

This Pull Request introduces a rewrite of the GBFS Go implementation, designed to provide full support for GBFS v2.3 and v3.0, v3.1RC, and v3.1RC2 specifications. The previous codebase has been completely replaced due to incompatibilities with current GBFS standards and insufficient type safety across different Feeds and specification versions.

Major Update: This rewrite adds complete support for GBFS v2.3, GBFS v3.1RC, and GBFS v3.1RC2, which were previously missing from the Go implementation, while maintaining compatibility with v3.0.

Key Motivations for the Rewrite:

  • The previous implementation lacked support for GBFS v2.3, which is widely used in production environments
  • The previous implemementation lacked support for GBFS v3.1RC and v3.1RC2, which are the latest versions of the GBFS specification
  • Redeclaration of identical types across different feeds. E.g. type Version string was declared in all Feeds, leading to redundancy and potential inconsistencies.
  • Codebase was not easy to use due to the lack of shared types and enums.
  • The codebase was not easily extensible for future GBFS versions
  • Non working examples.
  • Errors in the test implementation and data.

This rewrite establishes a solid foundation for GBFS processing in Go, with improved type safety, better maintainability, complete v2.3, v3.0, and v3.1RC, v3.1RC2 specification coverage, and a clear path for supporting future specification updates.

My changes include:

  • Complete GBFS v2.3, v3.0, v3.1RC, and v3.1RC2 Implementation: Added full support for GBFS v2.3, v3.0, v3.1RC, and v3.1RC2 specifications, including all feeds and data structures that were previously missing from the Go implementation
  • Multi-Version Support: Designed the architecture to seamlessly handle both v2.3, v3.0, v3.1RC, and v3.1RC2 specifications within a single, unified codebase
  • Shared Types: I have introduced shared types for common fields across v2.3, v3.0, v3.1RC, and v3.1RC2, ensuring consistency and reducing redundancy. Previously, the code had separate types for each version, leading to duplication and inconsistencies across the codebase.
  • Shared Enums: Enums that are common to both v2.3, v3.0, v3.1RC, and v3.1RC2 have been consolidated into shared enums, allowing for easier maintenance and updates. As for the shared types, the previous code had separate enums for each version, which made it difficult to manage changes and updates.
  • Updated Tests and Test Fixtures: The tests have been updated to reflect the new structure and functionality of the code, with test coverage for v2.3, v3.0, v3.1RC, and v3.1RC2 specifications. Test fixtures have been updated to include full examples with all fields (previously, some fields were missing as they are optional in the GBFS specification). This ensures that the tests cover all aspects of the GBFS feeds and validate the functionality of the new implementation and shared types. As this led to file changes outside of the direct Go code, I have also updated and extended the tests for TypeScript to ensure that the TypeScript code is still compatible with the new Go code. Tests for the Java and Rust implementations did not require changes, as they use test files directly from their own codebase.
  • Abstract Unmarshal Function: In the previous implementation, the unmarshal function was tightly coupled with specific feed types, making it difficult to handle different versions and types of feeds. The new implementation relies on the generic json unmarshalling capabilities of Go, allowing for more flexible and type-safe unmarshalling of GBFS feeds. This change simplifies the code and makes it easier to extend for future versions of GBFS.
  • New GBFS Example: A new example has been added to demonstrate the usage of the GBFS implementation with a sample feed. This example shows how to use it to unmarshal a GBFS feed and access its fields, providing a clear reference for developers on how to work with the new code.
  • Improved Documentation: Enhanced inline documentation and comments throughout the codebase to better explain the implementation details and usage patterns.

Breaking Changes: This is a breaking change that requires updating any existing code that depends on the previous GBFS Go implementation. However, this rewrite now provides GBFS v2.3, v3.1RC, and v3.1RC2 support that was entirely missing before, making it a significant upgrade for production use.

…re files with values respecting the minimum allowed timestamp for this field. No logic changes or new functionality introduced.
…ew station information and vehicle status data for typescript
- Added new vehicle_status and vehicle_types models based on v3.0.
- Updated test fixtures for gbfs.json, gbfs_versions.json, geofencing_zones.json, manifest.json, and system_information.json to reflect changes in versioning and TTL.
- Introduced new test fixtures for vehicle availability, vehicle status for carsharing and micromobility, and updated pricing plans.
- Removed deprecated system_pricing_plans.json and adjusted vehicle_status.json to align with new structure.
- Updated all relevant JSON files to use version "3.1-RC2" and adjusted TTL values accordingly.
…chemas to allow all dateTimes that are iso 8601 comlient

^
(\d{4}(-\d{2}(-\d{2})?)?|\d{8})         # Date: YYYY or YYYY-MM or YYYY-MM-DD or YYYYMMDD
T
(
  (\d{2}:\d{2}(:\d{2}(\.\d+)?)?) |      # Extended time: hh:mm, hh:mm:ss, hh:mm:ss.sss
  (\d{2}:\d{2}(\.\d+)?) |               # Extended time: hh:mm.mmm
  (\d{2}(\.\d+)?) |                     # Extended time: hh.hhh
  (\d{2}(\d{2}(\d{2}(\.\d+)?)?)?)       # Basic time: hhmm, hhmmss, hhmmss.sss
)
(Z|[+-]\d{2}(:?\d{2})?)?                # Optional timezone: Z or ±hh:mm or ±hhmm
$
- Changed version from 3.1-RC2 to 3.1-RC across multiple JSON files.
- Adjusted TTL values in various files, setting some to 0 and others to specific values.
- Updated geofencing zones to set ride_through_allowed to false for specific zones.
- Added new files for version 3.1-RC2, including gbfs.json, gbfs_versions.json, geofencing_zones.json, manifest.json, and others.
- Introduced new station information files for physical and virtual stations with detailed attributes.
- Added vehicle availability and status files for carsharing and micromobility vehicles.
- Included comprehensive vehicle types with detailed specifications and assets.
- Deleted obsolete test file for GBFS v3.1-RC1.
- Created new test file for GBFS v3.1-RC2 with updated schema paths and test functions.
- Updated station_information model to include city field and data structure.
- Removed unused fields from system_pricing_plans model.
- Updated vehicle_types model to reference v3.0 vehicle_types.
- Added new models for GBFS v3.1-RC2 including gbfs, gbfs_versions, geofencing_zones, manifest, station_status, system_alerts, system_information, system_pricing_plans, system_regions, vehicle_availability, vehicle_status, and vehicle_types.
- Ensured all new models inherit from their respective v3.1-RC counterparts.
…ions

- Removed redundant schema loading and validation functions from gbfsv30_test.go, gbfsv31-RC.go, and gbfsv31-RC2.go.
- Replaced calls to specific load and validate functions with a unified approach across all test files.
- Improved code readability and maintainability by reducing duplication in test implementations.
@richfab richfab requested review from Alessandro100 and davidgamez and removed request for davidgamez August 4, 2025 13:26
@richfab
Copy link
Contributor

richfab commented Aug 4, 2025

Hello @DanielKerger,

Thank you very much for this significant open source contribution 🙏

cc @davidgamez @emmambd for the next steps.

Thanks,
Fabien (MobilityData)

@richfab richfab requested a review from emmambd August 4, 2025 13:31
@davidgamez
Copy link
Member

Hi @DanielKerger,

Thanks for this contribution! 🚀 This is a large PR with many changes, and since our team has limited capacity at the moment, it may take us some time to review it thoroughly. We want to ensure that we give it the attention it deserves, so we appreciate your patience while we review it.

@DanielKerger
Copy link
Contributor Author

Hi @davidgamez,
I just wanted to ask if there is an update on the review of the PR or if you have a timeline for it.

Kind regards,

Daniel

@davidgamez
Copy link
Member

Thanks for this contribution! 🚀 This is a large PR with many changes, and since our team has limited capacity at the moment, it may take us some time to review it thoroughly. We want to ensure that we give it the attention it deserves, so we appreciate your patience while we review it.

Thanks for checking in! We don’t have a specific timeline yet for the review, but it’s still on our radar. As mentioned, it’s a large PR and we want to make sure we review it carefully when we can allocate proper time. We really appreciate your patience and contribution! 🙏

@Alessandro100
Copy link
Contributor

Hi @DanielKerger, thanks for taking the time to contribute and help improve the GBFS tools. I really like the updated test fixtures and the added support for v3.1-RC2.

I also appreciate the way the code is structured — it’s clean and easy to follow. However, I’m a bit concerned about the implications of including future GBFS versions directly in Go and the maintenance effort that might entail.

For this PR, did you use any tools or scripts to facilitate your work? That could make upgrading to future versions easier.

My main hesitations with this PR are:

  1. It may be more difficult to upgrade versions compared to using generate_go_models.sh.
  2. It introduces breaking changes.
  3. It modifies schema models (e.g., vehicle_status, vehicle_availability).

Thanks again for your work on this — I’m open to discussing how we could keep the improvements while minimizing upgrade friction.

@DanielKerger
Copy link
Contributor Author

Hi @Alessandro100,

thank you for taking the time to review the PR. Regarding your concerns about maintaining the Go library for future versions, I would offer to maintain the library myself for at least the next two to three years. I could also write a detailed guide on how to maintain the library so that anyone interested can easily pick it up.

Regarding your question about the tools used: I used only an IDE with LLM assistance (VSCode with GitHub Copilot). The changes were made manually based on the changes in the JSON schemas. No additional tools were used to generate the code.

To address your main hesitations:

  • Yes, releasing a new major version does require slightly more effort than before. However, implementing minor versions (such as 3.1) is relatively quick, as demonstrated by the implementation of RC-2.

  • This update introduces several breaking changes affecting the library’s usage. I would suggest a two-release approach:

    • Continue to support the current major version of the Go library using the generate_go_models.sh script.
    • Release a new major version to indicate that it includes breaking changes in the Go library. It’s not feasible to make these changes backward-compatible (as a minor version release), as nearly all types have been modified.
    • In addition it is worth remembering that the old version of the library will still be available for users who need it regardless of the taken release strategy. Therefore, users can choose to stick with the older version if it fits their needs better and do not want to upgrade to the new major version.
  • Regarding the modifications to the JSON schemas, a decision needs to be made. According to the GBFS Specification, the fields vehicles[].availabilities[].from, vehicles[].availabilities[].until, and vehicles[].available_until all use the Datetime type as defined here.
    The Datetime type follows the ISO 8601 standard, whereas Timestamps use the RFC 3339 format. While these two standards share a common subset, each also includes representations unique to itself. This overview provides a clear comparison.

    The date-time format supported by JSON Schema is compliant with RFC 3339, as noted here. Therefore, the date-time format cannot be used in the schema if ISO 8601 compliance is required and therefore not for vehicles[].availabilities[].from, vehicles[].availabilities[].until, and vehicles[].available_until. This likely explains why vehicles[].available_until already uses a regular expression rather than the date-time format. My change to the schema only improved the compliance of the regex patterns with ISO 8601.

Thank you again for your feedback. Please let me know if you have any further questions or concerns.

Daniel

@Alessandro100
Copy link
Contributor

First off, thank you so much for your hard work on this PR and the improvements you made, we really appreciate the time and thought you put into it.

After discussing with the team, we’ve decided that we won’t be maintaining a manually generated set of GBFS Go language types. While we truly appreciate your offer to maintain and document this work, we need to ensure that key maintenance tasks can be handled by our core team. In our experience, external contributors often have other priorities and commitments that may arise over time, which is completely understandable

That said, there are several aspects of your PR we’d like to highlight and build on:

  1. Test fixture enhancements: these would bring real value and would make an excellent separate PR.
  2. You were correct to point out those issues in the schema regarding Datetime formatting. Having a separate PR addressing those schema changes would be of high value

I’d also love to learn more about your experience with the working examples and tests. Feel free to create an issue, come to our contributors meeting or join us on our Slack

We also recognize that GBFS version 2.3 is widely used, and adding support for it in the near future would bring great value.

As a general guideline for future contributions, we encourage keeping pull requests small and focused whenever possible. One clear goal or fix per PR makes it easier to review, test, and merge. If you’d like to include multiple improvements, consider splitting them into separate PRs for faster feedback and review.

Once again, thank you for your contribution and for the insights you’ve shared throughout this PR. Your work has surfaced valuable points that will help guide future improvements.

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.

4 participants