openapi-generator: [BUG][dart-dio] optimize parameterToString to convert DateTime correctly

Description

Currently DateTime is being converted to string using normal .ToString() Ref: https://github.com/OpenAPITools/openapi-generator/blob/c3220848f24bbc5e5441f53846916eaa82e6673c/modules/openapi-generator/src/main/resources/dart-dio/api_util.mustache#L6-L14

instead, toIso8601String should be used

openapi-generator version

V5.0.0

Suggested fix:
  if (value == null) {
    return '';
  } else if (value is String || value is num) {
    return value.toString();
  } else if (value is DateTime) {
    return value.toIso8601String();
  } else {
    return json.encode(serializers.serialize(value));
  }

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (18 by maintainers)

Commits related to this issue

Most upvoted comments

Both should now work with collections and path[]=value1&path[]=value2 format. We can not configure the collection format for application/x-www-form-urlencoded until https://github.com/flutterchina/dio/pull/808 is released.