4 commits: dart2 support, latest json_serial, etc
MODIFY
lib/src/common.g.dart
lib/src/common.g.dart
@@ -7,19 +7,19 @@ part of github.common;
// **************************************************************************
GitTree _$GitTreeFromJson(Map<String, dynamic> json) {
- return new GitTree(
+ return GitTree(
json['sha'] as String,
json['url'] as String,
json['truncated'] as bool,
(json['tree'] as List)
?.map((e) => e == null
? null
- : new GitTreeEntry.fromJson(e as Map<String, dynamic>))
+ : GitTreeEntry.fromJson(e as Map<String, dynamic>))
?.toList());
}
GitTreeEntry _$GitTreeEntryFromJson(Map<String, dynamic> json) {
- return new GitTreeEntry(
+ return GitTreeEntry(
json['path'] as String,
json['mode'] as String,
json['type'] as String,
@@ -29,7 +29,7 @@ GitTreeEntry _$GitTreeEntryFromJson(Map<String, dynamic> json) {
}
GitHubComparison _$GitHubComparisonFromJson(Map<String, dynamic> json) {
- return new GitHubComparison(
+ return GitHubComparison(
json['url'] as String,
json['status'] as String,
json['ahead_by'] as int,
@@ -38,62 +38,61 @@ GitHubComparison _$GitHubComparisonFromJson(Map<String, dynamic> json) {
}
Tag _$TagFromJson(Map<String, dynamic> json) {
- return new Tag(
+ return Tag(
json['name'] as String,
json['commit'] == null
? null
- : new CommitInfo.fromJson(json['commit'] as Map<String, dynamic>),
+ : CommitInfo.fromJson(json['commit'] as Map<String, dynamic>),
json['zipball_url'] as String,
json['tarball_url'] as String);
}
CommitData _$CommitDataFromJson(Map<String, dynamic> json) {
- return new CommitData(
+ return CommitData(
json['sha'] as String,
- json['commit'] == null ? null : new GitCommit.fromJson(json['commit']),
+ json['commit'] == null ? null : GitCommit.fromJson(json['commit']),
json['url'] as String,
json['html_url'] as String,
json['comments_url'] as String,
json['author'] == null
? null
- : new CommitDataUser.fromJson(json['author'] as Map<String, dynamic>),
+ : CommitDataUser.fromJson(json['author'] as Map<String, dynamic>),
json['committer'] == null
? null
- : new CommitDataUser.fromJson(
- json['committer'] as Map<String, dynamic>),
+ : CommitDataUser.fromJson(json['committer'] as Map<String, dynamic>),
(json['parents'] as List)
?.map((e) => e as Map<String, dynamic>)
?.toList());
}
CommitDataUser _$CommitDataUserFromJson(Map<String, dynamic> json) {
- return new CommitDataUser(
+ return CommitDataUser(
json['login'] as String, json['id'] as int, json['type'] as String);
}
CommitInfo _$CommitInfoFromJson(Map<String, dynamic> json) {
- return new CommitInfo(
+ return CommitInfo(
json['sha'] as String,
json['tree'] == null
? null
- : new GitTree.fromJson(json['tree'] as Map<String, dynamic>));
+ : GitTree.fromJson(json['tree'] as Map<String, dynamic>));
}
UserInformation _$UserInformationFromJson(Map<String, dynamic> json) {
- return new UserInformation(json['login'] as String, json['id'] as int,
+ return UserInformation(json['login'] as String, json['id'] as int,
json['avatar_url'] as String, json['html_url'] as String);
}
Branch _$BranchFromJson(Map<String, dynamic> json) {
- return new Branch(
+ return Branch(
json['name'] as String,
json['commit'] == null
? null
- : new CommitData.fromJson(json['commit'] as Map<String, dynamic>));
+ : CommitData.fromJson(json['commit'] as Map<String, dynamic>));
}
LicenseDetails _$LicenseDetailsFromJson(Map<String, dynamic> json) {
- return new LicenseDetails(
+ return LicenseDetails(
name: json['name'] as String,
path: json['path'] as String,
sha: json['sha'] as String,
@@ -112,10 +111,10 @@ LicenseDetails _$LicenseDetailsFromJson(Map<String, dynamic> json) {
encoding: json['encoding'] as String,
links: json['_links'] == null
? null
- : new Links.fromJson(json['_links'] as Map<String, dynamic>),
+ : Links.fromJson(json['_links'] as Map<String, dynamic>),
license: json['license'] == null
? null
- : new LicenseKind.fromJson(json['license'] as Map<String, dynamic>));
+ : LicenseKind.fromJson(json['license'] as Map<String, dynamic>));
}
Map<String, dynamic> _$LicenseDetailsToJson(LicenseDetails instance) =>
@@ -136,7 +135,7 @@ Map<String, dynamic> _$LicenseDetailsToJson(LicenseDetails instance) =>
};
LicenseKind _$LicenseKindFromJson(Map<String, dynamic> json) {
- return new LicenseKind(
+ return LicenseKind(
key: json['key'] as String,
name: json['name'] as String,
spdxId: json['spdx_id'] as String,
@@ -154,7 +153,7 @@ Map<String, dynamic> _$LicenseKindToJson(LicenseKind instance) =>
};
Links _$LinksFromJson(Map<String, dynamic> json) {
- return new Links(
+ return Links(
git: json['git'] == null ? null : Uri.parse(json['git'] as String),
self: json['self'] == null ? null : Uri.parse(json['self'] as String),
html: json['html'] == null ? null : Uri.parse(json['html'] as String));

MODIFY
lib/src/common/model/repos.dart
lib/src/common/model/repos.dart
part of github.common;
-@JsonSerializable(createToJson: false)
+@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
class GitHubComparison {
final String url;
-
final String status;
-
- @JsonKey(name: 'ahead_by')
final int aheadBy;
-
- @JsonKey(name: 'behind_by')
final int behindBy;
-
- @JsonKey(name: 'total_commits')
final int totalCommits;
GitHubComparison(
@@ -205,7 +198,6 @@ class CloneUrls {
class Tag {
final String name;
final CommitInfo commit;
-
@JsonKey(name: 'zipball_url')
final String zipUrl;
@JsonKey(name: 'tarball_url')
@@ -220,18 +212,12 @@ class Tag {
String toString() => 'Tag: $name';
}
-@JsonSerializable(createToJson: false)
+@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
class CommitData {
final String sha;
final GitCommit commit;
-
- @JsonKey(name: "url")
final String url;
-
- @JsonKey(name: "html_url")
final String htmlUrl;
-
- @JsonKey(name: "comments_url")
final String commentsUrl;
final CommitDataUser author, committer;
@@ -268,7 +254,7 @@ class CommitInfo {
}
/// User Information
-@JsonSerializable(createToJson: false)
+@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
class UserInformation {
/// Owner Username
final String login;
@@ -277,11 +263,9 @@ class UserInformation {
final int id;
/// Avatar Url
- @JsonKey(name: "avatar_url")
final String avatarUrl;
/// Url to the user's GitHub Profile
- @JsonKey(name: "html_url")
final String htmlUrl;
UserInformation(this.login, this.id, this.avatarUrl, this.htmlUrl);
@@ -454,7 +438,7 @@ class LanguageBreakdown {
}
}
-@JsonSerializable()
+@JsonSerializable(fieldRename: FieldRename.snake)
class LicenseDetails {
final String name;
final String path;
@@ -462,11 +446,8 @@ class LicenseDetails {
final int size;
final Uri url;
- @JsonKey(name: 'html_url')
final Uri htmlUrl;
- @JsonKey(name: 'git_url')
final Uri gitUrl;
- @JsonKey(name: 'download_url')
final Uri downloadUrl;
final String type;
@@ -499,16 +480,12 @@ class LicenseDetails {
Map<String, dynamic> toJson() => _$LicenseDetailsToJson(this);
}
-@JsonSerializable()
+@JsonSerializable(fieldRename: FieldRename.snake)
class LicenseKind {
final String key;
final String name;
-
- @JsonKey(name: 'spdx_id')
final String spdxId;
final Uri url;
-
- @JsonKey(name: 'node_id')
final String nodeId;
LicenseKind({this.key, this.name, this.spdxId, this.url, this.nodeId});

MODIFY
pubspec.yaml
pubspec.yaml
@@ -4,15 +4,15 @@ author: Kenneth Endfinger <kaendfinger@gmail.com>
description: GitHub API Client Library
homepage: https://github.com/DirectMyFile/github.dart
environment:
- sdk: '>=2.0.0-dev.36 <2.0.0'
+ sdk: '>=2.0.0-dev.36 <3.0.0'
dependencies:
html: '>=0.12.0 <0.14.0'
http: '^0.11.3'
http_parser: ^3.1.1
- json_annotation: '>=0.2.8 <2.0.0'
+ json_annotation: ^1.1.0
xml: '>=2.0.0 <4.0.0'
dev_dependencies:
- build_runner: ^0.9.0
- json_serializable: ^1.0.0
- test: '^0.12.0'
- mockito: '^1.0.1'
+ build_runner: ^0.10.0
+ json_serializable: ^1.1.0
+ test: ^1.3.0
+ mockito: ^3.0.0

MODIFY
test/git_test.dart
test/git_test.dart
@@ -133,8 +133,7 @@ void main() {
// given
http.Response expectedResponse = new http.Response('{}', 200);
- when(github.request(any, any,
- body: any, headers: typed(any, named: 'headers')))
+ when(github.request(any, any, body: any, headers: any))
.thenReturn(new Future.value(expectedResponse));
// when
@@ -142,22 +141,21 @@ void main() {
// then
verify(github.request('PATCH', '/repos/o/n/git/refs/heads/b',
- headers: typed(any, named: 'headers'), body: any));
+ headers: any, body: any));
});
test('creates valid JSON body', () {
// given
http.Response expectedResponse = new http.Response('{}', 200);
- when(github.request(any, any,
- body: any, headers: typed(any, named: 'headers')))
+ when(github.request(any, any, body: any, headers: any))
.thenReturn(new Future.value(expectedResponse));
// when
git.editReference(repo, 'heads/b', someSha, force: true);
// then
- var captured = verify(github.request(any, any,
- body: captureAny, headers: typed(captureAny, named: 'headers')))
+ var captured = verify(
+ github.request(any, any, body: captureAny, headers: captureAny))
.captured;
var body = jsonDecode(captured[0]);

4 commits: dart2 support, latest json_serial, etc (#112)