Skip to content

fix(api): add JSON tags to TripDetailResp and PlaceDetailsResp - #420

Open
Ronnie434 wants to merge 1 commit into
timwangmusic:masterfrom
Ronnie434:fix/add-json-tags
Open

fix(api): add JSON tags to TripDetailResp and PlaceDetailsResp#420
Ronnie434 wants to merge 1 commit into
timwangmusic:masterfrom
Ronnie434:fix/add-json-tags

Conversation

@Ronnie434

Copy link
Copy Markdown
Contributor

Problem

TripDetailResp and PlaceDetailsResp structs lack JSON struct tags, causing Go's encoding/json to serialize field names in PascalCase (e.g. OriginalPlanID, LatLongs, PlaceDetails). This is inconsistent with every other response struct in the codebase (PlanningResponse, TravelPlan, TimeSectionPlace, etc.) which all use snake_case JSON tags.

This makes it difficult for frontend clients to parse the /plans/:id and /users/plan/:id endpoints reliably, since all other endpoints return snake_case keys.

Before (no JSON tags):

{
  "OriginalPlanID": "abc-123",
  "LatLongs": [[37.31, -121.95]],
  "PlaceDetails": [{"ID": "...", "Name": "...", "PhotoURL": "..."}],
  "ApiKey": "EXPOSED_KEY"
}

After (with JSON tags):

{
  "original_plan_id": "abc-123",
  "lat_longs": [[37.31, -121.95]],
  "place_details": [{"id": "...", "name": "...", "photo_url": "..."}],
}

Changes

  • Added json:"snake_case" tags to all fields of TripDetailResp and PlaceDetailsResp
  • Marked ApiKey with json:"-" to prevent it from being exposed in API responses (security fix)

Testing

  • Verified the fix compiles cleanly with go build ./...
  • No behavioral changes other than JSON field naming — all existing data is preserved

These two structs lacked JSON tags, causing Go to serialize field names
in PascalCase (e.g. OriginalPlanID, LatLongs, PlaceDetails). This made
it impossible for frontend clients to reliably parse the response using
standard snake_case conventions.

Also marks ApiKey with json:"-" to prevent it from being exposed in API
responses.
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.

1 participant