Skip to content

Commit

Permalink
fix: Retain $ref when setting name property
Browse files Browse the repository at this point in the history
Setting the `name` property no longer results in a `$ref` being wrapped in `allOf`.
  • Loading branch information
clintonb committed May 16, 2024
1 parent e6ea29f commit 94f565c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/services/schema-object-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion test/services/fixtures/create-profile.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export class CreateProfileDto {
lastname: string;

@ApiProperty({
type: () => CreateUserDto
type: () => CreateUserDto,
name: 'parent'
})
parent: CreateUserDto;
}

0 comments on commit 94f565c

Please sign in to comment.