-
Notifications
You must be signed in to change notification settings - Fork 3
Add api module #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add api module #126
Conversation
This file contains hidden or 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
testower
commented
Apr 7, 2025
4da4b2a to
782a489
Compare
73b727c to
6008717
Compare
e776396 to
a13dfc0
Compare
Extends the OpenAPI schema to include a `systemErrors` field in the `GbfsFile` type. This field is an array of `SystemError` objects, each with an `error` code and a `message`. This change introduces two distinct internal SystemError types: - `org.entur.gbfs.validator.loader.SystemError` for file loading issues (e.g., file not found, HTTP connection errors). - `org.entur.gbfs.validation.model.SystemError` for JSON parsing or stream reading issues within the validator. Modifications were made to: - `Loader.java`: To capture loading exceptions and populate them in `LoadedFile.systemErrors`. - `GbfsJsonValidator.java`: To capture parsing/reading exceptions and populate them in `FileValidationResult.systemErrors`. - `ValidateApiDelegateHandler.java`: To map both internal `SystemError` types to the OpenAPI `SystemError` model and combine them in the final API response for each file. Unit tests across all affected modules (`gbfs-validator-java-loader`, `gbfs-validator-java`, `gbfs-validator-java-api`) have been added and updated to verify this new functionality and ensure correct error reporting.
This commit addresses compilation failures that arose after introducing the systemErrors field to FileValidationResult and modifying related method signatures. Fixes include: - Updating FileValidationResult constructor calls in FileValidator.java to include an empty list for systemErrors. - Ensuring the schema argument passed to FileValidationResult constructors in GbfsJsonValidator.java is consistently a String (using .toString() on Schema objects). - Correcting the arguments for the FileValidator.validate call in GbfsJsonValidator.java by removing an extraneous originalContent argument that did not match the method signature.
This commit addresses several issues that were causing the build to fail:
1. **Missing Mockito Dependency**: Added `mockito-core` and `mockito-junit-jupiter` (version 5.12.0) to `gbfs-validator-java/pom.xml` to resolve `package org.mockito does not exist` errors during test compilation.
2. **Constructor Mismatch in ValidationResultTest**: Updated the constructor call for `FileValidationResult` in `ValidationResultTest.java` to include the missing 9th argument (a list of system errors), resolving a compilation error. An empty list is passed for this argument.
3. **JUnit Test Discovery Failure**:
* Added `org.junit.platform:junit-platform-launcher` as a test dependency.
* Configured the `maven-surefire-plugin` with `org.junit.platform:junit-platform-surefire-provider` to ensure JUnit 5 tests are discovered and executed correctly.
With these changes, the project now compiles successfully, and all 15 tests in `gbfs-validator-java` pass.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Feat/system errors
This change adds support for specifying authentication details when fetching GBFS files, as defined in the OpenAPI specification. The loader can now handle Basic Authentication, Bearer Token Authentication, and OAuth 2.0 Client Credentials Grant. Key changes: - Added authentication models (`BasicAuth`, `BearerTokenAuth`, `OAuthClientCredentialsGrantAuth`) to the `gbfs-validator-java-loader` module. - Modified `Loader.java` to accept an `Authentication` object and include appropriate `Authorization` headers in HTTP requests. For OAuth2, it handles fetching the token from the specified token URL. - Integrated these changes into the `gbfs-validator-java-api` module by updating `ValidateApiDelegateHandler.java` to map API authentication models to the loader's authentication models. - Ensured backward compatibility by providing an overloaded `load` method in `Loader.java` that defaults to no authentication. Testing: - I added comprehensive unit tests for `Loader.java` in `gbfs-validator-java-loader` using WireMock. These tests cover successful authentication for all supported methods, as well as error scenarios like incorrect credentials and token fetch failures. - I added integration tests in `gbfs-validator-java-api` using `MockMvc` and WireMock. These tests verify the end-to-end authentication flow, from the API request to the `Loader` making authenticated HTTP calls. They ensure that the `/validate` endpoint correctly processes authentication details and that the system behaves as expected under various authentication scenarios. The tests verify that: - Files are fetched successfully with valid authentication credentials for each supported method. - Appropriate `Authorization` headers are added to requests. - OAuth2 token acquisition works correctly. - System errors are reported for authentication failures (e.g., HTTP 401 errors due to bad credentials or token issues) rather than causing the validation process to crash.
feat: Implement authentication for fetching GBFS files
|
I configured the spring-boot-maven-plugin in `gbfs-validator-java-api/pom.xml` to build an executable fat jar. This allows the API module to be run as a standalone application. I also made the build process more robust by: - Adding integrity check for downloaded schema zip in `gbfs-validator-java/bin/gbfs-download-extract.sh`. - Fixing POM errors in `gbfs-validator-java-api/pom.xml` by removing duplicate dependencies and adding missing versions. I've verified that the generated fat jar includes all necessary dependencies and the application starts successfully.
feat: Create fat jar for gbfs-validator-java-api
…java into feature/api-module
davidgamez
reviewed
Sep 22, 2025
...-java-api/src/main/java/org/entur/gbfs/validator/api/handler/ValidateApiDelegateHandler.java
Show resolved
Hide resolved
gbfs-validator-java-loader/src/main/java/org/entur/gbfs/validator/loader/Loader.java
Outdated
Show resolved
Hide resolved
gbfs-validator-java-loader/src/main/java/org/entur/gbfs/validator/loader/Loader.java
Outdated
Show resolved
Hide resolved
gbfs-validator-java/src/main/java/org/entur/gbfs/validation/model/FileValidationResult.java
Show resolved
Hide resolved
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


Closes #102 and #117
OpenAPI spec for standardized exchange of GBFS validation results
API module for REST api on top of core validator
Loader module that can be reused by future CLI module
API spec: https://dev.gbfs.api.mobilitydatabase.org/openapi.yaml
Demo api: https://dev.gbfs.api.mobilitydatabase.org/validate
Demo ui: https://ent-gbfsvalid-dev.web.app/