ojoanalogo / nestjs-redoc

📘 ReDoc frontend for you NestJS swagger API documentation
MIT License
146 stars 55 forks source link

NestJS v7 issue #20

Closed erickalmeidaptc closed 3 years ago

erickalmeidaptc commented 3 years ago

I'm using NestJS 7.5.1.

  "dependencies": {
    "@nestjs/common": "^7.5.1",
    "@nestjs/core": "^7.5.1",
    "@nestjs/platform-express": "^7.5.1",
    "@nestjs/swagger": "^4.6.1",
    "nestjs-redoc": "^1.3.2",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^6.6.3",
    "swagger-ui-express": "^4.1.4"
  },

And I got this error.

src/main.ts:39:36 - error TS2345: Argument of type 'import("/home/erickalmeida/dev/generic-adapter-nest/node_modules/@nestjs/common/interfaces/nest-application.interface").INestApplication' is not assignable to parameter of type 'import("/home/erickalmeida/dev/generic-adapter-nest/node_modules/nestjs-redoc/node_modules/@nestjs/common/interfaces/nest-application.interface").INestApplication'.
  The types returned by 'getHttpAdapter().createMiddlewareFactory(...)' are incompatible between these types.
    Type '((path: string, callback: Function) => any) | Promise<(path: string, callback: Function) => any>' is not assignable to type '(path: string, callback: Function) => any'.
      Type 'Promise<(path: string, callback: Function) => any>' is not assignable to type '(path: string, callback: Function) => any'.
        Type 'Promise<(path: string, callback: Function) => any>' provides no match for the signature '(path: string, callback: Function): any'.

39 await RedocModule.setup('/docs', app, document, redocOptions);

rankery commented 3 years ago

Same there. Really need it and it not working for now.

I researched a bit and there is a chance of error because of old (for now) @nestjs/common - 7.4.2. There was some changes like sse and new fastify version (tell me if i`m wrong) so something was changed.

Not 100% sure that will help but can be easy fix solution

rankery commented 3 years ago

@mxarc So what i did:

  1. Copied ur repo to my project so it will use my latest nestjs modules
  2. Done

Seems like its bug due to new nestjs version. Just updating all dependencies should fix it.

Screenshot from 2020-11-07 01-42-40

gulaandrij commented 3 years ago
    "nestjs-redoc": "1.3.1",

works for me

rankery commented 3 years ago
    "nestjs-redoc": "1.3.1",

works for me

Can u share ur package.json?

Tryed 1.3.1 and still same error

  "dependencies": {
    "@hapi/joi": "^17.1.1",
    "@nestjs/common": "^7.5.1",
    "@nestjs/config": "^0.5.0",
    "@nestjs/core": "^7.5.1",
    "@nestjs/jwt": "^7.2.0",
    "@nestjs/microservices": "^7.5.1",
    "@nestjs/passport": "^7.1.0",
    "@nestjs/platform-express": "^7.5.1",
    "@nestjs/swagger": "^4.7.0",
    "@types/passport-jwt": "^3.0.3",
    "amqp-connection-manager": "^3.2.1",
    "amqplib": "^0.6.0",
    "class-transformer": "^0.3.1",
    "class-validator": "^0.12.2",
    "express": "^4.17.1",
    "nestjs-redoc": "1.3.1",
    "passport": "^0.4.1",
    "passport-jwt": "^4.0.0",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^6.5.4",
    "swagger-ui-express": "^4.1.4"
  },
ojoanalogo commented 3 years ago

@rankery @erickalmeidaptc Please update to the latest version (2.0.3), should work for you now npm i nestjs-redoc@2.0.3