Describe the bug
When using both dio baseUrl and the retrofit annotation's baseUrl together, the annotation's baseUrl overrides the existing baseUrl's endpoint. For example: /api/v1 with /employee.
To Reproduce
This can be reproduced from the example given in the documentation (README)
Steps to reproduce the behavior:
@RestApi(baseUrl: '/tasks')
abstract class RestClient {
factory RestClient(Dio dio, {String? baseUrl}) = _RestClient;
@GET('{id}')
Future<HttpResponse<Task>> getTask(@Path('id') String id);
@GET('')
Future<HttpResponse<List<Task>>> getTasks();
}
// Inside main
dio.options.baseUrl = 'https://mockapi.io/api/v1';
final client = RestClient(dio);
await client.getTasks();
Expected behavior
The client should send a request to https://mockapi.io/api/v1/tasks. But instead, it makes a request to https://mockapi.io/tasks.
The issue is that /api/v1 is removed, which messes up everything.
I have confirmed this by both logging (talker_dio) and also by debugging with breakpoint. I can see the url being generated inside the _combineBaseUrls method of my generated class. With return Uri.parse(dioBaseUrl).resolveUri(url).toString();
Describe the bug When using both dio baseUrl and the retrofit annotation's
baseUrl
together, the annotation'sbaseUrl
overrides the existingbaseUrl
's endpoint. For example:/api/v1
with/employee
.To Reproduce This can be reproduced from the example given in the documentation (README) Steps to reproduce the behavior:
Expected behavior The client should send a request to
https://mockapi.io/api/v1/tasks
. But instead, it makes a request tohttps://mockapi.io/tasks
.The issue is that
/api/v1
is removed, which messes up everything.I have confirmed this by both logging (talker_dio) and also by debugging with breakpoint. I can see the url being generated inside the
_combineBaseUrls
method of my generated class. Withreturn Uri.parse(dioBaseUrl).resolveUri(url).toString();