diff --git a/src/controllers/ImportController.ts b/src/controllers/ImportController.ts index 8a57a3b..232df6f 100644 --- a/src/controllers/ImportController.ts +++ b/src/controllers/ImportController.ts @@ -22,9 +22,9 @@ export class ImportController { @Post('/runners/import') @ContentType("application/json") - @ResponseSchema(ResponseRunner, { isArray: true }) - @ResponseSchema(RunnerGroupNotFoundError) - @ResponseSchema(RunnerGroupNeededError) + @ResponseSchema(ResponseRunner, { isArray: true, statusCode: 200 }) + @ResponseSchema(RunnerGroupNotFoundError, { statusCode: 404 }) + @ResponseSchema(RunnerGroupNeededError, { statusCode: 406 }) @OpenAPI({ description: "Create new runners from json and insert them (or their teams) into the provided group" }) async postJSON(@Body({ validate: true, type: ImportRunner }) importRunners: ImportRunner[], @QueryParam("group") groupID: number) { if (!groupID) { throw new RunnerGroupNeededError(); } @@ -37,9 +37,9 @@ export class ImportController { @Post('/organisations/:id/import') @ContentType("application/json") - @ResponseSchema(ResponseRunner, { isArray: true }) - @ResponseSchema(RunnerGroupNotFoundError) - @ResponseSchema(RunnerGroupNeededError) + @ResponseSchema(ResponseRunner, { isArray: true, statusCode: 200 }) + @ResponseSchema(RunnerGroupNotFoundError, { statusCode: 404 }) + @ResponseSchema(RunnerGroupNeededError, { statusCode: 406 }) @OpenAPI({ description: "Create new runners from json and insert them (or their teams) into the provided org" }) async postOrgsJSON(@Body({ validate: true, type: ImportRunner }) importRunners: ImportRunner[], @Param('id') id: number) { return await this.postJSON(importRunners, id) @@ -47,9 +47,9 @@ export class ImportController { @Post('/teams/:id/import') @ContentType("application/json") - @ResponseSchema(ResponseRunner, { isArray: true }) - @ResponseSchema(RunnerGroupNotFoundError) - @ResponseSchema(RunnerGroupNeededError) + @ResponseSchema(ResponseRunner, { isArray: true, statusCode: 200 }) + @ResponseSchema(RunnerGroupNotFoundError, { statusCode: 404 }) + @ResponseSchema(RunnerGroupNeededError, { statusCode: 406 }) @OpenAPI({ description: "Create new runners from json and insert them into the provided team" }) async postTeamsJSON(@Body({ validate: true, type: ImportRunner }) importRunners: ImportRunner[], @Param('id') id: number) { return await this.postJSON(importRunners, id) @@ -58,9 +58,9 @@ export class ImportController { @Post('/runners/import/csv') @ContentType("application/json") @UseBefore(RawBodyMiddleware) - @ResponseSchema(ResponseRunner, { isArray: true }) - @ResponseSchema(RunnerGroupNotFoundError) - @ResponseSchema(RunnerGroupNeededError) + @ResponseSchema(ResponseRunner, { isArray: true, statusCode: 200 }) + @ResponseSchema(RunnerGroupNotFoundError, { statusCode: 404 }) + @ResponseSchema(RunnerGroupNeededError, { statusCode: 406 }) @OpenAPI({ description: "Create new runners from csv and insert them (or their teams) into the provided group" }) async postCSV(@Req() request: any, @QueryParam("group") groupID: number) { let csvParse = await csv({ delimiter: [",", ";"], trim: true }).fromString(request.rawBody.toString()); @@ -80,9 +80,9 @@ export class ImportController { @Post('/organisations/:id/import/csv') @ContentType("application/json") @UseBefore(RawBodyMiddleware) - @ResponseSchema(ResponseRunner, { isArray: true }) - @ResponseSchema(RunnerGroupNotFoundError) - @ResponseSchema(RunnerGroupNeededError) + @ResponseSchema(ResponseRunner, { isArray: true, statusCode: 200 }) + @ResponseSchema(RunnerGroupNotFoundError, { statusCode: 404 }) + @ResponseSchema(RunnerGroupNeededError, { statusCode: 406 }) @OpenAPI({ description: "Create new runners from csv and insert them (or their teams) into the provided org" }) async postOrgsCSV(@Req() request: any, @Param("id") id: number) { return await this.postCSV(request, id); @@ -91,9 +91,9 @@ export class ImportController { @Post('/teams/:id/import/csv') @ContentType("application/json") @UseBefore(RawBodyMiddleware) - @ResponseSchema(ResponseRunner, { isArray: true }) - @ResponseSchema(RunnerGroupNotFoundError) - @ResponseSchema(RunnerGroupNeededError) + @ResponseSchema(ResponseRunner, { isArray: true, statusCode: 200 }) + @ResponseSchema(RunnerGroupNotFoundError, { statusCode: 404 }) + @ResponseSchema(RunnerGroupNeededError, { statusCode: 406 }) @OpenAPI({ description: "Create new runners from csv and insert them into the provided team" }) async postTeamsCSV(@Req() request: any, @Param("id") id: number) { return await this.postCSV(request, id);