-
Notifications
You must be signed in to change notification settings - Fork 509
[re]: feat(@nestjs/swagger) add the ability to work with Nest RouterModule. #104
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
Conversation
Hi @shekohex, Many thanks for your hard work :) Will using this integration also honor the ApiDisableEndpoint decorator recently merged? Would love to use the router module to define a private api (used by the spa app with cors disabled, ApiDisableEndpoint) and a public api using Swagger. Regards, |
Hi @thaoula, hmm, I'm a bit confused about the Regards. |
Hi @shekohex, I am not sure how the swagger module identifies the endpoints to list in the swagger UI. However, correct me if I am wrong, I am assuming that the disable endpoint will result in the endpoint being hidden in the swagger UI. The reason for my question is i want to make sure we can mark the endpoints returned by your router as hidden so that they do not appear in the Swagger UI. Hope that makes sense :) |
Hi @kamilmysliwiec |
@shekohex I build your branch and locally running my app with your swagger version.
|
lib/swagger-scanner.ts
Outdated
@@ -18,7 +18,7 @@ export class SwaggerScanner { | |||
const path = metatype | |||
? Reflect.getMetadata(MODULE_PATH, metatype) | |||
: undefined; | |||
this.scanModuleRoutes(routes, path); | |||
return this.scanModuleRoutes(routes, path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @xmlking , thank you for reporting,
it was a silly error, i missed the return here.
so it now should be fixed 😃
@shekohex I am testing locally by cloning your repo and using
After I upgraded your fork with {
"name": "@nestjs/swagger",
"version": "2.2.0",
"description": "Nest - modern, fast, powerful node.js web framework (@swagger)",
"author": "Kamil Mysliwiec",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.json",
"format": "prettier lib/**/*.ts --write",
"precommit": "lint-staged",
"prepublish:next": "npm run build",
"publish:next": "npm publish --access public --tag next",
"prepublish:npm": "npm run build",
"publish:npm": "npm publish --access public"
},
"dependencies": {
"lodash": "^4.17.10",
"path-to-regexp": "^2.2.1",
"swagger-ui-express": "^3.0.8"
},
"devDependencies": {
"@nestjs/common": "^5.1.0",
"@nestjs/core": "^5.1.0",
"@types/node": "^10.5.2",
"fastify-swagger": "^0.12.0",
"husky": "^0.14.3",
"lint-staged": "^7.2.0",
"prettier": "^1.13.7",
"reflect-metadata": "^0.1.12",
"typescript": "2.7.2"
},
"peerDependencies": {
"@nestjs/common": "^5.1.0",
"@nestjs/core": "^5.1.0"
},
"lint-staged": {
"*.ts": [
"prettier --write",
"git add -f"
]
}
} |
@xmlking and as always, thank you for reporting 👍 |
@shekohex appreciate your quick fixes. Expected: @Post()
async create(@Body() createCatDto: CreateCatDto) {
this.catsService.create(createCatDto);
} |
@xmlking can you share your playground (minimal repo) if possibly, so i can test that ? |
@shekohex |
finally i found where the issue is coming from. I am using monorepo style repo. this has You can reproduce it with my final replay repo at https://github.com/xmlking/11-swagger Now i need to figerout how I can keep project root |
Hi @xmlking, thank you for debugging time, but in my opinion that issue is not related to your code / or nest however, that issue IMO, is a typescript configuration problem, but to be fair can you invest more time to test the last version of swagger from @nestjs/swagger with\without my changes, to see if the problem comes from my changes, if not, i think you should open a new issue so we can help with that. and thank you again for your time 😃 |
@shekohex I pulled your latest code any also published NPM module : @xmlking/swagger for easy testing. interestingly it only effect and cause problem when I run |
Thanks @shekohex 👍 Just merged :) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
PR Checklist
Docs have been added / updated (for bug fixes / features)PR Type
What kind of change does this PR introduce?
What is the current behavior?
If we use nest router with swagger module. Swagger module doesn't know the correct routes.
Issue Number: nestjsx/nest-router#3
What is the new behavior?
add the ability to work with Nest RouterModule.
Does this PR introduce a breaking change?
Other information
this PR is a new one of #54 since it was messy there
so @kamilmysliwiec please merge this PR as soon as possible.
Thanks.