Skip to content

Commit a791a32

Browse files
authored
Merge pull request #191 from SpinlockLabs/dev
make RepositoryContents json serializable
2 parents e0d0472 + bce84a9 commit a791a32

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v6.0.1
2+
- Fix https://github.com/SpinlockLabs/github.dart/issues/190
3+
14
## v6.0.0
25

36
- There's a single entrypoint now: `package:github/github.dart`

lib/src/common/model/repos_contents.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,22 @@ class Links {
8787
}
8888

8989
/// Model class for a file or directory.
90+
@JsonSerializable(fieldRename: FieldRename.snake)
9091
class RepositoryContents {
92+
RepositoryContents({
93+
this.file,
94+
this.tree,
95+
});
9196
GitHubFile file;
9297
List<GitHubFile> tree;
9398

9499
bool get isFile => file != null;
95100
bool get isDirectory => tree != null;
101+
102+
factory RepositoryContents.fromJson(Map<String, dynamic> json) =>
103+
_$RepositoryContentsFromJson(json);
104+
105+
Map<String, dynamic> toJson() => _$RepositoryContentsToJson(this);
96106
}
97107

98108
/// Model class for a new file to be created.

lib/src/common/model/repos_contents.g.dart

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: github
2-
version: 6.0.0
2+
version: 6.0.1
33
author: Kenneth Endfinger <[email protected]>
44
description: A high-level GitHub API Client Library that uses Github's v3 API
55
homepage: https://github.com/SpinlockLabs/github.dart

0 commit comments

Comments
 (0)