Skip to content

Commit d93c10c

Browse files
committed
fix: refactor for CI approved
1 parent 76535ea commit d93c10c

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

__tests__/expose.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ import { IsString } from 'class-validator'
44
import { validationMetadatasToSchemas } from '../src'
55
const { defaultMetadataStorage } = require('class-transformer/cjs/storage')
66

7-
8-
97
// @ts-ignore unused
10-
class User {
8+
class User {
119
@IsString()
1210
id: string
1311

14-
@Expose({ name: 'domain_id'})
12+
@Expose({ name: 'domain_id' })
1513
@IsString()
1614
domainId: string
1715
}

src/index.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,26 @@ export function validationMetadataArrayToSchemas(
6464
isExcluded(propMeta, options) ||
6565
isExcluded({ ...propMeta, target }, options)
6666
)
67-
).map((propMeta) => {
68-
/**
69-
* Retrieves all properties that have the Expose decorator from class-transformer
70-
* and remaps the property names to the names exposed by the Expose decorator.
71-
*/
72-
const exposeMetadata = userOptions?.classTransformerMetadataStorage?.getExposedMetadatas(propMeta.target as any)
67+
)
68+
.map((propMeta) => {
69+
/**
70+
* Retrieves all properties that have the Expose decorator from class-transformer
71+
* and remaps the property names to the names exposed by the Expose decorator.
72+
*/
73+
const exposeMetadata =
74+
userOptions?.classTransformerMetadataStorage?.getExposedMetadatas(
75+
propMeta.target as any
76+
)
7377

74-
const ctMetaForField = ctMetadata?.find((meta: ExposeMetadata) => meta.propertyName == propMeta.propertyName)
78+
const ctMetaForField = exposeMetadata?.find(
79+
(meta: ExposeMetadata) => meta.propertyName === propMeta.propertyName
80+
)
7581

76-
if (ctMetaForField?.options.name) {
77-
propMeta.propertyName = ctMetaForField.options.name;
78-
}
82+
if (ctMetaForField?.options.name) {
83+
propMeta.propertyName = ctMetaForField.options.name
84+
}
7985

80-
return propMeta
86+
return propMeta
8187
})
8288

8389
const properties: { [name: string]: ReferenceObject | SchemaObject } = {}

0 commit comments

Comments
 (0)