Skip to content

Commit

Permalink
Always keep curly brackets for dynamic paths (#416)
Browse files Browse the repository at this point in the history
Co-authored-by: William Oprandi <[email protected]>
  • Loading branch information
woprandi and woprandi authored Nov 16, 2021
1 parent 87c8a4d commit 74bae83
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion generator/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class RetrofitGenerator extends GeneratorForAnnotation<retrofit.RestApi> {
String? definePath = method.peek("path")?.stringValue;
paths.forEach((k, v) {
final value = v.peek("value")?.stringValue ?? k.displayName;
definePath = definePath?.replaceFirst("{$value}", "\$${k.displayName}");
definePath = definePath?.replaceFirst("{$value}", "\${${k.displayName}}");
});
return literal(definePath);
}
Expand Down
10 changes: 10 additions & 0 deletions generator/test/src/generator_test_src.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ abstract class FormUrlEncodedTest {
Future<String> ip();
}

@ShouldGenerate(
r"/image/${id}_XL.png",
contains: true,
)
@RestApi()
abstract class PathTest {
@GET("/image/{id}_XL.png")
Future<HttpResponse> getImage(@Path('id') String id);
}

@ShouldGenerate(
r'''
final _data = FormData();
Expand Down

0 comments on commit 74bae83

Please sign in to comment.