diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java index 2435a3170ca..2ed426d43ee 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java @@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory; import java.io.File; +import java.nio.file.Files; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -173,9 +174,7 @@ public static InputOption serverOptions(@SuppressWarnings("unused") String langu protected static File getTmpFolder() { try { - File outputFolder = File.createTempFile("codegen-", "-tmp"); - outputFolder.delete(); - outputFolder.mkdir(); + File outputFolder = Files.createTempDirectory("codegen-").toFile(); outputFolder.deleteOnExit(); return outputFolder; } catch (Exception e) {