From 937fbd041ae5251e6e28732bda7f67bd26642691 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Tue, 28 Jan 2025 15:12:39 +0100 Subject: [PATCH] fix: add missing ApiProperty decorator to patchExternalSettings endpoint --- src/samples/schemas/sample.schema.ts | 8 ++++---- src/users/users.controller.ts | 13 ++++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/samples/schemas/sample.schema.ts b/src/samples/schemas/sample.schema.ts index 857dbf7af..75db3c432 100644 --- a/src/samples/schemas/sample.schema.ts +++ b/src/samples/schemas/sample.schema.ts @@ -16,16 +16,16 @@ export type SampleDocument = SampleClass & Document; timestamps: true, }) export class SampleClass extends OwnableClass { - @ApiHideProperty() - @Prop({ type: String }) - _id: string; - /** * Globally unique identifier of a sample. This could be provided as an input value or generated by the system. */ @Prop({ type: String, unique: true, required: true, default: () => uuidv4() }) sampleId: string; + @ApiHideProperty() + @Prop({ type: String }) + _id: string; + /** * The owner of the sample. */ diff --git a/src/users/users.controller.ts b/src/users/users.controller.ts index 0b63b8367..de2ef0ec8 100644 --- a/src/users/users.controller.ts +++ b/src/users/users.controller.ts @@ -16,6 +16,7 @@ import { ApiBearerAuth, ApiBody, ApiOperation, + ApiParam, ApiResponse, ApiTags, } from "@nestjs/swagger"; @@ -304,11 +305,21 @@ export class UsersController { ability.can(Action.UserUpdateOwn, User) || ability.can(Action.UserUpdateAny, User), ) + @ApiParam({ name: "id", type: String, description: "User ID" }) + @ApiBody({ + schema: { + type: "object", + additionalProperties: true, + example: { field: "setting" }, + description: + "External settings to update. This should be a key-value pair object containing the settings to modify.", + }, + }) @Patch("/:id/settings/external") async patchExternalSettings( @Req() request: Request, @Param("id") id: string, - @Body() externalSettings: Record, + @Body() externalSettings = {}, ): Promise { await this.checkUserAuthorization( request,