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

Nodejs generator throws an exception #444

Closed
lowmemory opened this issue Feb 22, 2015 · 2 comments
Closed

Nodejs generator throws an exception #444

lowmemory opened this issue Feb 22, 2015 · 2 comments
Milestone

Comments

@lowmemory
Copy link

I get this exception when I try to generate a nodejs server stub:

image

I'm surprised that no one else generates nodejs stubs.

My test enviroment:
windows 8.1
jdk8
mvn 3.2.3

I think the problem is in NodeJSServerCodegen.java (line 92):
return outputFolder + File.separator + apiPackage().replaceAll(".", File.separator);
It should be replaced with:
return outputFolder + File.separator + apiPackage().replace('.', File.separatorChar);
This was done in others codegen (ex. JavaClientCodegen.java) but not for the nodejs one.

Searching the code I found other parts that need to be fixed:

C:\Users\Marco\Desktop\swagger\swagger-codegen\modules\swagger-codegen\src\main\java\com\wordnik\swagger\codegen\DefaultGenerator.java 15 KB File JAVA 22/02/2015 08:41:55 22/02/2015 08:41:55 22/02/2015 08:41:55 1
156 bundle.put("apiFolder", config.apiPackage().replaceAll(".", "/"));

C:\Users\Marco\Desktop\swagger\swagger-codegen\modules\swagger-codegen\src\main\java\com\wordnik\swagger\codegen\DefaultCodegen.java 31 KB File JAVA 22/02/2015 08:41:55 22/02/2015 08:41:55 22/02/2015 08:41:55 2
104 return outputFolder + "/" + apiPackage().replaceAll(".", "/");
108 return outputFolder + "/" + modelPackage().replaceAll(".", "/");

C:\Users\Marco\Desktop\swagger\swagger-codegen\modules\swagger-codegen\src\main\java\com\wordnik\swagger\codegen\languages\NodeJSServerCodegen.java 4 KB File JAVA 22/02/2015 10:02:53 22/02/2015 08:41:55 22/02/2015 08:41:55 2
92 return outputFolder + File.separator + apiPackage().replaceAll(".", File.separator);
96 return outputFolder + File.separator + modelPackage().replaceAll(".", File.separator);

C:\Users\Marco\Desktop\swagger\swagger-codegen\modules\swagger-codegen\src\main\java\com\wordnik\swagger\codegen\languages\PythonClientCodegen.java 4 KB File JAVA 22/02/2015 08:41:55 22/02/2015 08:41:55 22/02/2015 08:41:55 2
67 return outputFolder + "/" + apiPackage().replaceAll(".", "/");
71 return outputFolder + "/" + modelPackage().replaceAll(".", "/");

The fix is the same for all:
replace
.replaceAll(".", .... );
with:
.replace('.', File.separatorChar);

Bye.

Marco

@fehguy
Copy link
Contributor

fehguy commented Feb 22, 2015

when you make that change, does it work for you?

@fehguy fehguy added this to the v2.1.0-M2 milestone Feb 22, 2015
fehguy added a commit that referenced this issue Feb 22, 2015
@fehguy fehguy closed this as completed Feb 22, 2015
@lowmemory
Copy link
Author

yes, it worked.

I don't think it was an issue related to windows.
I didn't try it on linux or osx but I cannot belive that something like this
"app.apis".replaceAll(".", File.separator);
throws an exception only on windows.

bye

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

No branches or pull requests

2 participants