fix: align routes-for-agency with OBA API spec #855
Open
reddy-santhu wants to merge 1 commit intoOneBusAway:mainfrom
Open
fix: align routes-for-agency with OBA API spec #855reddy-santhu wants to merge 1 commit intoOneBusAway:mainfrom
reddy-santhu wants to merge 1 commit intoOneBusAway:mainfrom
Conversation
c7d1cb6 to
24132a0
Compare
24132a0 to
57bb8d9
Compare
Contributor
Author
|
Hey @aaronbrethorst, would you mind taking a look at this when you get a chance? I want to make sure I'm heading in the right direction before picking up more issues , thanks! |
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
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 #845
This PR addresses the behavioural gaps identified in the spec for
GET /api/where/routes-for-agency/{id}, verified against the live Puget Sound OBA server.Changes
Handler
sendNullwhich produced a 200 response with a null body. The fix replaces it withsendNotFound, consistent with how stops, routes and trips handle the same case.limitExceededis alwaysfalse. TheParsePaginationParamsandPaginateSlicecalls are dropped andlimitExceededis hardcoded tofalse.includeReferences=falsesupported. When passed, the references block is returned empty. Defaults totrue.Models
shortName,longName,description,url,color,textColor) now useomitemptyso they are absent from the response when the GTFS feed does not supply them, matching the spec's field definitions.nullSafeShortNameis removed from the wire format withjson:"-". It is an internal Java implementation detail that was leaking into responses and is not part of the spec schema.AgencyReferencefields (lang,phone,email,fareUrl,disclaimer) now useomitempty. Required fields (id,name,url,timezone,privateService) are unchanged.Cleanup
NullSafeShortNameassignments inreference_utils.goandtrip_details_handler.go. The field isjson:"-"so those values were never serialised or read anywhere.Tests
TestRoutesForAgencyHandlerEndToEndextended with per-route assertions on required fields (id,agencyId,type) and per-agency assertions on required reference fields (id,name,url,timezone,privateService), and a check thatnullSafeShortNameis absent from every route object.TestRoutesForAgencyHandlerNonExistentAgencyupdated to assert 404 with"resource not found"text.TestRoutesForAgencyHandlerLimitExceededAlwaysFalsereplaces the old pagination test.TestRoutesForAgencyHandlerIncludeReferencesFalseadded for theincludeReferences=falsepath.TestAgenciesWithCoverageHandlerEndToEnd,TestRouteHandlerEndToEnd,TestRouteWithNilValuesJSONupdated for the newomitemptyserialisation behaviour.Verification
Envelope and list shape (Maglev)
{ "version": 2, "code": 200, "text": "OK", "limitExceeded": false, "routeCount": 8, "agencyRefCount": 1 }Route fields — side by side
Live OBA Java server:
{ "agencyId": "40", "color": "2B376E", "description": "", "id": "40_532", "longName": "Everett - Bellevue", "nullSafeShortName": "532", "shortName": "532", "textColor": "FFFFFF", "type": 3, "url": "https://www.soundtransit.org/ride-with-us/routes-schedules/532" }Maglev after this PR:
{ "agencyId": "40", "color": "FFB819", "id": "40_1-SHUTTLE", "longName": "Link Replacement Shuttle Bus", "shortName": "Shuttle", "textColor": "000000", "type": 3 }nullSafeShortName is gone. description and url are absent rather than serialised as "" when the GTFS feed does not supply them.
Agency reference (Maglev)
{ "email": "main@soundtransit.org", "fareUrl": "https://www.soundtransit.org/ride-with-us/how-to-pay/fares", "id": "40", "lang": "en", "name": "Sound Transit", "phone": "1-888-889-6368", "privateService": false, "timezone": "America/Los_Angeles", "url": "https://www.soundtransit.org" }includeReferences=false (Maglev)
{ "agencies": [], "routes": [], "situations": [], "stopTimes": [], "stops": [], "trips": [] }Unknown agency — defect fixed
Live OBA Java returns a malformed error envelope with no standard fields:
{ "code": null, "text": null }Maglev returns a proper 404:
{ "code": 404, "text": "resource not found" }Auth and validation
11@10)Notes
The
versionquery parameter is not validated by this PR. Supplying a value other than 2 returning 500 is documented in the spec but per-handler version checking would be inconsistent with the rest of the codebase. If needed, it belongs in shared middleware.