Skip to content
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

fix(generator): generates invalid code for the same path parameter appears multiple times #736

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

YumNumm
Copy link

@YumNumm YumNumm commented Jan 18, 2025

This PR fixes an issue with path parameter replacement in RetrofitGenerator.
This modification allows for multiple occurrences of the same Path Parameter to be properly replaced in API Endpoint URL.

Changes

  • Changed replaceFirst to replaceAll in the path parameter replacement logic
  • Added test cases to verify multiple path parameter replacements

Example

https://x.com/YumNumm/status/1880651949508612347

image


Before:

@Get('/users/{id}/posts/{id}')
Future<ResponseType> getUserPosts(@Path('id') String id);
// Only replaces first occurrence: `/users/123/posts/{id}`

After:

@Get('/users/{id}/posts/{id}')
Future<ResponseType> getUserPosts(@Path('id') String id);
// Replaces all occurrences: `/users/123/posts/123`

Related Issues

N/A

@YumNumm YumNumm changed the title FIX(generator): generates invalid code for the same path parameter appears multiple times fix(generator): generates invalid code for the same path parameter appears multiple times Jan 18, 2025
@YumNumm YumNumm marked this pull request as ready for review January 18, 2025 16:58
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