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
- [dart][dart-dio] Add support for query collection parameter format * add support for collectionFormat in query parameters and www-url-encoded content * add tests * remove empty query parameter maps f... — committed to kuhnroyal/openapi-generator by kuhnroyal 3 years ago
- [dart][dart-dio] Add support for query collection parameter format * add support for collectionFormat in query parameters and www-url-encoded content * add tests * remove empty query parameter maps f... — committed to kuhnroyal/openapi-generator by kuhnroyal 3 years ago
- [dart][dart-dio] Add support for query collection parameter format (#9635) * [dart][dart-dio] Add support for query collection parameter format * add support for collectionFormat in query paramete... — committed to OpenAPITools/openapi-generator by kuhnroyal 3 years ago
Both should now work with collections and
path[]=value1&path[]=value2format. We can not configure the collection format forapplication/x-www-form-urlencodeduntil https://github.com/flutterchina/dio/pull/808 is released.