docs(backend): Setup swagger-autogen
This commit is contained in:
		
							parent
							
								
									3cd7496989
								
							
						
					
					
						commit
						ab8ece2a76
					
				
					 9 changed files with 929 additions and 19 deletions
				
			
		
							
								
								
									
										28
									
								
								docs/api/generate.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								docs/api/generate.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| import swaggerAutogen from "swagger-autogen"; | ||||
| 
 | ||||
| const doc = { | ||||
|     info: { | ||||
|         version: '0.1.0', | ||||
|         title: 'Dwengo-1 Backend API', | ||||
|         description: 'Dwengo-1 Backend API using Express, based on VZW Dwengo', | ||||
|         license: { | ||||
|             name: 'MIT', | ||||
|             url: 'https://github.com/SELab-2/Dwengo-1/blob/336496ab6352ee3f8bf47490c90b5cf81526cef6/LICENSE' | ||||
|         } | ||||
|     }, | ||||
|     servers: [ | ||||
|         { | ||||
|             url: 'http://localhost:3000/', | ||||
|         }, | ||||
|         { | ||||
|             url: 'https://sel2-1.ugent.be/api' | ||||
|         } | ||||
|     ] | ||||
| }; | ||||
| 
 | ||||
| const outputFile = './swagger.json'; | ||||
| const routes = [ | ||||
|     '../../backend/src/app.ts' | ||||
| ]; | ||||
| 
 | ||||
| swaggerAutogen({ openapi: '3.1.0' })(outputFile, routes, doc); | ||||
							
								
								
									
										712
									
								
								docs/api/swagger.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										712
									
								
								docs/api/swagger.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,712 @@ | |||
| { | ||||
|   "openapi": "3.1.0", | ||||
|   "info": { | ||||
|     "version": "0.1.0", | ||||
|     "title": "Dwengo-1 Backend API", | ||||
|     "description": "Dwengo-1 Backend API using Express, based on VZW Dwengo", | ||||
|     "license": { | ||||
|       "name": "MIT", | ||||
|       "url": "https://github.com/SELab-2/Dwengo-1/blob/336496ab6352ee3f8bf47490c90b5cf81526cef6/LICENSE" | ||||
|     } | ||||
|   }, | ||||
|   "servers": [ | ||||
|     { | ||||
|       "url": "http://localhost:3000/" | ||||
|     }, | ||||
|     { | ||||
|       "url": "https://sel2-1.ugent.be/api" | ||||
|     } | ||||
|   ], | ||||
|   "paths": { | ||||
|     "/": { | ||||
|       "get": { | ||||
|         "description": "", | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/student/": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Student" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/student/{id}": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Student" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/student/{id}/classes": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Student" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/student/{id}/submissions": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Student" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/student/{id}/assignments": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Student" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/student/{id}/groups": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Student" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/group/": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Group" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/group/{id}": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Group" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/group/{id}/question": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Group" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/assignment/": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Assignment" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/assignment/{id}": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Assignment" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/assignment/{id}/submissions": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Assignment" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/assignment/{id}/groups": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Assignment" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/assignment/{id}/questions": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Assignment" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/submission/": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Submission" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/submission/{id}": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Submission" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/class/": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Class" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/class/{id}": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Class" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/class/{id}/invitations": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Class" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/class/{id}/assignments": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Class" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/class/{id}/students": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Class" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/question/": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Question" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/question/{id}": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Question" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/question/{id}/answers": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Question" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/login/": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Login" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/theme/": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Theme" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "language", | ||||
|             "in": "query", | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/theme/{theme}": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Theme" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "theme", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           }, | ||||
|           "404": { | ||||
|             "description": "Not Found" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/learningPath/": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Learning Path" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "hruid", | ||||
|             "in": "query", | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           }, | ||||
|           { | ||||
|             "name": "theme", | ||||
|             "in": "query", | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           }, | ||||
|           { | ||||
|             "name": "search", | ||||
|             "in": "query", | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           }, | ||||
|           { | ||||
|             "name": "language", | ||||
|             "in": "query", | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           }, | ||||
|           "404": { | ||||
|             "description": "Not Found" | ||||
|           }, | ||||
|           "500": { | ||||
|             "description": "Internal Server Error" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/learningObject/": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Learning Object" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "hruid", | ||||
|             "in": "query", | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           }, | ||||
|           { | ||||
|             "name": "full", | ||||
|             "in": "query", | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           }, | ||||
|           { | ||||
|             "name": "language", | ||||
|             "in": "query", | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           }, | ||||
|           "400": { | ||||
|             "description": "Bad Request" | ||||
|           }, | ||||
|           "500": { | ||||
|             "description": "Internal Server Error" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "/learningObject/{hruid}": { | ||||
|       "get": { | ||||
|         "tags": [ | ||||
|           "Learning Object" | ||||
|         ], | ||||
|         "description": "", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "hruid", | ||||
|             "in": "path", | ||||
|             "required": true, | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           }, | ||||
|           { | ||||
|             "name": "language", | ||||
|             "in": "query", | ||||
|             "schema": { | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "description": "OK" | ||||
|           }, | ||||
|           "400": { | ||||
|             "description": "Bad Request" | ||||
|           }, | ||||
|           "500": { | ||||
|             "description": "Internal Server Error" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
							
								
								
									
										14
									
								
								docs/package.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								docs/package.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | |||
| { | ||||
|     "name": "dwengo-1-docs", | ||||
|     "version": "0.0.1", | ||||
|     "description": "Documentation for Dwengo-1", | ||||
|     "private": true, | ||||
|     "scripts": { | ||||
|         "build": "npm run architecture && npm run swagger", | ||||
|         "architecture": "python3 -m venv .venv && source .venv/bin/activate && pip install -r docs/requirements.txt && python docs/architecture/schema.py", | ||||
|         "swagger": "tsx api/generate.ts" | ||||
|     }, | ||||
|     "devDependencies": { | ||||
|         "swagger-autogen": "^2.23.7" | ||||
|     } | ||||
| } | ||||
		Reference in a new issue