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.ts index b589944e38..30966a5e0c 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.ts index 21e28c5654..319a7868b2 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 { 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 { @@ -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 { 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.ts new file mode 100644 index 0000000000..392f330b00 --- /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.json index 33742906f1..b83aa4195d 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" } } ],