Add default definition
This commit is contained in:
		
							parent
							
								
									08aeaf6c64
								
							
						
					
					
						commit
						25b5456a32
					
				
					 1 changed files with 168 additions and 24 deletions
				
			
		
							
								
								
									
										190
									
								
								swagger.js
									
										
									
									
									
								
							
							
						
						
									
										190
									
								
								swagger.js
									
										
									
									
									
								
							|  | @ -11,32 +11,175 @@ const files = [ | |||
|   'auth/session/userkey.js', | ||||
| ]; | ||||
| 
 | ||||
| const errorDefinition = { | ||||
|   'type': 'object', | ||||
|   'properties':{ | ||||
|     'error': { | ||||
|       'type': 'string', | ||||
|       'description': 'Error message' | ||||
| const defaultSwagger = { | ||||
|   "swagger": "2.0", | ||||
|   "info": { | ||||
|     "title": "Misskey API", | ||||
|     "version": "aoi" | ||||
|   }, | ||||
|   "host": "api.misskey.local", | ||||
|   "schemes": [ | ||||
|     "http" | ||||
|   ], | ||||
|   "consumes": [ | ||||
|     "application/x-www-form-urlencoded" | ||||
|   ], | ||||
|   "produces": [ | ||||
|     "application/json" | ||||
|   ], | ||||
|   "definitions": { | ||||
|     "Error": { | ||||
|       "type": "object", | ||||
|       "properties": { | ||||
|         "error": { | ||||
|           "type": "string", | ||||
|           "description": "Error message" | ||||
|         } | ||||
|       } | ||||
| }  | ||||
|     }, | ||||
|     "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": "ユーザー名" | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "Application": { | ||||
|       "type": "object", | ||||
|       "properties": { | ||||
|         "created_at": { | ||||
|           "type": "string", | ||||
|           "format": "date", | ||||
|           "description": "アプリケーションの作成日時" | ||||
|         }, | ||||
|         "user_id": { | ||||
|           "type": "string", | ||||
|           "description": "アプリケーションを作成したユーザーのID" | ||||
|         }, | ||||
|         "name": { | ||||
|           "type": "string", | ||||
|           "description": "アプリケーションの名前" | ||||
|         }, | ||||
|         "description": { | ||||
|           "type": "string", | ||||
|           "description": "アプリケーションの説明" | ||||
|         }, | ||||
|         "permission": { | ||||
|           "type": "array", | ||||
|           "items": { | ||||
|             "type": "string" | ||||
|           }, | ||||
|           "description": "アプリケーションの持つ権限一覧" | ||||
|         }, | ||||
|         "callback_url": { | ||||
|           "type": "string", | ||||
|           "description": "コールバックURL" | ||||
|         }, | ||||
|         "id": { | ||||
|           "type": "string", | ||||
|           "description": "アプリケーションID" | ||||
|         }, | ||||
|         "icon_url": { | ||||
|           "type": "string", | ||||
|           "description": "アプリケーションのアイコンのURL" | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   }, | ||||
|   "responses": {}, | ||||
|   "parameters": {}, | ||||
|   "securityDefinitions": {}, | ||||
|   "tags": [] | ||||
| }; | ||||
| 
 | ||||
| var options = { | ||||
|   swaggerDefinition: { | ||||
|     swagger: '2.0', | ||||
|     info: { | ||||
|       title: 'Misskey API', | ||||
|       version: 'aoi', | ||||
|     }, | ||||
|     host: 'api.misskey.xyz', | ||||
|     schemes: ['https'], | ||||
|     consumes: [ | ||||
|       'application/x-www-form-urlencoded' | ||||
|     ], | ||||
|     produces: [ | ||||
|       'application/json' | ||||
|     ] | ||||
|   }, | ||||
|   swaggerDefinition: defaultSwagger, | ||||
|   apis: [] | ||||
| }; | ||||
| options.apis = files.map(c => {return `${apiRoot}/${c}`;}); | ||||
|  | @ -48,7 +191,8 @@ if(fs.existsSync('.config/config.yml')){ | |||
| } | ||||
| 
 | ||||
| var swaggerSpec = swaggerJSDoc(options); | ||||
| swaggerSpec.definitions.Error = errorDefinition; | ||||
| 
 | ||||
| fs.writeFileSync('api-docs.json', JSON.stringify(swaggerSpec)); | ||||
| 
 | ||||
| console.log(JSON.stringify(swaggerSpec)); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue