lib/core/stream: LineIterator use CachedIterator
[nit.git] / lib / github / api.nit
index bf7d653..4eb9a97 100644 (file)
@@ -26,7 +26,7 @@ intrude import json::serialization_read
 #
 # To access the API you need an instance of a `GithubAPI` client.
 #
-# ~~~
+# ~~~nitish
 # # Get Github authentification token.
 # var token = get_github_oauth
 # assert not token.is_empty
@@ -37,7 +37,7 @@ intrude import json::serialization_read
 #
 # The API client allows you to get Github API entities.
 #
-# ~~~
+# ~~~nitish
 # var repo = api.load_repo("nitlang/nit")
 # assert repo != null
 # assert repo.name == "nit"
@@ -116,7 +116,7 @@ class GithubAPI
        #     assert err isa GithubError
        #     assert err.name == "GithubAPIError"
        #     assert err.message == "Not Found"
-       fun get(path: String): nullable Jsonable do
+       fun get(path: String): nullable Serializable do
                path = sanitize_uri(path)
                var res = ghcurl.get_and_parse("{api_url}{path}")
                if res isa Error then
@@ -200,7 +200,9 @@ class GithubAPI
                var array = get("/repos/{repo.full_name}/branches")
                var res = new Array[Branch]
                if not array isa JsonArray then return res
-               return deserialize(array.to_json).as(Array[Branch])
+               var deser = deserialize(array.to_json)
+               if deser isa Array[Object] then return res # empty array
+               return deser.as(Array[Branch])
        end
 
        # List of issues associated with their ids.
@@ -507,7 +509,6 @@ end
 #
 # Mainly a Nit wrapper around a JSON objet.
 abstract class GithubEntity
-       super Jsonable
        serialize
 
        # Github page url.
@@ -737,7 +738,7 @@ class Issue
        var closed_by: nullable User is writable
 
        # Is this issue linked to a pull request?
-       var is_pull_request: Bool = false is writable, noserialize
+       var is_pull_request: Bool = false is writable
 end
 
 # A Github pull request.
@@ -850,7 +851,7 @@ class Milestone
        serialize
 
        # The milestone id on Github.
-       var number: Int is writable
+       var number: nullable Int = null is writable
 
        # Milestone title.
        var title: String is writable
@@ -859,10 +860,10 @@ class Milestone
        var description: nullable String is writable
 
        # Count of opened issues linked to this milestone.
-       var open_issues: Int is writable
+       var open_issues: nullable Int = null is writable
 
        # Count of closed issues linked to this milestone.
-       var closed_issues: Int is writable
+       var closed_issues: nullable Int = null is writable
 
        # Milestone state.
        var state: nullable String is writable
@@ -1114,7 +1115,6 @@ end
 
 # Make ISO Datew serilizable
 redef class ISODate
-       super Jsonable
        serialize
 end