chopper icon indicating copy to clipboard operation
chopper copied to clipboard

How to keep the InnerType and the BodyType the same.

Open Simouche opened this issue 3 years ago • 1 comments

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?

Simouche avatar Aug 16 '21 09:08 Simouche

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?

Guldem avatar Apr 09 '24 11:04 Guldem