openApiDateTimeParameterToString function
Convert a DateTime to a string parameter. A {path} parameter requires encoding, whereas a Query parameter doesn't. To ensure a non-breaking API, we use encode to default true.
Implementation
String openApiDateTimeParameterToString(dynamic value, [bool encode = true]) {
if (encode) {
return Uri.encodeComponent((value as DateTime).toUtc().toIso8601String());
} else {
return (value as DateTime).toUtc().toIso8601String();
}
}