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

--template-dir completely ignored by nodejs-server generator. #9941

Closed
enbits opened this issue Dec 19, 2019 · 4 comments
Closed

--template-dir completely ignored by nodejs-server generator. #9941

enbits opened this issue Dec 19, 2019 · 4 comments

Comments

@enbits
Copy link

enbits commented Dec 19, 2019

Description

Can not use custom templates on nodejs-server code generation.

Swagger-codegen version

3.0.14

Swagger declaration file content or url

Tested with the default petstore and several other with the same result.

Command line used for generation
  • swagger-codegen generate -i petstore.json -l nodejs-server -t ./templates --template-engine mustache
Steps to reproduce

Run the following commands

  • wget http://petstore.swagger.io/v2/swagger.json
  • mkdir templates
  • swagger-codegen generate -i swagger.json -l nodejs-server -t ./templates --template-engine mustache

Expected Result:

  • Should return error because no templates files are found

Actual Result:

  • Code is generated, completely ignoring the templates folder. If any template file is included inside the folder (e.g. service.mustache), it is also ignored.

A test with another language to verify that other languages work:

Run the following command:

  • swagger-codegen generate -i swagger.json -l javascript -t ./templates --template-engine mustache

Result:
ERROR io.swagger.codegen.v3.templates.MustacheTemplateEngine - javascript/model.mustache (No such file or directory)

That is the expected result because there is no model.mustache inside the templates.

Suggest a fix/enhancement

It caught my attention that in the resources folder there is a nodejs folder but not a nodejs-server folder; not sure if that's the issue, but there's definitely something fishy going on:

https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/nodejs

@enbits enbits changed the title --template-dir completely ignores nodejs-server generator. --template-dir completely ignored by nodejs-server generator. Dec 19, 2019
@alarm9k
Copy link

alarm9k commented Feb 12, 2020

This also applies to typescript-fetch.

@philippelacoste
Copy link

Should be solved fixing NodeJSServerCodegen as done in AbstractCSharpCodegen

l.293 :
embeddedTemplateDir = templateDir = getTemplateDir();
should be change to ;
if (StringUtils.isBlank(templateDir)) {
embeddedTemplateDir = templateDir = getTemplateDir();
}

Then generation with specific template dir should then be fully functionnal

@hkosova
Copy link

hkosova commented Mar 30, 2020

Duplicate of #8904

@HugoMario
Copy link
Contributor

this has been fixed by swagger-codegen-generators#710 for codegen v3

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