You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into an issue while working when using the open api lib
@ApiProperty({ type: [String] }) @computed()
public get permissions(): string[] {
return this.permissionRelation.map((p) => p.name)
}
I am getting this error
"message": "Class constructor User cannot be invoked without 'new'",
"name": "TypeError",
"status": 500,
"frames": [
{
"file": "Users/junkaihwong/Projects/kkip-app/node_modules/.pnpm/[email protected][email protected]/node_modules/openapi-metadata/dist/loaders/type.js",
"filePath": "/Users/junkaihwong/Projects/kkip-app/node_modules/.pnpm/[email protected][email protected]/node_modules/openapi-metadata/dist/loaders/type.js",
"line": 104,
"callee": "loadType",
"calleeShort": "loadType",
I've pinpointed the error to the .map function but when i tried swapping .map with any other array iterator but it still gives me the same error. My code runs fine tho. Wondering if it has anything to do with anything the screenshot and is there a quick fix / workaround? Appreciate any help 🙏
Setting up routes and adding controllers and updating the model to use .map() in the User Model
@ApiProperty() @computed()
public get name(): string[] {
return ['hwllo'].map((q) => q)
}
You will be greeted by this error:
"message": "Class constructor User cannot be invoked without 'new'",
"name": "TypeError",
"status": 500,
openapi-typescript version
12.1.3
Node.js version
23.6.0
OS + version
macOS 15.2
Description
I ran into an issue while working when using the open api lib
@ApiProperty({ type: [String] })
@computed()
public get permissions(): string[] {
return this.permissionRelation.map((p) => p.name)
}
I am getting this error
I've pinpointed the error to the .map function but when i tried swapping .map with any other array iterator but it still gives me the same error. My code runs fine tho. Wondering if it has anything to do with anything the screenshot and is there a quick fix / workaround? Appreciate any help 🙏
Reproduction
Reproduce by doing the following:
@ApiProperty()
@computed()
public get name(): string[] {
return ['hwllo'].map((q) => q)
}
You will be greeted by this error:
"message": "Class constructor User cannot be invoked without 'new'",
"name": "TypeError",
"status": 500,
At point 3, the code looks like this: https://github.com/jollyjunkaih/adonis-openapi-bug
Expected result
It's not supposed to fail
Required
npx @redocly/cli@latest lint
)Extra
The text was updated successfully, but these errors were encountered: