Comments (12)
Check out the latest release (2.0.1+). While there isn't a true fix, there's now a way to ignore directories for TypeScript scanning, e.g. in tsoa.json:
{
"swagger": {
...
},
"routes": {
...
},
"ignore": [
"**/node_modules/**"
]
}
My guess is that most folks only want to expose domain-specific models, not interfaces/classes from external libs. That may not be totally true. In any case, this will help you resolve the above issue.
Let me know what you think.
from tsoa.
@myflowpl I had the same issue with Account
model. And the only way to workaround it was renaming the model.
The tricky thing for me was that i had only 1 Account
in the project, but debugging helped me to figure out that the duplication happened because of Account
model in TypeScript library.
Issue happens because TSOA uses TypeScript's Program.getSourceFiles()
to generate metadata, which gives all the source files involved, including libraries.
see https://github.com/lukeautry/tsoa/blob/master/src/metadataGeneration/metadataGenerator.ts#L21
And when TSOA is trying to resolve model type and it finds more than 1 with the same name - it throws an error https://github.com/lukeautry/tsoa/blob/master/src/metadataGeneration/resolveType.ts#L304
I don't see an easy way to resolve this issue.
from tsoa.
Hi, I saw your feature is only to resolve the same model name, but how can i resolve the same namespace definition in different files ?
Thanks in advance.
from tsoa.
Any solution to this? I've tried ignoring the paths in the tsoa config as well as using the @tsoaModel decorator.
UnhandledPromiseRejectionWarning: Error: Multiple matching models found for referenced type Model; please make model names unique. Conflicts found: "/Users/..../node_modules/sequelize/types/lib/model.d.ts"; "/Users/...../node_modules/sequelize-typescript/dist/model/model/model.d.ts".
from tsoa.
See the @tsoamodel feature (new): https://github.com/lukeautry/tsoa#dealing-with-duplicate-model-names
Link moved to:
https://tsoa-community.github.io/docs/faq.html#dealing-with-duplicate-model-names
from tsoa.
I am also getting with @typings
Error: Multiple matching models found for referenced type Response; please make model names unique. Conflicts found: "/usr/local/lib/node_modules/tsoa/node_modules/typescript/lib/lib.d.ts"; "/Users/xxx/node_modules/@types/express-serve-static-core/index.d.ts".
How to fix this?
from tsoa.
@isman-usoh I noticed you tagged this in progress - did you have a solution in the works?
from tsoa.
@amozh thanks for deep explanation of the issue.
I also resolved the problem by renaming the model, right now as a good practice, i call all my models with suffix Model
Location => LocationModel LocationModelRequest, LocationModelResponse
After some time, when the model list got quite big, i found it easier to maintain and read the project structure with suffixes, so it was god workaround for me.
from tsoa.
I'm running into the same issue as @Cidaas above, "Multiple matching models found" for basic typing definitions (String
in this case). I had tsoa package version 1.3.3 but removed and replaced it with version 2.0.1 but still see the same error. Can anyone share suggestions for a workaround, please?
There was a problem resolving type of 'String'.
Error: Multiple matching models found for referenced type String; please make model names unique.
Conflicts found: "/mnt/s/Development/complex-reserve-tsoa/node_modules/typescript/lib/lib.d.ts"; "/mnt/s/Development/complex-reserve-tsoa/node_modules/typescript/lib/lib.d.ts".
from tsoa.
@lukeautry Thanks for the update. That is a step closer and may fully fix the issue for some. In my case I have another bug that has came up, probably need it's own ticket - the error is regarding use of String
types in my models. Looks like we need to add support for String Type in resolveType.js.
Error: No matching model found for referenced type String.
This is thrown from src/metadataGeneration/resolveType.ts (my models have String
types in them). This issue is similar to the Buffer
issue reported here: #38.
I appear to have solved the issue by mapping String to string in resolveType.ts around line 76. Is this the best solution?
if (typeReference.typeName.text === 'String') {
return { dataType: 'string' } as Tsoa.Type;
}
In the mean time I've forked the module for my own use with this fix, but I think this should be handled in tsoa. Edit - I've submitted PR #172
from tsoa.
I am also getting error for Request object
Error: Multiple matching models found for referenced type Request; please make model names
unique. Conflicts found:
"/usr/local/lib/node_modules/tsoa/node_modules/typescript/lib/lib.d.ts";
"/Users/../Projects/.../node_modules/@types/express-serve-static-core/index.d.ts".
My config file. I am using "tsoa": "^2.0.1"
{
"swagger": {
"outputDirectory": "./dist",
"entryFile": "./src/Routers/entryfile.ts",
"basePath": "/v1",
"name": "vimal",
"description": "vimal"
},
"ignore": [
"**/node_modules/**"
]
}
from tsoa.
See the @tsoamodel feature (new): https://github.com/lukeautry/tsoa#dealing-with-duplicate-model-names
from tsoa.
Related Issues (20)
- Can't Handle Optional File Field on multipart/form-data HOT 1
- Proposal/file upload configurations HOT 2
- UnknownType: IndexedAccessType error when using enum to index type object HOT 1
- The latest version 6.1.4 causes new build issues. HOT 10
- Middleware after response HOT 6
- After update 6.1.5 Types of property 'successStatus' are incompatible HOT 16
- Handling parameters that include mapped types with `Date` as a generic argument HOT 1
- ErrorHandlerMiddleware is ignore with 6.1.* HOT 11
- Populate causes error log: Debug Failure. False expression: Node must have a real position for this operation HOT 3
- ' HOT 1
- Treat null values as no value or undefined HOT 2
- jsdoc @example is used for union type but ignored for enum HOT 3
- programmatic way to generate the spec and routes HOT 12
- Custom parameters in controller
- Evaluate @Security in order of definition HOT 1
- AuthenticationMiddleware should also depend on authenticationModule being present HOT 1
- Unable to assign null to properties defined as number | null | undefined after updating to version 6.2.0 HOT 2
- Reasoning for always setting defaultNumberType HOT 1
- Can't send stream to injected error responder when using '@Security()` decorator. (Really I'm just trying to create a plain-text error) HOT 1
- Declare Auth schema without need to implement handlers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tsoa.