chopper
chopper copied to clipboard
How to keep the InnerType and the BodyType the same.
I have a wrapper DRFResponse
class which contains the base api response, which wraps another class which will represents the data returned.
@Get()
Future<Response<DRFResponse<Product>>> getAllProducts(
@QueryMap() Map<String, dynamic> queries,
);
in this I expect the BodyType to be DRFResponse<Product>
and the InnerType to be the same.
but when generated chopper makes the BodyType DRFResponse<Product>
and the InnerType Product
. which is wrong and makes errors when parsing my api response.
@override
Future<Response<DRFResponse<Product>>> getAllProducts(
Map<String, dynamic> queries) {
final $url = 'shop/products/';
final $params = queries;
final $request = Request('GET', $url, client.baseUrl, parameters: $params);
return client.send<DRFResponse<Product>, Product>($request);
}
How can i change this behaviour? make the generated BodyType and InnerType the same for this endpoint?
I think the BodyType
and InnerType
are correct. This is usually used in for List
and Map
objects to determine the types. But in this case that InnerType
would be Product
indeed since its the InnerType of DRFResponse
Could you provide a example of the API parsing and where it goes wrong?