feat: Enhances Route API with file export and athlete ID parameter - #179
Merged
Conversation
The GetRoutesByAthleteId method now explicitly takes the athlete ID as a direct argument, reflecting an API change where the ID is expected as a path parameter. This update ensures the client aligns with the latest API specification for this endpoint. Also includes a minor adjustment to parameter setting in CreateActivity for consistency.
The Strava API endpoints for exporting routes as GPX and TCX files return raw file data. This change enables the client to correctly retrieve these files by: - Updating the OpenAPI specification to properly define the file response types. - Registering byte stream consumers for `application/gpx+xml`, `application/tcx+xml`, and other XML/text MIME types. - Modifying the client methods to return the file content as `[]byte` and providing options to explicitly set the `Accept` header. This ensures that users can successfully download route export files
The `go-tools-docker-compose.yml` file has been simplified to focus on core linting and code generation tasks, removing services for specific testing, coverage, and release operations that are now handled through other mechanisms. This streamlines the local development environment setup. Furthermore, integration tests in `examples/client_example_test.go` are explicitly tagged with `//go:build integration` and comprehensive execution instructions, including the `STRAVA_ACCESS_TOKEN` requirement, have been added to the `README.md`. A skip condition was also introduced to enhance test robustness when an authenticated athlete lacks specific data. A minor correction to a `.PHONY` declaration in the `Makefile` completes these tooling adjustments.
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.
Summary
This pull request significantly enhances the Strava Go API client by enabling direct export of GPX and TCX route files and ensuring the
GetRoutesByAthleteIdendpoint correctly utilizes the athlete ID as a path parameter. It also includes comprehensive improvements to development tooling and the integration test suite.Type of change (select all that apply)
What's Changed
GetRouteAsGPXandGetRouteAsTCXmethods in theRoutesAPI now return([]byte, error), providing the raw file content directly.GetRoutesByAthleteIdmethod has been updated to accept the athlete ID as a required path parameter.application/gpx+xml,application/tcx+xml, and other relevant XML/text MIME types to correctly handle file downloads.examples/client_example_test.goare now marked with anintegrationbuild tag, include new tests for fetching routes by athlete ID and exporting files, and feature more robust skipping logic.README.mdhas been updated with instructions for running integration tests.deployments/docker-compose/go-tools-docker-compose.ymlfile has been streamlined by removing several unused build and test services.Makefilefor theformat-codephony target.docs/swagger.jsonreflects the updated route exportproducesmedia types and theidpath parameter forgetRoutesByAthleteId.sportTypeinCreateActivitywas corrected fromSetType(&sportType)toSetSportType(sportType).Breaking Changes
The following changes are breaking for users of the
client/routes.gointerface:GetRouteAsGPXandGetRouteAsTCXmethod signatures have changed from(ctx context.Context, id int64) errorto(ctx context.Context, id int64) ([]byte, error).GetRoutesByAthleteIdmethod signature has changed from(ctx context.Context, opts ...GetRoutesByAthleteIdOpts) ([]models.Route, error)to(ctx context.Context, id int64, opts ...GetRoutesByAthleteIdOpts) ([]models.Route, error), adding a requiredidparameter.Proposed Changes
GetRoutesByAthleteIdendpoint strictly adheres to the OpenAPI specification by correctly processing the athlete ID as a path parameter.go-tools-docker-compose.ymlfile.Additional Information
These changes were made on the
developbranch, reflecting ongoing feature development and improvements.Related Issues