nestjs / swagger

OpenAPI (Swagger) module for Nest framework (node.js) :earth_americas:
https://nestjs.com
MIT License
1.68k stars 464 forks source link

Cannot import module containing a class when Nest project parent directory has diacritics in its name #689

Closed ipamo closed 3 years ago

ipamo commented 4 years ago

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

yarn start succeeds when NestJS project is located in ~/repos/typescript-starter, but fails when it is in ~/dépôts/typescript-starter:

Error: Cannot find module '../../../dépôts/typescript-starter/src/cat'.

Notice the reference to src directory (it should be dist). The origin of the problem is in the generated controller (app.controller.js), more specifically on this line:

openapi.ApiResponse({ status: 200, type: require("../../../d\u00E9p\u00F4ts/typescript-starter/src/cat").Cat })

Expected behavior

yarn start succeeds when Nest project is in both locations.

Minimal reproduction of the problem with instructions

Tested from a fresh project cloned from typescript-starter. See this reproduction commit: https://github.com/ipamo/typescript-starter/commit/f8ba00619c224c51e20807c509f630f1cd29f1dd

The bug also appears after upgrading to latest version of dependencies: yarn upgrade --latest

What is the motivation / use case for changing the behavior?

Ability to use nestjs/swagger from within any directory.

Environment


Nest version: 7.1.2 (`nest --version`)


For Tooling issues:
- Node version: v12.16.2  
- Platform: Linux  

Others: Debian 10.3
echo $LANG: fr_FR.UTF-8


kamilmysliwiec commented 4 years ago

Would you like to create a PR for this?

ipamo commented 4 years ago

I don't know how to fix this issue