From b20aeb76daf0c2a60c2e98189b91a7bd6df764f5 Mon Sep 17 00:00:00 2001 From: Tosuke Date: Wed, 4 Jan 2017 15:04:54 +0900 Subject: [PATCH] [WIP][Swagger]Add swagger definition - /auth/session/userkey - User entity --- src/api/endpoints/auth/session/generate.js | 1 + src/api/endpoints/auth/session/userkey.js | 36 ++++++++++ src/api/endpoints/users.js | 76 ++++++++++++++++++++++ swagger.js | 4 +- 4 files changed, 116 insertions(+), 1 deletion(-) diff --git a/src/api/endpoints/auth/session/generate.js b/src/api/endpoints/auth/session/generate.js index 07ff8a819..1390ae290 100644 --- a/src/api/endpoints/auth/session/generate.js +++ b/src/api/endpoints/auth/session/generate.js @@ -15,6 +15,7 @@ import AuthSess from '../../../models/auth-session'; * parameters: * - * name: app_secret + * description: App Secret * in: formData * required: true * type: string diff --git a/src/api/endpoints/auth/session/userkey.js b/src/api/endpoints/auth/session/userkey.js index 2626e4ce3..918caa8f3 100644 --- a/src/api/endpoints/auth/session/userkey.js +++ b/src/api/endpoints/auth/session/userkey.js @@ -8,6 +8,42 @@ import AuthSess from '../../../models/auth-session'; import Userkey from '../../../models/userkey'; import serialize from '../../../serializers/user'; +/** + * @swagger + * /auth/session/userkey: + * post: + * summary: Get a userkey + * parameters: + * - + * name: app_secret + * description: App Secret + * in: formData + * required: true + * type: string + * - + * name: token + * description: API Token + * in: formData + * required: true + * type: string + * + * responses: + * 200: + * description: OK + * schema: + * type: object + * properties: + * userkey: + * type: string + * description: User Key + * user: + * $ref: "#/definitions/User" + * 400: + * description: Failed + * schema: + * $ref: "#/definitions/Error" + */ + /** * Generate a session * diff --git a/src/api/endpoints/users.js b/src/api/endpoints/users.js index cd40cdf4e..bb47b4b64 100644 --- a/src/api/endpoints/users.js +++ b/src/api/endpoints/users.js @@ -6,6 +6,82 @@ import User from '../models/user'; import serialize from '../serializers/user'; +/** + * @swagger + * definitions: + * User: + * type: object + * required: + * - created_at + * - followers_count + * - following_count + * - id + * - liked_count + * - likes_count + * - name + * - posts_count + * - username + * properties: + * avatar_id: + * type: string + * description: アバターに設定しているドライブのファイルのID + * avatar_url: + * type: string + * description: アバターURL + * banner_id: + * type: string + * description: バナーに設定しているドライブのファイルのID + * banner_url: + * type: string + * description: バナーURL + * bio: + * type: string + * description: プロフィール + * birthday: + * type: string + * description: 誕生日 + * created_at: + * type: string + * format: date + * description: アカウント作成日時 + * drive_capacity: + * type: integer + * description: ドライブの最大容量 + * followers_count: + * type: integer + * description: フォロワー数 + * following_count: + * type: integer + * description: フォロー数 + * id: + * type: string + * description: ユーザーID + * is_followed: + * type: boolean + * description: フォローされているか + * is_following: + * type: boolean + * description: フォローしているか + * liked_count: + * type: integer + * description: 投稿にいいねされた数 + * likes_count: + * type: integer + * description: 投稿にいいねした数 + * location: + * type: string + * description: 場所 + * name: + * type: string + * description: ニックネーム + * posts_count: + * type: integer + * description: 投稿数 + * username: + * type: string + * description: ユーザー名 + */ + /** * Lists all users * diff --git a/swagger.js b/swagger.js index a7046e3bd..9cb5e8509 100644 --- a/swagger.js +++ b/swagger.js @@ -6,7 +6,9 @@ const yaml = require('js-yaml'); const apiRoot = './src/api/endpoints'; const files = [ - 'auth/session/generate.js' + 'users.js', + 'auth/session/generate.js', + 'auth/session/userkey.js', ]; const errorDefinition = {