Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nest Router with Swagger doesn't show correct routes #3

Closed
mentos1386 opened this issue Feb 19, 2018 · 12 comments
Closed

Nest Router with Swagger doesn't show correct routes #3

mentos1386 opened this issue Feb 19, 2018 · 12 comments
Labels
bug Something isn't working

Comments

@mentos1386
Copy link

If we use nest router with swagger module. Swagger module doesn't know the correct routes. Is it even possible to implement this?

@shekohex
Copy link
Member

Hi @mentos1386
the implementation of Nest RouterModule was missing in Swagger Package.
This PR nestjs/swagger#54 will solve the problem.
Thank again for reporting ❤️

@shekohex
Copy link
Member

it is ok now
closing.

@alexvanzyl
Copy link

alexvanzyl commented Mar 24, 2019

Thought this my be related.

I am having an issue with swagger generating routes with regards to nested resource, for example if I have the following routes:

export const routes: Routes = [
  {
    path: '/ninja',
    module: NinjaModule,
    children: [
        { path: ':ninjaId/cats', module: CatsModule },
    ],
  },
];

The generated swagger document will generate the following route where ninjaId is the parent id:

GET ​/ninja​/:ninjaId​/cats

In order to work correctly with the swagger UI what it should generate is the below route (Notice the curly brackets):

GET ​/ninja​/{ninjaId​}/cats

Any ideas?

My dependencies are:

"dependencies": {
    "@nestjs/common": "^6.0.0",
    "@nestjs/core": "^6.0.0",
    "@nestjs/platform-express": "^6.0.0",
    "@nestjs/platform-fastify": "^6.0.1",
    "@nestjs/swagger": "^3.0.1",
    "class-transformer": "^0.2.0",
    "class-validator": "^0.9.1",
    "fastify-swagger": "^2.3.2",
    "nest-router": "^1.0.9",
    "nestjs-config": "^1.3.21",
    "reflect-metadata": "^0.1.12",
    "rimraf": "^2.6.2",
    "rxjs": "^6.3.3"
  },
  "devDependencies": {
    "@types/express": "^4.16.0",
    "@types/jest": "^23.3.13",
    "@types/node": "^10.12.18",
    "@types/supertest": "^2.0.7",
    "@nestjs/testing": "^6.0.0",
    "jest": "^23.6.0",
    "nodemon": "^1.18.9",
    "prettier": "^1.15.3",
    "supertest": "^3.4.1",
    "ts-jest": "^23.10.5",
    "ts-node": "^7.0.1",
    "tsconfig-paths": "^3.7.0",
    "tslint": "5.12.1",
    "typescript": "^3.2.4"
  },

@Joel-Raju
Copy link

I'm facing the same problem as @alexvanzyl

@shekohex
Copy link
Member

@Joel-Raju @alexvanzyl any minimal repository to reproduce that behavior?
I will reopen that issue.

@shekohex shekohex reopened this May 10, 2019
Joel-Raju added a commit to Joel-Raju/nest-router that referenced this issue May 13, 2019
@Joel-Raju
Copy link

@shekohex checkout this example https://github.com/Joel-Raju/nest-router/tree/master/examples/heroes

see the endpoint generated by swagger for /heroes/:heroId/powers

@shekohex
Copy link
Member

@Joel-Raju @alexvanzyl the hot fix is on its way nestjs/swagger#253 😃

@shekohex
Copy link
Member

@Joel-Raju @alexvanzyl it dose not seem to be a hot fix at all 😂 , it just got merged now
please once a new version of @nestjs/swagger package get published, give it another try, so i can close this issue.

thanks :)

@DmytroMysak
Copy link

DmytroMysak commented Mar 5, 2020

Still having the same issue:

router:

  {
    path: '/private',
    module: PrivateModule,
  },
  {
    path: '/public',
    module: PublicModule,
    children: [
      {
        path: '/notifications',
        module: NotificationModule,
      },
    ],
  },
];

In swagger ui I have /notifications API instead of /public/notificatons
image

@steven274
Copy link

I have the same problem with DmytroMysak

@chriskuech
Copy link

@shekohex this appears to still be an issue

@francorosatti
Copy link

francorosatti commented Jul 25, 2023

Hi @chriskuech

@shekohex this appears to still be an issue

I fix it by moving from the nest-router external package to the one included in @nestjs/core as explained in the readme of this project:

As of Nestjs v8.0.0 This module got added into the @nestjs/core. see the docs with that being said, this package is still maintained (for now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants