Issue between TSOA and Sequelize - No matching model found

See original GitHub issue

Hi,

We’re having some serious issues with our Sequelize models and the tsoa swagger/routes generation. The metadata generator fails when we do something as simple as this :

    // Dummy controller
    public userJson(@Request() request: express.Request): User {
        return request.user.toJSON();
    }

Where User is a simple Sequelize model like so :

import { Model } from "sequelize-typescript";
import { Column } from "sequelize-typescript/lib/annotations/Column";

export default class User extends Model<User> {
  /** email id of the user */
  @Column emailId: string;
  /** First name of the user */
  @Column firstName: string;
  /** Lastname of the user */
  @Column lastName: string;
}

When we try generating the routes we get :

There was a problem resolving type of 'SequelizeOrigin'.
There was a problem resolving type of 'Sequelize'.
There was a problem resolving type of 'Model'.
There was a problem resolving type of 'User'.
Generate swagger error.
 Error: No matching model found for referenced type SequelizeOrigin.
    at new GenerateMetadataError (/home/esya/Documents/Git/microservice-tsoa-working/node_modules/tsoa/dist/metadataGeneration/exceptions.js:17:28)
    at getModelTypeDeclaration (/home/esya/Documents/Git/microservice-tsoa-working/node_modules/tsoa/dist/metadataGeneration/resolveType.js:419:15)
    at getReferenceType (/home/esya/Documents/Git/microservice-tsoa-working/node_modules/tsoa/dist/metadataGeneration/resolveType.js:280:25)
    at /home/esya/Documents/Git/microservice-tsoa-working/node_modules/tsoa/dist/metadataGeneration/resolveType.js:572:33
    at Array.forEach (<anonymous>)
    at /home/esya/Documents/Git/microservice-tsoa-working/node_modules/tsoa/dist/metadataGeneration/resolveType.js:570:22
    at Array.forEach (<anonymous>)
    at getModelInheritedProperties (/home/esya/Documents/Git/microservice-tsoa-working/node_modules/tsoa/dist/metadataGeneration/resolveType.js:566:21)
    at getReferenceType (/home/esya/Documents/Git/microservice-tsoa-working/node_modules/tsoa/dist/metadataGeneration/resolveType.js:283:35)
    at resolveType (/home/esya/Documents/Git/microservice-tsoa-working/node_modules/tsoa/dist/metadataGeneration/resolveType.js:95:25)

We’ve found a very very nasty work-around which is to block the typedetection when it reaches “Model” or “SequelizeOrigin” but that means a fork of tsoa with a quick & dirty fix.

Would you have a solution for this? Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
hienqnguyencommented, Mar 15, 2018

I’m running into similar issue but slightly different scenario where my Typescript types are generated from a protobuffer file.

Protobuf file:

syntax = "proto3";
package "mypackage.test";

message User {
   string id = 1;
}

The generated code (using protobufjs) looks like below: compiled.d.ts:

export namespace mypackage {
    namespace test {
        interface IUser {
            id: string;
        }
    }
}

The generated code is in organized into its own npm package, @hien/domain. and used in the controller as:

import proto from "@hien/domain"

class Test extends Controller {

    @Get()
    public async get(): proto.mypackage.test.IUser {
         ...
    }
}

I get Error: No matching module declarations found for proto.

This issue seems related but I can create a separate issue if needed.

Thanks!

1reaction
Superd22commented, Feb 27, 2018

I’m encountering the exact same issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue between TSOA and Sequelize - No matching model found
Hi,. We're having some serious issues with our Sequelize models and the tsoa swagger/routes generation. The metadata generator fails when we ...
Read more >
Model Instances - Sequelize
As you already know, a model is an ES6 class. An instance of the class represents one object from that model (which maps...
Read more >
Swagger, NodeJS, & TypeScript : TSOA - Medium
While the generation of code may not be a fruitful endeavor, the documentation, Swagger UI, produced from the Swagger Schema ( swagger-api.yaml/ ...
Read more >
TSOA "Multiple matching models found for referenced type" on ...
This issue is something that is addressed in TSOA's official docs, where if you have multiple models that share the same name, ...
Read more >
404 | tsoa - GitHub Pages
How to ensure no additional properties come in at runtime #. By default, OpenAPI allows for models to have additionalProperties . If you...
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