question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support generic type parameter and return type

See original GitHub issue

Return type: Current only support return Promise<XXX>, when return Promise<Response<XXX>> or Response<XXX>, cli throw error “No matching model found for referenced type T”.

Paramter type: use generic type in parameter can generate definition file, but swagger show parameter’s schema is undefined.

Can you support it? thank you.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:11
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
nenadalmcommented, Jun 1, 2017

I see that support for this was merged, but if I try to use Promise<ResultList<Resource>> I get an error:

$ ./node_modules/.bin/tsoa swagger
There was a problem resolving type of 'T'.
There was a problem resolving type of 'ResultListResource'.
Error: No matching model found for referenced type T

with ResultList being

interface ResultList<T> {
    data: T[],
}

version: tsoa@1.1.8

4reactions
andriykrasnychukcommented, Mar 22, 2019

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using different generic types on a method's argument and ...
You need to explicitly specify the return generic type as a type parameter to the method. Something like:
Read more >
Generic Methods - Java™ Tutorials
Generic methods allow type parameters to be used to express dependencies among the types of one or more arguments to a method and/or...
Read more >
How To Use Generics in TypeScript
TypeScript fully supports generics as a way to introduce type-safety into components that accept arguments and return values whose type will ...
Read more >
Documentation - Generics
A generic class has a similar shape to a generic interface. Generic classes have a generic type parameter list in angle brackets (...
Read more >
4. Generics - Programming C# 8.0 [Book]
You can use a constructed generic type anywhere you would use a normal type. For example, you can use them as the types...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found