diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-12-24 03:03:56 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-12-24 03:10:34 +0900 |
commit | 410e7bdfe7f814688a1d65cb405630e1ca4803c2 (patch) | |
tree | 69acf809dffd52525b5e5878d59b61bb6e996d38 /frontend/src | |
parent | 98563422c7daffaea11c29c5f5820fbc78791209 (diff) | |
download | aclog-410e7bdfe7f814688a1d65cb405630e1ca4803c2.tar.gz |
static apidocs
Diffstat (limited to 'frontend/src')
-rw-r--r-- | frontend/src/components/apidocs/endpoint.vue | 54 | ||||
-rw-r--r-- | frontend/src/components/apidocs/sidebar.vue | 9 | ||||
-rw-r--r-- | frontend/src/lib/aclog.js | 3 | ||||
-rw-r--r-- | frontend/src/lib/apidocs.js | 276 |
4 files changed, 303 insertions, 39 deletions
diff --git a/frontend/src/components/apidocs/endpoint.vue b/frontend/src/components/apidocs/endpoint.vue index aeddced..c87448f 100644 --- a/frontend/src/components/apidocs/endpoint.vue +++ b/frontend/src/components/apidocs/endpoint.vue @@ -40,7 +40,7 @@ <script> import ApidocsSidebar from "./sidebar.vue"; -import aclog from "aclog"; +import apidocs from "apidocs"; import utils from "utils"; export default { @@ -74,34 +74,30 @@ export default { transition.abort(); }; - aclog.apidocs.load().then(docs => { - const path = this.$route.params.path; - const ns = path.split("/", 2)[0]; - const es = docs.namespaces[ns]; - if (!es) return notFound(); - const endpoint = es.find(endp => endp.path === path); - if (!endpoint) return notFound(); - - transition.next({ endpoint: endpoint, example: { loading: false, result: null } }); - }).catch(notFound).then(() => { - this.example.loading = true; - fetch(this.example_url).then(res => { - if (res.status >= 400) { - var err = new Error(res.statusText); - err.response = res; - throw err; - } - return res.json(); - }).then(body => { - this.example.loading = false; - this.example.result = JSON.stringify(body, null, 2); - }).catch(err => { - this.example.loading = false; - this.example.result = "Failed to load example. (" + err + ")"; - if (err.response) { - err.response.json().then(body => this.example.result += "\n" + JSON.stringify(body, null, 2)); - } - }); + const path = this.$route.params.path; + const ns = path.split("/", 2)[0]; + const es = apidocs.namespaces[ns]; + if (!es) return notFound(); + const endpoint = es.find(endp => endp.path === path); + if (!endpoint) return notFound(); + transition.next({ endpoint: endpoint, example: { loading: false, result: null } }); + this.example.loading = true; + fetch(this.example_url).then(res => { + if (res.status >= 400) { + var err = new Error(res.statusText); + err.response = res; + throw err; + } + return res.json(); + }).then(body => { + this.example.loading = false; + this.example.result = JSON.stringify(body, null, 2); + }).catch(err => { + this.example.loading = false; + this.example.result = "Failed to load example. (" + err + ")"; + if (err.response) { + err.response.json().then(body => this.example.result += "\n" + JSON.stringify(body, null, 2)); + } }); } }, diff --git a/frontend/src/components/apidocs/sidebar.vue b/frontend/src/components/apidocs/sidebar.vue index 0c3a43b..dda2722 100644 --- a/frontend/src/components/apidocs/sidebar.vue +++ b/frontend/src/components/apidocs/sidebar.vue @@ -14,12 +14,12 @@ </template> <script> -import aclog from "aclog"; +import apidocs from "apidocs"; export default { data() { return { - apidocs: {}, + apidocs: apidocs.namespaces, loading: false, }; }, @@ -32,11 +32,6 @@ export default { }, }, created() { - this.loading = true; - aclog.apidocs.load().then(docs => { - this.loading = false; - this.apidocs = docs.namespaces - }); } }; </script> diff --git a/frontend/src/lib/aclog.js b/frontend/src/lib/aclog.js index b41f459..39525a3 100644 --- a/frontend/src/lib/aclog.js +++ b/frontend/src/lib/aclog.js @@ -65,9 +65,6 @@ export default { destroy: () => post("sessions/destroy"), verify: () => get("sessions/verify"), }, - apidocs: { - load: () => get("apidocs/all"), - }, optout: { redirect: (cb) => post("optout/redirect", { oauth_callback: cb }), callback: (verifier) => get("optout/callback", { oauth_verifier: verifier }), diff --git a/frontend/src/lib/apidocs.js b/frontend/src/lib/apidocs.js new file mode 100644 index 0000000..9757501 --- /dev/null +++ b/frontend/src/lib/apidocs.js @@ -0,0 +1,276 @@ +export default { + "namespaces": { + "tweets": [ + { + "method": "GET", + "description": "Returns a single Tweet, specified by ID.", + "path": "tweets/show", + "params": { + "id": { + "required": true, + "description": "The numerical ID of the desired Tweet.", + "type": "Integer" + } + }, + "example_params": { + "id": 43341783446466560 + } + }, + { + "method": "GET", + "description": "Returns Tweets, specified by comma-separated IDs.", + "path": "tweets/lookup", + "params": { + "ids": { + "required": true, + "description": "A comma-separated list of Tweet IDs, up to 100 are allowed in a single request.", + "type": "String" + } + }, + "example_params": { + "ids": "43341783446466560,340640143058825216" + } + }, + { + "method": "GET", + "description": "Returns the best Tweets of a user, specified by username or user ID.", + "path": "tweets/user_best", + "params": { + "user_id": { + "required": false, + "description": "The numerical ID of the user for whom to return results for.", + "type": "Integer" + }, + "screen_name": { + "required": false, + "description": "The username of the user for whom to return results for.", + "type": "String" + }, + "count": { + "required": false, + "description": "The number of tweets to retrieve. Must be less than or equal to 100, defaults to 10.", + "type": "Integer" + }, + "page": { + "required": false, + "description": "The page number of results to retrieve.", + "type": "Integer" + }, + "recent": { + "required": false, + "description": "When specified, returns only recent tweets in the term. Format is: /^\\d+[dwmy]$/", + "type": "String" + } + }, + "example_params": { + "user_id": 15926668, + "count": 2, + "page": 3, + "recent": "1m" + } + }, + { + "method": "GET", + "description": "Returns the newest Tweets of a user, specified by username or user ID.", + "path": "tweets/user_timeline", + "params": { + "user_id": { + "required": false, + "description": "The numerical ID of the user for whom to return results for.", + "type": "Integer" + }, + "screen_name": { + "required": false, + "description": "The username of the user for whom to return results for.", + "type": "String" + }, + "count": { + "required": false, + "description": "The number of tweets to retrieve. Must be less than or equal to 100, defaults to 10.", + "type": "Integer" + }, + "page": { + "required": false, + "description": "The page number of results to retrieve.", + "type": "Integer" + }, + "since_id": { + "required": false, + "description": "Returns results with an ID greater than the specified ID.", + "type": "Integer" + }, + "max_id": { + "required": false, + "description": "Returns results with an ID less than or equal to the specified ID.", + "type": "Integer" + }, + "reactions": { + "required": false, + "description": "Returns Tweets which has received reactions more than (or equal to) the specified number of times.", + "type": "Integer" + } + }, + "example_params": { + "screen_name": "toshi_a", + "count": 3, + "max_id": 432112694871605250 + } + }, + { + "method": "GET", + "description": "Returns the Tweets which a user specified by username or user ID favorited.", + "path": "tweets/user_favorites", + "params": { + "user_id": { + "required": false, + "description": "The numerical ID of the user for whom to return results for.", + "type": "Integer" + }, + "screen_name": { + "required": false, + "description": "The username of the user for whom to return results for.", + "type": "String" + }, + "count": { + "required": false, + "description": "The number of tweets to retrieve. Must be less than or equal to 100, defaults to 10.", + "type": "Integer" + }, + "page": { + "required": false, + "description": "The page number of results to retrieve.", + "type": "Integer" + }, + "reactions": { + "required": false, + "description": "Returns Tweets which has received reactions more than (or equal to) the specified number of times.", + "type": "Integer" + } + }, + "example_params": { + "user_id": 120726371, + "count": 2 + } + }, + { + "method": "GET", + "description": "Returns the specified user's Tweets which another specified user favorited.", + "path": "tweets/user_favorited_by", + "params": { + "user_id": { + "required": false, + "description": "The numerical ID of the user for whom to return results for.", + "type": "Integer" + }, + "screen_name": { + "required": false, + "description": "The username of the user for whom to return results for.", + "type": "String" + }, + "source_user_id": { + "required": false, + "description": "The numerical ID of the user for whom to return results for.", + "type": "Integer" + }, + "source_screen_name": { + "required": false, + "description": "The username of the user for whom to return results for.", + "type": "String" + }, + "count": { + "required": false, + "description": "The number of tweets to retrieve. Must be less than or equal to 100, defaults to 10.", + "type": "Integer" + }, + "page": { + "required": false, + "description": "The page number of results to retrieve.", + "type": "Integer" + }, + "since_id": { + "required": false, + "description": "Returns results with an ID greater than the specified ID.", + "type": "Integer" + }, + "max_id": { + "required": false, + "description": "Returns results with an ID less than or equal to the specified ID.", + "type": "Integer" + }, + "reactions": { + "required": false, + "description": "Returns Tweets which has received reactions more than (or equal to) the specified number of times.", + "type": "Integer" + } + }, + "example_params": { + "user_id": 120726371, + "count": 2, + "source_screen_name": "haru067" + } + } + ], + "users": [ + { + "method": "GET", + "description": "Returns the stats of a user, specified by username or user ID.", + "path": "users/stats", + "params": { + "id": { + "required": false, + "description": "The numerical ID of the user for whom to return results for.", + "type": "Integer" + }, + "screen_name": { + "required": false, + "description": "The username of the user for whom to return results for.", + "type": "String" + } + }, + "example_params": { + "id": 15926668 + } + }, + { + "method": "GET", + "description": "Returns the list of the users who discovered the Tweets of a user, specified by username or user ID.", + "path": "users/discovered_by", + "params": { + "id": { + "required": false, + "description": "The numerical ID of the user for whom to return results for.", + "type": "Integer" + }, + "screen_name": { + "required": false, + "description": "The username of the user for whom to return results for.", + "type": "String" + } + }, + "example_params": { + "id": 15926668 + } + }, + { + "method": "GET", + "description": "Returns the list of the users discovered by a user, specified by username or user ID.", + "path": "users/discovered_users", + "params": { + "id": { + "required": false, + "description": "The numerical ID of the user for whom to return results for.", + "type": "Integer" + }, + "screen_name": { + "required": false, + "description": "The username of the user for whom to return results for.", + "type": "String" + } + }, + "example_params": { + "screen_name": "toshi_a" + } + } + ] + } +}; |