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

command generate-templates is not working #853

Open
MoJo2600 opened this issue Jul 31, 2024 · 4 comments
Open

command generate-templates is not working #853

MoJo2600 opened this issue Jul 31, 2024 · 4 comments

Comments

@MoJo2600
Copy link

I tried to generate the templates with the generate-templates command. I think it is not doing what it is supposed to do. I'm using version 13.0.14.

First try with pnpm:

npx swagger-typescript-api generate-templates -o src/provider/swagger-typescript-api-templates/ --http-client axios throws an error:

✨   swagger-typescript-api(13.0.12),npm/10.7.0 node/v18.20.3 linux x64 workspaces/false,debug mode DISABLED
⭐   start generating source templates ".ejs" for code generator
Error: ENOENT: no such file or directory, scandir '/workspace/backend/node_modules/.pnpm/[email protected]/templates/base'
    at Object.readdirSync (node:fs:1525:3)
    at G.readDir (file:///workspace/backend/node_modules/.pnpm/[email protected]/node_modules/swagger-typescript-api/dist/chunk-IQ7AWJFN.js:59:148)
    at Ke.getTemplateNamesFromDir (file:///workspace/backend/node_modules/.pnpm/[email protected]/node_modules/swagger-typescript-api/dist/chunk-IQ7AWJFN.js:61:3710)
    at Ke.getTemplates (file:///workspace/backend/node_modules/.pnpm/[email protected]/node_modules/swagger-typescript-api/dist/chunk-IQ7AWJFN.js:61:2588)
    at Ke.start (file:///workspace/backend/node_modules/.pnpm/[email protected]/node_modules/swagger-typescript-api/dist/chunk-IQ7AWJFN.js:61:1647)
    at ts (file:///workspace/backend/node_modules/.pnpm/[email protected]/node_modules/swagger-typescript-api/dist/chunk-IQ7AWJFN.js:61:3900)
    at K (file:///workspace/backend/node_modules/.pnpm/[email protected]/node_modules/swagger-typescript-api/dist/cli.js:34:5913) {
  errno: -2,
  syscall: 'scandir',
  code: 'ENOENT',
  path: '/workspace/backend/node_modules/.pnpm/[email protected]/templates/base'

The error is correct, the directory /workspace/backend/node_modules/.pnpm/[email protected]/templates/base does not exist. I think there is an issue with pnpm somehow.

But...

I tried it with npm as well, there the error is different, it does find the base directory in the node_modules package, but:

❯ ./node_modules/.bin/swagger-typescript-api generate-templates
✨   swagger-typescript-api(13.0.14),nodejs(v18.12.0),debug mode DISABLED
⭐   start generating source templates ".ejs" for code generator
Error: ENOENT: no such file or directory, scandir '/home/user/workspace/tmp/templates/base'
    at Object.readdirSync (node:fs:1451:3)
    at G.readDir (file:///home/user/workspace/tmp/node_modules/swagger-typescript-api/dist/chunk-FPPX3UNW.js:59:148)
    at qe.getTemplateNamesFromDir (file:///home/user/workspace/tmp/node_modules/swagger-typescript-api/dist/chunk-FPPX3UNW.js:61:3710)
    at qe.getTemplates (file:///home/user/workspace/tmp/node_modules/swagger-typescript-api/dist/chunk-FPPX3UNW.js:61:2588)
    at qe.start (file:///home/user/workspace/tmp/node_modules/swagger-typescript-api/dist/chunk-FPPX3UNW.js:61:1647)
    at ts (file:///home/user/workspace/tmp/node_modules/swagger-typescript-api/dist/chunk-FPPX3UNW.js:61:3900)
    at K (file:///home/user/workspace/tmp/node_modules/swagger-typescript-api/dist/cli.js:34:5981) {
  errno: -2,
  syscall: 'scandir',
  code: 'ENOENT',
  path: '/home/user/workspace/tmp/templates/base'
}

When I do create the /home/user/workspace/tmp/templates/base directory it asks for the http-clients directory and after that for default directory. Then the command seems to succeed with the message:

❯ ./node_modules/.bin/swagger-typescript-api generate-templates
✨   swagger-typescript-api(13.0.14),nodejs(v18.12.0),debug mode DISABLED
⭐   start generating source templates ".ejs" for code generator

But the directories I created are completely empty.

@toxygene
Copy link

I just encountered this issue as well. I tried a few previous versions of the library and it appears that both problems started with version 13.0.10.

@uwucka
Copy link

uwucka commented Sep 19, 2024

I installed version 12.0.4 and everything worked. For me, the trouble started with version 13
I use Node 20.12.2 and Npm 10.5.0

@niemyjski
Copy link

+1

@smorodin-it
Copy link

same here.

v13.0.23, node 10.16.0, pnpm 9.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants