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

Filenames incorrect on windows due to inconsistent use of "/" and File.separator [Windows only, Jersey JAX-RS] #626

Open
will-thurman opened this issue Mar 12, 2020 · 3 comments · May be fixed by #632

Comments

@will-thurman
Copy link

As of 1.0.17, becuase the DefaultCodegenConfig#apiFilename method uses File.separator to concatenate the filename, an issue occurs on windows that causes the generator to create files with incorrect package structures. This is a problem because some classes are expected to be in the same package, and this could also break ignore rules, leading to duplicate classes and other compilation issues. In the java JAX-RS generator, we check for a '/', causing the index to be inaccurate on Windows (or any other OS that doesn't use / as the file path separator), resulting in a the substring and replace calls not doing what is intended. The same happens in the Factory.mustache branch of the if statement.

We should use File.separator everywhere we are forming/checking file paths. Otherwise, we run the risk of assuming the OS the project is running on, and breaking compilation due to malformed paths.

@will-thurman
Copy link
Author

@HugoMario the change was made here - was there a reason for the change that I'm overlooking?

@HugoMario
Copy link
Contributor

hi @will-thurman

yes, the key of that change on PR was to fix a conflict with paths on windows.

@will-thurman
Copy link
Author

Ok, I was thinking I would revert that line before making bigger changes but maybe not. I'll update the Jax-RS generator to use the File.separator when checking filenames in this workflow

will-thurman pushed a commit to will-thurman/swagger-codegen-generators that referenced this issue Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants