require('./InitialImports'); // ATTENTION : These lines MUST be the first of this file import swaggerAutogen from 'swagger-autogen'; import { version } from './config/Version'; import Config from './config/Config'; const doc = { info : { title : 'Dojo API', version : version, description: '**Backend API of the Dojo project.**\n\nSee more information about the projet on [Gitlab](https://githepia.hesge.ch/dojo_project/dojo).', license : { name: 'AGPLv3', url : 'https://githepia.hesge.ch/dojo_project/projects/backend/dojobackendapi/-/blob/main/LICENSE' }, contact : { name : 'Michaƫl Minelli', email: 'dojo@minelli.me' } }, servers : [ { url : `http://localhost:${ Config.api.port }/`, description: 'Development' }, { url : `http://dojo-test.edu.hesge.ch/dojo/api/`, description: 'Test (only from HES-GE network)' }, { url : `https://rdps.hesge.ch/dojo/api/`, description: 'Production' } ], tags : [ { name : 'General', description: '' }, { name : 'Session', description: 'Routes that are used to manage the user\'s session' }, { name : 'Gitlab', description: 'Routes that are used to provide Gitlab informations' }, { name : 'Assignment', description: 'Routes that are used to manage assignments' }, { name : 'Exercise', description: 'Routes that are used to manage exercises' } ], consumes : [ 'multipart/form-data' ], produces : [ 'application/json' ], components: { securitySchemes: { 'Clients token' : { type : 'http', scheme : 'bearer', bearerFormat: 'JWT' }, 'ExerciseChecker secret': { type: 'apiKey', in : 'header', name: 'ExerciseSecret' } }, schemas : { DojoBackendResponse: { $timestamp : '717876000000', $code : 200, $description : 'OK', $sessionToken: 'JWT token (for content, see schema named \'SessionTokenJWT\')', $data : {} }, User : { $id : 142, name : 'michael.minelli', mail : 'dojo@minelli.me', $role : { '@enum': [ 'STUDENT', 'TEACHING_STAFF', 'ADMIN' ] }, $gitlabUsername : 'michael.minelli', gitlabLastInfo : {}, $isTeachingStaff: true, $isAdmin : true, $deleted : false, assignments : [ { $ref: '#/components/schemas/Assignment' } ], exercises : [ { $ref: '#/components/schemas/Exercise' } ] }, Assignment : { $name : 'C_Hello_World', $gitlabId : 30992, $gitlabLink : 'https://githepia.hesge.ch/dojo_project', $gitlabCreationInfo: {}, $gitlabLastInfo : {}, $gitlabLastInfoDate: '1992-09-30 19:00:00.000', $published : true, $staff : [ { $ref: '#/components/schemas/User' } ], $exercises : [ { $ref: '#/components/schemas/Exercise' } ] }, Exercise : { $id : 'eb5f2182-f5b1-42a9-80fc-cad384571053', $assignmentName : 'C_Hello_World', $name : 'DojoEx - C_Hello_World - michael.minelli', $gitlabId : 93092, $gitlabLink : 'https://githepia.hesge.ch/dojo_project/dojo', $gitlabCreationInfo: {}, $gitlabLastInfo : {}, $gitlabLastInfoDate: '1992-09-30 19:00:00.000' }, SessionTokenJWT : { $profile: { $ref: '#/components/schemas/User' }, $iat : '1700749215' } } } }; const options = { openapi : '3.1.0', autoHeader: false, autoBody : false }; const outputFile = '../assets/openapi.json'; const routes = [ './routes/*.ts' ]; swaggerAutogen(options)(outputFile, routes, doc);