tsoa
tsoa copied to clipboard
path-mapping for interface not deeply
Sorting
-
I'm submitting a ...
- [x] bug report
- [ ] feature request
- [ ] support request
-
I confirm that I
- [x] used the search to make sure that a similar issue hasn't already been submit
Expected Behavior
The path-mapping that I set up on tsoa.config.compilerOptions could mapping correctly.
{
"entryFile": "src/index.ts",
"noImplicitAdditionalProperties": "throw-on-extras",
"controllerPathGlobs": ["src/backyard/controller/*"],
"spec": {
"outputDirectory": "build/backyard",
"specVersion": 3,
},
"routes": {
"basePath": "/api/v2/backyard",
"routesDir": "build/backyard",
"authenticationModule": "./authentication.ts"
},
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@public/*": ["src/public/*"],
"@backyard/*": ["src/backyard/*"]
}
}
}
import { Controller, Get, Route } from "tsoa";
import { queryAllListingsInOrder } from "@/src/query";
import { ListingDetailDto } from "@/src/types/listing"; <-- This path could not be found
@Route("listing")
export class ListingController extends Controller {
@Get("")
public async getListings(): Promise<{
listings: Array<ListingDetailDto>;
}> {
const listings = await queryAllListingsInOrder({
page: 1,
pageSize: 6,
}).then((res) => res.payload);
return {
listings,
};
}
}
Current Behavior
The tsoa spec-and-routes
will throw error.
Generate routes error.
GenerateMetadataError: No declarations found for referenced type ListingDetailDto.
at TypeResolver.getModelTypeDeclaration (/Users/liaojiwei/Desktop/funwoo/backyard-api-oas/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:755:19)
at TypeResolver.typeArgumentsToContext (/Users/liaojiwei/Desktop/funwoo/backyard-api-oas/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:880:34)
at TypeResolver.getReferenceType (/Users/liaojiwei/Desktop/funwoo/backyard-api-oas/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:576:14)
at TypeResolver.resolve (/Users/liaojiwei/Desktop/funwoo/backyard-api-oas/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:389:36)
at TypeResolver.resolve (/Users/liaojiwei/Desktop/funwoo/backyard-api-oas/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:374:128)
at /Users/liaojiwei/Desktop/funwoo/backyard-api-oas/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:131:118
at Array.reduce (<anonymous>)
at TypeResolver.resolve (/Users/liaojiwei/Desktop/funwoo/backyard-api-oas/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:130:18)
at TypeResolver.resolve (/Users/liaojiwei/Desktop/funwoo/backyard-api-oas/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:379:118)
at MethodGenerator.Generate (/Users/liaojiwei/Desktop/funwoo/backyard-api-oas/node_modules/@tsoa/cli/dist/metadataGeneration/methodGenerator.js:39:78)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Possible Solution
The currently possible solution, but that was not good enough.
{
"entryFile": "src/index.ts",
"noImplicitAdditionalProperties": "throw-on-extras",
"controllerPathGlobs": ["src/backyard/controller/*"],
"spec": {
"outputDirectory": "build/backyard",
"specVersion": 3,
"securityDefinitions": {
"FUNWOO_AUTH": {
"type": "apiKey",
"name": "x-funwoo-token",
"in": "headers"
}
}
},
"routes": {
"basePath": "/api/v2/backyard",
"routesDir": "build/backyard",
"authenticationModule": "./authentication.ts"
},
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@/src/types/*": ["src/types/*"], <-- add the deep path
"@public/*": ["src/public/*"],
"@backyard/*": ["src/backyard/*"]
}
}
}
Context (Environment)
Version of the library: v4.0.0 Version of NodeJS: v16.13.0
- Confirm you were using yarn not npm: [yarn]
Hello there liaojiwei666 👋
Thank you for opening your very first issue in this project.
We will try to get back to you as soon as we can.👀
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
Is there any known solution to this?
I am running into the same problem.
Would you like to provide a PR?
This is assuming you tried **/*
and tsoa differs from tsc behaviour.
Bump this, same issue
Do you want to send a PR to fix this?
Ran into this issue, Same scenario. Why can't it resolve in the first place?