question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue
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));
  }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
kuhnroyalcommented, Feb 25, 2021

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.

0reactions
kuhnroyalcommented, May 31, 2021

The application/x-www-form-urlencoded part should now be handled correctly by #9635

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom date and time format strings | Microsoft Learn
Learn to use custom date and time format strings to convert DateTime or DateTimeOffset values into text representations, or to parse strings ...
Read more >
Where's the DateTime 'Z' format specifier? - Stack Overflow
A UTC DateTime is being converted to text in a format that is only correct for local times. This can happen when calling...
Read more >
Demystifying DateTime Manipulation in JavaScript - Toptal
Use the toISOString() or toJSON() methods of the Date object to convert the local DateTime to UTC. const dateFromUI = "12-13-2012"; const timeFromUI...
Read more >
Changelog — Python 3.11.1 documentation
gh-99891: Fix a bug in the tokenizer that could cause infinite recursion when showing ... bpo-43464: Optimize set.intersection() for non-set arguments.
Read more >
MATLAB datestr - MathWorks
datestr is not recommended. To convert datetime values to text, use the string or char function instead. For more information on updating your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found