forked from loafle/openapi-generator-original
Clean up file output handling (#1895)
* Clean up file output handling This attempts to normalize all generators to use OS agnostic File.separator. It also cleans up some areas in code where we replace "." in full file output path with File.separator. We should only be modifying directory names we own, and should avoid modifying anything that can be provided by a user. It would probably be better to use Paths.get(…).toString() in all cases. * Fix missed path separators in java codegen * Adjust Java codegen path replacements * Convert / in full path replacements, as / is forbidden in Windows, and noop elsewhere * Use Paths.get where files are written, to better handle Windows path constraints
This commit is contained in:
committed by
William Cheng
parent
d2769e646e
commit
db9102a440
@@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
@@ -65,7 +66,7 @@ public class ConfigHelp implements Runnable {
|
||||
generatePlainTextHelp(sb, config);
|
||||
|
||||
if (!isEmpty(outputFile)) {
|
||||
File out = new File(outputFile);
|
||||
File out = Paths.get(outputFile).toFile();
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
out.mkdirs();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user