Skip to content

feat: Enhances Route API with file export and athlete ID parameter - #179

Merged
obalunenko merged 3 commits into
masterfrom
develop
Jun 5, 2026
Merged

feat: Enhances Route API with file export and athlete ID parameter#179
obalunenko merged 3 commits into
masterfrom
develop

Conversation

@obalunenko

Copy link
Copy Markdown
Owner

Summary

This pull request significantly enhances the Strava Go API client by enabling direct export of GPX and TCX route files and ensuring the GetRoutesByAthleteId endpoint 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)

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (a change that only restructures existing code)
  • Build related changes (related to building the application or its environment)
  • Documentation change (a change to documentation only)

What's Changed

  • The GetRouteAsGPX and GetRouteAsTCX methods in the Routes API now return ([]byte, error), providing the raw file content directly.
  • The GetRoutesByAthleteId method has been updated to accept the athlete ID as a required path parameter.
  • The client initialization now registers custom consumers for application/gpx+xml, application/tcx+xml, and other relevant XML/text MIME types to correctly handle file downloads.
  • Integration tests in examples/client_example_test.go are now marked with an integration build tag, include new tests for fetching routes by athlete ID and exporting files, and feature more robust skipping logic.
  • The README.md has been updated with instructions for running integration tests.
  • The deployments/docker-compose/go-tools-docker-compose.yml file has been streamlined by removing several unused build and test services.
  • Minor correction in Makefile for the format-code phony target.
  • The docs/swagger.json reflects the updated route export produces media types and the id path parameter for getRoutesByAthleteId.
  • A parameter setting for sportType in CreateActivity was corrected from SetType(&sportType) to SetSportType(sportType).

Breaking Changes

The following changes are breaking for users of the client/routes.go interface:

  • The GetRouteAsGPX and GetRouteAsTCX method signatures have changed from (ctx context.Context, id int64) error to (ctx context.Context, id int64) ([]byte, error).
  • The GetRoutesByAthleteId method 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 required id parameter.

Proposed Changes

  • Implement robust file export capabilities for Strava routes in GPX and TCX formats, allowing direct retrieval of file content.
  • Ensure the GetRoutesByAthleteId endpoint strictly adheres to the OpenAPI specification by correctly processing the athlete ID as a path parameter.
  • Enhance the client's ability to handle diverse media types by explicitly registering consumers for various XML and text formats.
  • Optimize the development and testing workflow by refactoring integration tests, introducing a dedicated build tag, and expanding test coverage for route functionalities.
  • Streamline the project's build and development environment by pruning the go-tools-docker-compose.yml file.

Additional Information

These changes were made on the develop branch, reflecting ongoing feature development and improvements.

Related Issues

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.
@obalunenko obalunenko self-assigned this Jun 5, 2026
@obalunenko
obalunenko merged commit 95d3314 into master Jun 5, 2026
4 checks passed
@obalunenko
obalunenko deleted the develop branch June 5, 2026 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant