From 94f565c0d0c19f6be885926510ae3aad768e24ae Mon Sep 17 00:00:00 2001 From: Clinton Blackburn Date: Thu, 16 May 2024 10:32:47 -0700 Subject: [PATCH] fix: Retain $ref when setting name property Setting the `name` property no longer results in a `$ref` being wrapped in `allOf`. --- lib/services/schema-object-factory.ts | 2 +- test/services/fixtures/create-profile.dto.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/services/schema-object-factory.ts b/lib/services/schema-object-factory.ts index 8c72bd989..4a10643a7 100644 --- a/lib/services/schema-object-factory.ts +++ b/lib/services/schema-object-factory.ts @@ -365,7 +365,7 @@ export class SchemaObjectFactory { if (metadata.isArray) { return this.transformToArraySchemaProperty(metadata, key, { $ref }); } - const keysToRemove = ['type', 'isArray', 'required']; + const keysToRemove = ['type', 'isArray', 'required', 'name']; const validMetadataObject = omit(metadata, keysToRemove); const extraMetadataKeys = Object.keys(validMetadataObject); diff --git a/test/services/fixtures/create-profile.dto.ts b/test/services/fixtures/create-profile.dto.ts index 30ad74935..283e02754 100644 --- a/test/services/fixtures/create-profile.dto.ts +++ b/test/services/fixtures/create-profile.dto.ts @@ -10,7 +10,8 @@ export class CreateProfileDto { lastname: string; @ApiProperty({ - type: () => CreateUserDto + type: () => CreateUserDto, + name: 'parent' }) parent: CreateUserDto; }