Scheduling infrastructure for absolutely everyone.
fix: event-types controller params validation (#15353)
Morgan7732a22c4957
diff --git a/apps/api/v2/src/ee/event-types/controllers/event-types.controller.e2e-spec.ts b/apps/api/v2/src/ee/event-types/controllers/event-types.controller.e2e-spec.tsindex b589944e38c..30966a5e0c5 100644--- a/apps/api/v2/src/ee/event-types/controllers/event-types.controller.e2e-spec.ts+++ b/apps/api/v2/src/ee/event-types/controllers/event-types.controller.e2e-spec.ts@@ -204,6 +204,16 @@ describe("Event types Endpoints", () => {});});+ it("should return 400 if param event type id is null", async () => {+ const locations = [{ type: "inPerson", address: "123 Main St" }];++ const body: UpdateEventTypeInput = {+ locations,+ };++ return request(app.getHttpServer()).patch(`/api/v2/event-types/null`).send(body).expect(400);+ });+it("should update event type locations", async () => {const locations = [{ type: "inPerson", address: "123 Main St" }];diff --git a/apps/api/v2/src/ee/event-types/controllers/event-types.controller.ts b/apps/api/v2/src/ee/event-types/controllers/event-types.controller.tsindex 21e28c56547..319a7868b24 100644--- a/apps/api/v2/src/ee/event-types/controllers/event-types.controller.ts+++ b/apps/api/v2/src/ee/event-types/controllers/event-types.controller.ts@@ -1,4 +1,5 @@import { CreateEventTypeInput } from "@/ee/event-types/inputs/create-event-type.input";+import { EventTypeIdParams } from "@/ee/event-types/inputs/event-type-id.input";import { GetPublicEventTypeQueryParams } from "@/ee/event-types/inputs/get-public-event-type-query-params.input";import { UpdateEventTypeInput } from "@/ee/event-types/inputs/update-event-type.input";import { CreateEventTypeOutput } from "@/ee/event-types/outputs/create-event-type.output";@@ -30,6 +31,7 @@ import {Delete,Query,InternalServerErrorException,+ ParseIntPipe,} from "@nestjs/common";import { ApiTags as DocsTags } from "@nestjs/swagger";@@ -69,7 +71,9 @@ export class EventTypesController {@Permissions([EVENT_TYPE_READ])@UseGuards(AccessTokenGuard)async getEventType(- @Param("eventTypeId") eventTypeId: string,+ @Param() params: EventTypeIdParams,+ @Param("eventTypeId", ParseIntPipe) eventTypeId: number,+@GetUser() user: UserWithProfile): Promise<GetEventTypeOutput> {const eventType = await this.eventTypesService.getUserEventTypeForAtom(user, Number(eventTypeId));@@ -145,7 +149,8 @@ export class EventTypesController {@UseGuards(AccessTokenGuard)@HttpCode(HttpStatus.OK)async updateEventType(- @Param("eventTypeId") eventTypeId: number,+ @Param() params: EventTypeIdParams,+ @Param("eventTypeId", ParseIntPipe) eventTypeId: number,@Body() body: UpdateEventTypeInput,@GetUser() user: UserWithProfile): Promise<UpdateEventTypeOutput> {@@ -161,7 +166,8 @@ export class EventTypesController {@Permissions([EVENT_TYPE_WRITE])@UseGuards(AccessTokenGuard)async deleteEventType(- @Param("eventTypeId") eventTypeId: number,+ @Param() params: EventTypeIdParams,+ @Param("eventTypeId", ParseIntPipe) eventTypeId: number,@GetUser("id") userId: number): Promise<DeleteEventTypeOutput> {const eventType = await this.eventTypesService.deleteEventType(eventTypeId, userId);diff --git a/apps/api/v2/src/ee/event-types/inputs/event-type-id.input.ts b/apps/api/v2/src/ee/event-types/inputs/event-type-id.input.tsnew file mode 100644index 00000000000..392f330b002--- /dev/null+++ b/apps/api/v2/src/ee/event-types/inputs/event-type-id.input.ts@@ -0,0 +1,6 @@+import { IsNumberString } from "class-validator";++export class EventTypeIdParams {+ @IsNumberString()+ eventTypeId!: number;+}diff --git a/apps/api/v2/swagger/documentation.json b/apps/api/v2/swagger/documentation.jsonindex 33742906f10..b83aa4195da 100644--- a/apps/api/v2/swagger/documentation.json+++ b/apps/api/v2/swagger/documentation.json@@ -634,7 +634,7 @@"required": true,"in": "path","schema": {- "type": "string"+ "type": "number"}}],