Open lolekjohn opened 2 years ago
Can you make sure that you have reflect-metadata
in the environment you're running? I've seen cases where reflect-metadata
fails to get the information (because there's no information in the first place, eg: Vite)
Can you make sure that you have
reflect-metadata
in the environment you're running? I've seen cases wherereflect-metadata
fails to get the information (because there's no information in the first place, eg: Vite)
I do have reflect-metadata
package added to the Lambda function. Should that be enough?
It should be enough yes. Is there a reproduce that you can share? I'm not familiar with AWS Lambda at all :(
I had the same issue on the latest version too.
The error:
Cannot determine type metadata of "modes" on class UserVm.
"modes" metadata has been skipped.
Manually provide the "type" metadata to prevent unexpected behavior.
if we try to use https://repl.it, we'll get the same error. See https://replit.com/@micalevisk/trying-automapper#index.ts
But I guess this is due to how Repl.it builds the project. In this case, I'm not sure if we could fix that even tho it works if we use automapper v7
Is there an existing issue for this?
Describe the issue
We are creating a lambda function (using nodejs typscript) and trying to implement the mapper logic. We took the sample implementation from the documentation web page
`import { classes, AutoMap } from '@automapper/classes'; import 'reflect-metadata'; import { createMapper, createMap, typeConverter, namingConventions, CamelCaseNamingConvention, forMember, mapFrom, } from '@automapper/core';
const mapper = createMapper({ strategyInitializer: classes(), namingConventions: new CamelCaseNamingConvention(), });
export class Job { @AutoMap() title!: string;
}
export class Bio { @AutoMap(() => Job) job!: Job;
}
export class User { @AutoMap() firstName!: string;
}
export class BioDto { @AutoMap() jobTitle!: string;
}
export class UserDto { @AutoMap() firstName!: string;
}
createMap( mapper, Bio, BioDto, typeConverter(Date, String, (date) => date.toDateString()) );
createMap( mapper, User, UserDto, forMember( (d) => d.fullName, mapFrom((s) => s.firstName + ' ' + s.lastName) ) );
const user = new User(); user.firstName = 'Chau'; user.lastName = 'Tran'; user.username = 'ctran'; user.password = '123456'; user.bio = new Bio(); user.bio.avatarUrl = 'google.com'; user.bio.birthday = new Date(); user.bio.job = new Job(); user.bio.job.title = 'Developer'; user.bio.job.salary = 99999;
const dto = mapper.map(user, User, UserDto); console.log(user); console.log(dto); `
The response which we get is as below: `Cannot determine type metadata of "title" on class { }. "title" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "salary" on class { }. "salary" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "birthday" on class { }. "birthday" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "avatarUrl" on class { }. "avatarUrl" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "firstName" on class { }. "firstName" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "lastName" on class { }. "lastName" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "username" on class { }. "username" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "jobTitle" on class { }. "jobTitle" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "jobSalary" on class { }. "jobSalary" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "birthday" on class { }. "birthday" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "avatarUrl" on class { }. "avatarUrl" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "firstName" on class { }. "firstName" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "lastName" on class { }. "lastName" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "fullName" on class { }. "fullName" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
Cannot determine type metadata of "username" on class { }. "username" metadata has been skipped. Manually provide the "type" metadata to prevent unexpected behavior.
User { firstName: 'Chau', lastName: 'Tran', username: 'ctran', password: '123456', bio: Bio { avatarUrl: 'google.com', birthday: 2022-04-21T12:04:04.243Z, job: Job { title: 'Developer', salary: 99999 } } } UserDto { bio: BioDto {}, fullName: 'Chau Tran' }`
Models/DTOs/VMs
No response
Mapping configuration
No response
Steps to reproduce
No response
Expected behavior
User Dto object should be populated with all the mapper properties.
Screenshots
No response
Minimum reproduction code
No response
Package
Other package and its version
No response
AutoMapper version
8.0.0
Additional context
No response