swagger-api / swagger-api/swagger-codegen-generators
Filenames incorrect on windows due to inconsistent use of "/" and File.separator [Windows only, Jersey JAX-RS]
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with DefaultCodegenConfig.java at apiFilename and AbstractJavaJAXRSServerCodegen.java around line 227. Inspect the Factory.mustache branch as well, tracing where '/' is used while constructing or parsing paths. Done means path handling consistently uses File.separator and generated Windows package structures, ignore rules, and filenames no longer cause duplicate classes or compilation issues.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100