Skip to content

command generate-templates is not working #853

@MoJo2600

Description

@MoJo2600

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions