trevorwang / retrofit.dart

retrofit.dart is an dio client generator using source_gen and inspired by Chopper and Retrofit.
https://mings.in/retrofit.dart/
MIT License
1.06k stars 241 forks source link

Parameter marked with @Body in Retrofit methods fully replace other parameters marked with @Field. #670

Open Ridje opened 2 months ago

Ridje commented 2 months ago

Hello there.

Description I have a situation where I need to use both @Body and @Field together. However, in my specific case, parameters marked with @Field are not used in the generated file. Am I doing something wrong ideologically, or should I use another approach?

Code

  @POST('%{someexample}')
  @FormUrlEncoded()
  Future<String> getMyEndpoint({
    @Field("SERVICE_CODE") required String serviceCode,
    @Body() required Map<String, String> parameters,
    @Field("ACTION") String action = "ONLINE_CHECK",
  });

Expected request body Data: { "SERVICE_CODE: "myCode", "ACTION": "ONLINE_CHECK", "BODY_PARAM_1": "123", "BODY_PARAM_2": "321", }

Actual request body Data: { "BODY_PARAM_1": "123", "BODY_PARAM_2": "321", }