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.08k stars 246 forks source link

fix: Add Missing Mapping of DateTime in Multipart #679

Closed Sadhorsephile closed 3 months ago

Sadhorsephile commented 4 months ago

Problem

If we have a request like this:

  @MultiPart()
  @POST('/api/some/path/')
  Future<SomeResponse> requestName({
    @Part(name: 'full_name') required String fullName,
    @Part(name: 'birth_date') required DateTime birthDate,

we'll get a toJson() method have to add to DateTime Exception.

Solution

If part param doesn't have the toJson() method, we have to check whether this is DateTime. If so, we use atoIso8601String method.