diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache index 43d8f86637b..1c07a748346 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache @@ -49,6 +49,7 @@ public class ApiClient { private boolean lenientOnJson = false; private boolean debugging = false; private Map defaultHeaderMap = new HashMap(); + private String tempFolderPath = null; private Map authentications; @@ -363,6 +364,22 @@ public class ApiClient { return this; } + /** + * The path of temporary folder used to store downloaded files from endpoints + * with file response. The default value is null, i.e. using + * the system's default tempopary folder. + * + * @see https://docs.oracle.com/javase/7/docs/api/java/io/File.html#createTempFile(java.lang.String,%20java.lang.String,%20java.io.File) + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + /** * Format the given parameter object into string. */ @@ -590,7 +607,10 @@ public class ApiClient { prefix = "download-"; } - return File.createTempFile(prefix, suffix); + if (tempFolderPath == null) + return File.createTempFile(prefix, suffix); + else + return File.createTempFile(prefix, suffix, new File(tempFolderPath)); } /** diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java index 777e413e20e..38d6a39cbcc 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java @@ -49,6 +49,7 @@ public class ApiClient { private boolean lenientOnJson = false; private boolean debugging = false; private Map defaultHeaderMap = new HashMap(); + private String tempFolderPath = null; private Map authentications; @@ -362,6 +363,22 @@ public class ApiClient { return this; } + /** + * The path of temporary folder used to store downloaded files from endpoints + * with file response. The default value is null, i.e. using + * the system's default tempopary folder. + * + * @see https://docs.oracle.com/javase/7/docs/api/java/io/File.html#createTempFile(java.lang.String,%20java.lang.String,%20java.io.File) + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + /** * Format the given parameter object into string. */ @@ -589,7 +606,10 @@ public class ApiClient { prefix = "download-"; } - return File.createTempFile(prefix, suffix); + if (tempFolderPath == null) + return File.createTempFile(prefix, suffix); + else + return File.createTempFile(prefix, suffix, new File(tempFolderPath)); } /**