-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dart-dio] Fixes issues with DateTime import and form date paramaterT…
…oString function (#4929) - due to the addition of the timemachine library, models were importing ‘DateTime’ when using the core library, which is not a valid import. - the parameterToString function was copied from the dart2 generator and had some errors when some enums were classes.
- Loading branch information
1 parent
bb10e8c
commit f48325a
Showing
9 changed files
with
73 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 12 additions & 16 deletions
28
modules/openapi-generator/src/main/resources/dart-dio/api_util.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:built_value/serializer.dart'; | ||
|
||
/// Format the given parameter object into string. | ||
String parameterToString(dynamic value) { | ||
if (value == null) { | ||
return ''; | ||
} else if (value is DateTime) { | ||
return value.toUtc().toIso8601String(); | ||
{{#models}} | ||
{{#model}} | ||
{{#isEnum}} | ||
} else if (value is {{classname}}) { | ||
return {{classname}}TypeTransformer().encode(value).toString(); | ||
{{/isEnum}} | ||
{{/model}} | ||
{{/models}} | ||
} else { | ||
return value.toString(); | ||
} | ||
String parameterToString(Serializers serializers, dynamic value) { | ||
if (value == null) { | ||
return ''; | ||
} else if (value is String || value is num) { | ||
return value.toString(); | ||
} else { | ||
return json.encode(serializers.serialize(value)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:built_value/serializer.dart'; | ||
|
||
/// Format the given parameter object into string. | ||
String parameterToString(dynamic value) { | ||
if (value == null) { | ||
return ''; | ||
} else if (value is DateTime) { | ||
return value.toUtc().toIso8601String(); | ||
} else { | ||
return value.toString(); | ||
} | ||
String parameterToString(Serializers serializers, dynamic value) { | ||
if (value == null) { | ||
return ''; | ||
} else if (value is String || value is num) { | ||
return value.toString(); | ||
} else { | ||
return json.encode(serializers.serialize(value)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import 'DateTime'; | ||
import 'package:built_value/built_value.dart'; | ||
import 'package:built_value/serializer.dart'; | ||
|
||
|