Skip to content

Commit 32a182b

Browse files
committed
dart: fix lib names for JSON and BASE64
1 parent 23d7630 commit 32a182b

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

modules/swagger-codegen/src/main/resources/dart/api_client.mustache

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ class ApiClient {
4444
{{#model}}
4545
case '{{classname}}':
4646
{{#isEnum}}
47-
// Enclose the value in a list so that Dartson can use a transformer
48-
// to decode it.
49-
final listValue = [value];
50-
final List<dynamic> listResult = dson.map(listValue, []);
51-
return listResult[0];
47+
return new {{classname}}.fromJson(value);
5248
{{/isEnum}}
5349
{{^isEnum}}
5450
return new {{classname}}.fromJson(value);
@@ -76,13 +72,13 @@ class ApiClient {
7672
throw new ApiException(500, 'Could not find a suitable class for deserialization');
7773
}
7874

79-
dynamic deserialize(String json, String targetType) {
75+
dynamic deserialize(String jsonVal, String targetType) {
8076
// Remove all spaces. Necessary for reg expressions as well.
8177
targetType = targetType.replaceAll(' ', '');
8278
83-
if (targetType == 'String') return json;
79+
if (targetType == 'String') return jsonVal;
8480
85-
var decodedJson = JSON.decode(json);
81+
var decodedJson = json.decode(jsonVal);
8682
return _deserialize(decodedJson, targetType);
8783
}
8884

@@ -91,7 +87,7 @@ class ApiClient {
9187
if (obj == null) {
9288
serialized = '';
9389
} else {
94-
serialized = JSON.encode(obj);
90+
serialized = json.encode(obj);
9591
}
9692
return serialized;
9793
}

modules/swagger-codegen/src/main/resources/dart/auth/http_basic_auth.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class HttpBasicAuth implements Authentication {
88
@override
99
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
1010
String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
11-
headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str));
11+
headerParams["Authorization"] = "Basic " + base64.encode(utf8.encode(str));
1212
}
1313

1414
}

0 commit comments

Comments
 (0)