mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 22:50:53 +00:00
This commit is contained in:
parent
c7542dea3e
commit
6fdb632fb9
@ -100,6 +100,54 @@ public class {{classname}} {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
{{#hasParams}}
|
||||
@ -291,13 +339,23 @@ public class {{classname}} {
|
||||
);
|
||||
}
|
||||
|
||||
{{^isResponseFile}}{{#isResponseBinary}}
|
||||
Byte[] responseValue = localVarResponse.body().readAllBytes();
|
||||
{{/isResponseBinary}}{{/isResponseFile}}
|
||||
{{#isResponseFile}}
|
||||
// Handle file downloading.
|
||||
File responseValue = downloadFileFromResponse(localVarResponse);
|
||||
{{/isResponseFile}}
|
||||
{{^isResponseBinary}}{{^isResponseFile}}
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
{{{returnType}}} responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {});
|
||||
{{/isResponseFile}}{{/isResponseBinary}}
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<{{{returnType}}}>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {})
|
||||
responseValue
|
||||
);
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
|
@ -81,6 +81,54 @@ public class AuthApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* To test HTTP basic authentication
|
||||
* To test HTTP basic authentication
|
||||
|
@ -91,6 +91,54 @@ public class BodyApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test binary (gif) response body
|
||||
* Test binary (gif) response body
|
||||
@ -129,13 +177,16 @@ public class BodyApi {
|
||||
);
|
||||
}
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
|
||||
// Handle file downloading.
|
||||
File responseValue = downloadFileFromResponse(localVarResponse);
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<File>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<File>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -514,13 +565,17 @@ public class BodyApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Pet responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Pet>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -681,13 +736,17 @@ public class BodyApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Pet responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Pet>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -848,13 +907,17 @@ public class BodyApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
StringEnumRef responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<StringEnumRef>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<StringEnumRef>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<StringEnumRef>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
|
@ -88,6 +88,54 @@ public class FormApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test form parameter(s)
|
||||
* Test form parameter(s)
|
||||
|
@ -88,6 +88,54 @@ public class HeaderApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test header parameter(s)
|
||||
* Test header parameter(s)
|
||||
|
@ -88,6 +88,54 @@ public class PathApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test path parameter(s)
|
||||
* Test path parameter(s)
|
||||
|
@ -94,6 +94,54 @@ public class QueryApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test query parameter(s)
|
||||
* Test query parameter(s)
|
||||
|
@ -83,6 +83,54 @@ public class AnotherFakeApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* To test special tags
|
||||
* To test special tags and operation ID starting with number
|
||||
|
@ -83,6 +83,54 @@ public class DefaultApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -100,6 +100,54 @@ public class FakeApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* for Java apache and Java native, test toUrlQueryString for maps with BegDecimal keys
|
||||
|
@ -89,6 +89,54 @@ public class FakeClassnameTags123Api {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* To test class name in snake case
|
||||
* To test class name in snake case
|
||||
|
@ -91,6 +91,54 @@ public class PetApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
|
@ -89,6 +89,54 @@ public class StoreApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
|
@ -90,6 +90,54 @@ public class UserApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
|
@ -90,6 +90,54 @@ public class PetApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
@ -130,13 +178,17 @@ public class PetApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Pet responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Pet>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -300,13 +352,17 @@ public class PetApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
List<Pet> responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<Pet>>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<List<Pet>>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<Pet>>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -402,13 +458,17 @@ public class PetApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
List<Pet> responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<Pet>>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<List<Pet>>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<Pet>>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -500,13 +560,17 @@ public class PetApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Pet responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Pet>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -588,13 +652,17 @@ public class PetApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Pet responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Pet>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -778,13 +846,17 @@ public class PetApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
ModelApiResponse responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<ModelApiResponse>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<ModelApiResponse>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<ModelApiResponse>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
|
@ -88,6 +88,54 @@ public class StoreApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
@ -202,13 +250,17 @@ public class StoreApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Map<String, Integer> responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Map<String, Integer>>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Map<String, Integer>>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Map<String, Integer>>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -281,13 +333,17 @@ public class StoreApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Order responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Order>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Order>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Order>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -365,13 +421,17 @@ public class StoreApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Order responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Order>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Order>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Order>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
|
@ -89,6 +89,54 @@ public class UserApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
@ -448,13 +496,17 @@ public class UserApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
User responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<User>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<User>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<User>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -534,13 +586,17 @@ public class UserApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
String responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<String>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<String>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<String>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
|
@ -82,6 +82,54 @@ public class AnotherFakeApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* To test special tags
|
||||
* To test special tags and operation ID starting with number
|
||||
@ -122,13 +170,17 @@ public class AnotherFakeApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Client responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Client>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Client>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Client>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
|
@ -82,6 +82,54 @@ public class DefaultApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@ -120,13 +168,17 @@ public class DefaultApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
FooGetDefaultResponse responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<FooGetDefaultResponse>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<FooGetDefaultResponse>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<FooGetDefaultResponse>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
|
@ -99,6 +99,54 @@ public class FakeApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* for Java apache and Java native, test toUrlQueryString for maps with BegDecimal keys
|
||||
@ -137,13 +185,17 @@ public class FakeApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
FakeBigDecimalMap200Response responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<FakeBigDecimalMap200Response>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<FakeBigDecimalMap200Response>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<FakeBigDecimalMap200Response>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -214,13 +266,17 @@ public class FakeApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
HealthCheckResult responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<HealthCheckResult>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<HealthCheckResult>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<HealthCheckResult>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -293,13 +349,17 @@ public class FakeApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Boolean responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Boolean>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Boolean>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Boolean>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -378,13 +438,17 @@ public class FakeApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
OuterComposite responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<OuterComposite>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<OuterComposite>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<OuterComposite>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -463,13 +527,17 @@ public class FakeApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
BigDecimal responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<BigDecimal>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<BigDecimal>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<BigDecimal>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -548,13 +616,17 @@ public class FakeApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
String responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<String>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<String>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<String>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -626,13 +698,17 @@ public class FakeApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
List<OuterEnum> responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<OuterEnum>>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<List<OuterEnum>>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<OuterEnum>>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -703,13 +779,17 @@ public class FakeApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
List<OuterEnum> responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<OuterEnum>>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<List<OuterEnum>>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<OuterEnum>>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -1046,13 +1126,17 @@ public class FakeApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Client responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Client>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Client>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Client>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
|
@ -88,6 +88,54 @@ public class FakeClassnameTags123Api {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* To test class name in snake case
|
||||
* To test class name in snake case
|
||||
@ -128,13 +176,17 @@ public class FakeClassnameTags123Api {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Client responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Client>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Client>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Client>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
|
@ -90,6 +90,54 @@ public class PetApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
@ -292,13 +340,17 @@ public class PetApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
List<Pet> responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<Pet>>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<List<Pet>>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<Pet>>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -394,13 +446,17 @@ public class PetApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
List<Pet> responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<Pet>>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<List<Pet>>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<Pet>>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -492,13 +548,17 @@ public class PetApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Pet responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Pet>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -758,13 +818,17 @@ public class PetApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
ModelApiResponse responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<ModelApiResponse>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<ModelApiResponse>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<ModelApiResponse>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -882,13 +946,17 @@ public class PetApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
ModelApiResponse responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<ModelApiResponse>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<ModelApiResponse>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<ModelApiResponse>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
|
@ -88,6 +88,54 @@ public class StoreApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
@ -202,13 +250,17 @@ public class StoreApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Map<String, Integer> responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Map<String, Integer>>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Map<String, Integer>>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Map<String, Integer>>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -281,13 +333,17 @@ public class StoreApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Order responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Order>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Order>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Order>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -365,13 +421,17 @@ public class StoreApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
Order responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Order>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<Order>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Order>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
|
@ -89,6 +89,54 @@ public class UserApi {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
@ -448,13 +496,17 @@ public class UserApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
User responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<User>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<User>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<User>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
@ -534,13 +586,17 @@ public class UserApi {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
String responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<String>() {});
|
||||
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<String>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<String>() {})
|
||||
responseValue
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user