[Java][Native] Fix multipart builder files array (#16055) (#16094)

* [Java] Fixed bug in native client generation when API accepts array of files (#16055)

* Adding test for java native client

* Updated samples
This commit is contained in:
Luca
2023-07-24 09:57:21 +02:00
committed by GitHub
parent 0a02860b50
commit 584f8448ee
20 changed files with 1028 additions and 1 deletions

View File

@@ -107,6 +107,7 @@ Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*BodyApi* | [**testBinaryGif**](docs/BodyApi.md#testBinaryGif) | **POST** /binary/gif | Test binary (gif) response body
*BodyApi* | [**testBodyApplicationOctetstreamBinary**](docs/BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s)
*BodyApi* | [**testBodyMultipartFormdataArrayOfBinary**](docs/BodyApi.md#testBodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime
*BodyApi* | [**testEchoBodyFreeFormObjectResponseString**](docs/BodyApi.md#testEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object
*BodyApi* | [**testEchoBodyPet**](docs/BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s)
*BodyApi* | [**testEchoBodyPetResponseString**](docs/BodyApi.md#testEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body

View File

@@ -427,6 +427,27 @@ paths:
tags:
- body
x-accepts: image/gif
/body/application/octetstream/array_of_binary:
post:
description: Test array of binary in multipart mime
operationId: test/body/multipart/formdata/array_of_binary
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/test_body_multipart_formdata_array_of_binary_request'
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test array of binary in multipart mime
tags:
- body
x-content-type: multipart/form-data
x-accepts: text/plain
components:
requestBodies:
Pet:
@@ -657,4 +678,14 @@ components:
allOf:
- $ref: '#/components/schemas/Bird'
- $ref: '#/components/schemas/Category'
test_body_multipart_formdata_array_of_binary_request:
properties:
files:
items:
format: binary
type: string
type: array
required:
- files
type: object

View File

@@ -6,6 +6,7 @@ All URIs are relative to *http://localhost:3000*
|------------- | ------------- | -------------|
| [**testBinaryGif**](BodyApi.md#testBinaryGif) | **POST** /binary/gif | Test binary (gif) response body |
| [**testBodyApplicationOctetstreamBinary**](BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s) |
| [**testBodyMultipartFormdataArrayOfBinary**](BodyApi.md#testBodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime |
| [**testEchoBodyFreeFormObjectResponseString**](BodyApi.md#testEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object |
| [**testEchoBodyPet**](BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s) |
| [**testEchoBodyPetResponseString**](BodyApi.md#testEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body |
@@ -141,6 +142,72 @@ No authorization required
| **200** | Successful operation | - |
## testBodyMultipartFormdataArrayOfBinary
> String testBodyMultipartFormdataArrayOfBinary(files)
Test array of binary in multipart mime
Test array of binary in multipart mime
### Example
```java
// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.models.*;
import org.openapitools.client.api.BodyApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost:3000");
BodyApi apiInstance = new BodyApi(defaultClient);
List<File> files = Arrays.asList(); // List<File> |
try {
String result = apiInstance.testBodyMultipartFormdataArrayOfBinary(files);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BodyApi#testBodyMultipartFormdataArrayOfBinary");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```
### Parameters
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **files** | **List&lt;File&gt;**| | |
### Return type
**String**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Successful operation | - |
## testEchoBodyFreeFormObjectResponseString
> String testEchoBodyFreeFormObjectResponseString(body)

View File

@@ -189,6 +189,82 @@ public class BodyApi {
);
}
/**
* Test array of binary in multipart mime
* Test array of binary in multipart mime
* @param files (required)
* @return String
* @throws ApiException if fails to make API call
*/
public String testBodyMultipartFormdataArrayOfBinary(List<File> files) throws ApiException {
return this.testBodyMultipartFormdataArrayOfBinary(files, Collections.emptyMap());
}
/**
* Test array of binary in multipart mime
* Test array of binary in multipart mime
* @param files (required)
* @param additionalHeaders additionalHeaders for this call
* @return String
* @throws ApiException if fails to make API call
*/
public String testBodyMultipartFormdataArrayOfBinary(List<File> files, Map<String, String> additionalHeaders) throws ApiException {
Object localVarPostBody = null;
// verify the required parameter 'files' is set
if (files == null) {
throw new ApiException(400, "Missing the required parameter 'files' when calling testBodyMultipartFormdataArrayOfBinary");
}
// create path and map variables
String localVarPath = "/body/application/octetstream/array_of_binary";
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarHeaderParams.putAll(additionalHeaders);
if (files != null)
localVarFormParams.put("files", files);
final String[] localVarAccepts = {
"text/plain"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
"multipart/form-data"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { };
TypeReference<String> localVarReturnType = new TypeReference<String>() {};
return apiClient.invokeAPI(
localVarPath,
"POST",
localVarQueryParams,
localVarCollectionQueryParams,
localVarQueryStringJoiner.toString(),
localVarPostBody,
localVarHeaderParams,
localVarCookieParams,
localVarFormParams,
localVarAccept,
localVarContentType,
localVarAuthNames,
localVarReturnType
);
}
/**
* Test free form object
* Test free form object

View File

@@ -427,6 +427,27 @@ paths:
tags:
- body
x-accepts: image/gif
/body/application/octetstream/array_of_binary:
post:
description: Test array of binary in multipart mime
operationId: test/body/multipart/formdata/array_of_binary
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/test_body_multipart_formdata_array_of_binary_request'
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test array of binary in multipart mime
tags:
- body
x-content-type: multipart/form-data
x-accepts: text/plain
components:
requestBodies:
Pet:
@@ -657,4 +678,14 @@ components:
allOf:
- $ref: '#/components/schemas/Bird'
- $ref: '#/components/schemas/Category'
test_body_multipart_formdata_array_of_binary_request:
properties:
files:
items:
format: binary
type: string
type: array
required:
- files
type: object

View File

@@ -72,6 +72,35 @@ public interface BodyApi extends ApiClient.Api {
/**
* Test array of binary in multipart mime
* Test array of binary in multipart mime
* @param files (required)
* @return String
*/
@RequestLine("POST /body/application/octetstream/array_of_binary")
@Headers({
"Content-Type: multipart/form-data",
"Accept: text/plain",
})
String testBodyMultipartFormdataArrayOfBinary(@Param("files") List<File> files);
/**
* Test array of binary in multipart mime
* Similar to <code>testBodyMultipartFormdataArrayOfBinary</code> but it also returns the http response headers .
* Test array of binary in multipart mime
* @param files (required)
* @return A ApiResponse that wraps the response boyd and the http headers.
*/
@RequestLine("POST /body/application/octetstream/array_of_binary")
@Headers({
"Content-Type: multipart/form-data",
"Accept: text/plain",
})
ApiResponse<String> testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(@Param("files") List<File> files);
/**
* Test free form object
* Test free form object

View File

@@ -108,6 +108,8 @@ Class | Method | HTTP request | Description
*BodyApi* | [**testBinaryGifWithHttpInfo**](docs/BodyApi.md#testBinaryGifWithHttpInfo) | **POST** /binary/gif | Test binary (gif) response body
*BodyApi* | [**testBodyApplicationOctetstreamBinary**](docs/BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s)
*BodyApi* | [**testBodyApplicationOctetstreamBinaryWithHttpInfo**](docs/BodyApi.md#testBodyApplicationOctetstreamBinaryWithHttpInfo) | **POST** /body/application/octetstream/binary | Test body parameter(s)
*BodyApi* | [**testBodyMultipartFormdataArrayOfBinary**](docs/BodyApi.md#testBodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime
*BodyApi* | [**testBodyMultipartFormdataArrayOfBinaryWithHttpInfo**](docs/BodyApi.md#testBodyMultipartFormdataArrayOfBinaryWithHttpInfo) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime
*BodyApi* | [**testEchoBodyFreeFormObjectResponseString**](docs/BodyApi.md#testEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object
*BodyApi* | [**testEchoBodyFreeFormObjectResponseStringWithHttpInfo**](docs/BodyApi.md#testEchoBodyFreeFormObjectResponseStringWithHttpInfo) | **POST** /echo/body/FreeFormObject/response_string | Test free form object
*BodyApi* | [**testEchoBodyPet**](docs/BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s)

View File

@@ -427,6 +427,27 @@ paths:
tags:
- body
x-accepts: image/gif
/body/application/octetstream/array_of_binary:
post:
description: Test array of binary in multipart mime
operationId: test/body/multipart/formdata/array_of_binary
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/test_body_multipart_formdata_array_of_binary_request'
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test array of binary in multipart mime
tags:
- body
x-content-type: multipart/form-data
x-accepts: text/plain
components:
requestBodies:
Pet:
@@ -657,4 +678,14 @@ components:
allOf:
- $ref: '#/components/schemas/Bird'
- $ref: '#/components/schemas/Category'
test_body_multipart_formdata_array_of_binary_request:
properties:
files:
items:
format: binary
type: string
type: array
required:
- files
type: object

View File

@@ -8,6 +8,8 @@ All URIs are relative to *http://localhost:3000*
| [**testBinaryGifWithHttpInfo**](BodyApi.md#testBinaryGifWithHttpInfo) | **POST** /binary/gif | Test binary (gif) response body |
| [**testBodyApplicationOctetstreamBinary**](BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s) |
| [**testBodyApplicationOctetstreamBinaryWithHttpInfo**](BodyApi.md#testBodyApplicationOctetstreamBinaryWithHttpInfo) | **POST** /body/application/octetstream/binary | Test body parameter(s) |
| [**testBodyMultipartFormdataArrayOfBinary**](BodyApi.md#testBodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime |
| [**testBodyMultipartFormdataArrayOfBinaryWithHttpInfo**](BodyApi.md#testBodyMultipartFormdataArrayOfBinaryWithHttpInfo) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime |
| [**testEchoBodyFreeFormObjectResponseString**](BodyApi.md#testEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object |
| [**testEchoBodyFreeFormObjectResponseStringWithHttpInfo**](BodyApi.md#testEchoBodyFreeFormObjectResponseStringWithHttpInfo) | **POST** /echo/body/FreeFormObject/response_string | Test free form object |
| [**testEchoBodyPet**](BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s) |
@@ -279,6 +281,140 @@ No authorization required
| **200** | Successful operation | - |
## testBodyMultipartFormdataArrayOfBinary
> String testBodyMultipartFormdataArrayOfBinary(files)
Test array of binary in multipart mime
Test array of binary in multipart mime
### Example
```java
// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.models.*;
import org.openapitools.client.api.BodyApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost:3000");
BodyApi apiInstance = new BodyApi(defaultClient);
List<File> files = Arrays.asList(); // List<File> |
try {
String result = apiInstance.testBodyMultipartFormdataArrayOfBinary(files);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BodyApi#testBodyMultipartFormdataArrayOfBinary");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```
### Parameters
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **files** | **List&lt;File&gt;**| | |
### Return type
**String**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Successful operation | - |
## testBodyMultipartFormdataArrayOfBinaryWithHttpInfo
> ApiResponse<String> testBodyMultipartFormdataArrayOfBinary testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(files)
Test array of binary in multipart mime
Test array of binary in multipart mime
### Example
```java
// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.ApiResponse;
import org.openapitools.client.Configuration;
import org.openapitools.client.models.*;
import org.openapitools.client.api.BodyApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost:3000");
BodyApi apiInstance = new BodyApi(defaultClient);
List<File> files = Arrays.asList(); // List<File> |
try {
ApiResponse<String> response = apiInstance.testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(files);
System.out.println("Status code: " + response.getStatusCode());
System.out.println("Response headers: " + response.getHeaders());
System.out.println("Response body: " + response.getData());
} catch (ApiException e) {
System.err.println("Exception when calling BodyApi#testBodyMultipartFormdataArrayOfBinary");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
System.err.println("Reason: " + e.getResponseBody());
e.printStackTrace();
}
}
}
```
### Parameters
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **files** | **List&lt;File&gt;**| | |
### Return type
ApiResponse<**String**>
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Successful operation | - |
## testEchoBodyFreeFormObjectResponseString
> String testEchoBodyFreeFormObjectResponseString(body)

View File

@@ -24,6 +24,12 @@ import org.openapitools.client.model.Tag;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -229,6 +235,120 @@ public class BodyApi {
}
return localVarRequestBuilder;
}
/**
* Test array of binary in multipart mime
* Test array of binary in multipart mime
* @param files (required)
* @return String
* @throws ApiException if fails to make API call
*/
public String testBodyMultipartFormdataArrayOfBinary(List<File> files) throws ApiException {
ApiResponse<String> localVarResponse = testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(files);
return localVarResponse.getData();
}
/**
* Test array of binary in multipart mime
* Test array of binary in multipart mime
* @param files (required)
* @return ApiResponse&lt;String&gt;
* @throws ApiException if fails to make API call
*/
public ApiResponse<String> testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(List<File> files) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = testBodyMultipartFormdataArrayOfBinaryRequestBuilder(files);
try {
HttpResponse<InputStream> localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("testBodyMultipartFormdataArrayOfBinary", localVarResponse);
}
// for plain text response
if (localVarResponse.headers().map().containsKey("Content-Type") &&
"text/plain".equalsIgnoreCase(localVarResponse.headers().map().get("Content-Type").get(0).split(";")[0].trim())) {
java.util.Scanner s = new java.util.Scanner(localVarResponse.body()).useDelimiter("\\A");
String responseBodyText = s.hasNext() ? s.next() : "";
return new ApiResponse<String>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBodyText
);
} else {
throw new RuntimeException("Error! The response Content-Type is supposed to be `text/plain` but it's not: " + localVarResponse);
}
} finally {
}
} catch (IOException e) {
throw new ApiException(e);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
private HttpRequest.Builder testBodyMultipartFormdataArrayOfBinaryRequestBuilder(List<File> files) throws ApiException {
// verify the required parameter 'files' is set
if (files == null) {
throw new ApiException(400, "Missing the required parameter 'files' when calling testBodyMultipartFormdataArrayOfBinary");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/body/application/octetstream/array_of_binary";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Accept", "text/plain");
MultipartEntityBuilder multiPartBuilder = MultipartEntityBuilder.create();
boolean hasFiles = false;
for (int i=0; i < files.size(); i++) {
multiPartBuilder.addBinaryBody("files", files.get(i));
hasFiles = true;
}
HttpEntity entity = multiPartBuilder.build();
HttpRequest.BodyPublisher formDataPublisher;
if (hasFiles) {
Pipe pipe;
try {
pipe = Pipe.open();
} catch (IOException e) {
throw new RuntimeException(e);
}
new Thread(() -> {
try (OutputStream outputStream = Channels.newOutputStream(pipe.sink())) {
entity.writeTo(outputStream);
} catch (IOException e) {
e.printStackTrace();
}
}).start();
formDataPublisher = HttpRequest.BodyPublishers.ofInputStream(() -> Channels.newInputStream(pipe.source()));
} else {
ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream();
try {
entity.writeTo(formOutputStream);
} catch (IOException e) {
throw new RuntimeException(e);
}
formDataPublisher = HttpRequest.BodyPublishers
.ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray()));
}
localVarRequestBuilder
.header("Content-Type", entity.getContentType().getValue())
.method("POST", formDataPublisher);
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* Test free form object
* Test free form object

View File

@@ -21,7 +21,11 @@ import org.openapitools.client.model.*;
import org.junit.Test;
import org.junit.Ignore;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.util.*;
/**
@@ -279,4 +283,33 @@ public class CustomTest {
Assert.assertEquals("/form/integer/boolean/string", p.path);
Assert.assertEquals("3b\ninteger_form=1337&boolean_form=true&string_form=Hello+World\n0\n\n", p.body);
}
@Test
public void testBodyMultipartFormdataArrayOfBinary() throws ApiException {
File file1 = Objects.requireNonNull(getFile("Hello"));
File file2 = Objects.requireNonNull(getFile("World"));
String response = bodyApi.testBodyMultipartFormdataArrayOfBinary(List.of(file1, file2));
org.openapitools.client.EchoServerResponseParser p = new org.openapitools.client.EchoServerResponseParser(response);
Assert.assertEquals("/body/application/octetstream/array_of_binary", p.path);
Assert.assertTrue(p.body.contains(file1.getName()));
Assert.assertTrue(p.body.contains("Hello"));
Assert.assertTrue(p.body.contains(file2.getName()));
Assert.assertTrue(p.body.contains("World"));
}
private File getFile(String content) {
try {
File tempFile = Files.createTempFile("tempFile", ".txt").toFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
writer.write(content);
writer.close();
return tempFile;
} catch (IOException e) {
return null;
}
}
}

View File

@@ -114,6 +114,7 @@ Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*BodyApi* | [**testBinaryGif**](docs/BodyApi.md#testBinaryGif) | **POST** /binary/gif | Test binary (gif) response body
*BodyApi* | [**testBodyApplicationOctetstreamBinary**](docs/BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s)
*BodyApi* | [**testBodyMultipartFormdataArrayOfBinary**](docs/BodyApi.md#testBodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime
*BodyApi* | [**testEchoBodyFreeFormObjectResponseString**](docs/BodyApi.md#testEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object
*BodyApi* | [**testEchoBodyPet**](docs/BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s)
*BodyApi* | [**testEchoBodyPetResponseString**](docs/BodyApi.md#testEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body

View File

@@ -427,6 +427,27 @@ paths:
tags:
- body
x-accepts: image/gif
/body/application/octetstream/array_of_binary:
post:
description: Test array of binary in multipart mime
operationId: test/body/multipart/formdata/array_of_binary
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/test_body_multipart_formdata_array_of_binary_request'
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test array of binary in multipart mime
tags:
- body
x-content-type: multipart/form-data
x-accepts: text/plain
components:
requestBodies:
Pet:
@@ -657,4 +678,14 @@ components:
allOf:
- $ref: '#/components/schemas/Bird'
- $ref: '#/components/schemas/Category'
test_body_multipart_formdata_array_of_binary_request:
properties:
files:
items:
format: binary
type: string
type: array
required:
- files
type: object

View File

@@ -6,6 +6,7 @@ All URIs are relative to *http://localhost:3000*
|------------- | ------------- | -------------|
| [**testBinaryGif**](BodyApi.md#testBinaryGif) | **POST** /binary/gif | Test binary (gif) response body |
| [**testBodyApplicationOctetstreamBinary**](BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s) |
| [**testBodyMultipartFormdataArrayOfBinary**](BodyApi.md#testBodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime |
| [**testEchoBodyFreeFormObjectResponseString**](BodyApi.md#testEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object |
| [**testEchoBodyPet**](BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s) |
| [**testEchoBodyPetResponseString**](BodyApi.md#testEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body |
@@ -132,6 +133,68 @@ No authorization required
|-------------|-------------|------------------|
| **200** | Successful operation | - |
<a id="testBodyMultipartFormdataArrayOfBinary"></a>
# **testBodyMultipartFormdataArrayOfBinary**
> String testBodyMultipartFormdataArrayOfBinary(files)
Test array of binary in multipart mime
Test array of binary in multipart mime
### Example
```java
// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.models.*;
import org.openapitools.client.api.BodyApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost:3000");
BodyApi apiInstance = new BodyApi(defaultClient);
List<File> files = Arrays.asList(); // List<File> |
try {
String result = apiInstance.testBodyMultipartFormdataArrayOfBinary(files);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BodyApi#testBodyMultipartFormdataArrayOfBinary");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```
### Parameters
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **files** | **List&lt;File&gt;**| | |
### Return type
**String**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Successful operation | - |
<a id="testEchoBodyFreeFormObjectResponseString"></a>
# **testEchoBodyFreeFormObjectResponseString**
> String testEchoBodyFreeFormObjectResponseString(body)

View File

@@ -305,6 +305,133 @@ public class BodyApi {
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
/**
* Build call for testBodyMultipartFormdataArrayOfBinary
* @param files (required)
* @param _callback Callback for upload/download progress
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> Successful operation </td><td> - </td></tr>
</table>
*/
public okhttp3.Call testBodyMultipartFormdataArrayOfBinaryCall(List<File> files, final ApiCallback _callback) throws ApiException {
String basePath = null;
// Operation Servers
String[] localBasePaths = new String[] { };
// Determine Base Path to Use
if (localCustomBaseUrl != null){
basePath = localCustomBaseUrl;
} else if ( localBasePaths.length > 0 ) {
basePath = localBasePaths[localHostIndex];
} else {
basePath = null;
}
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/body/application/octetstream/array_of_binary";
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (files != null) {
localVarFormParams.put("files", files);
}
final String[] localVarAccepts = {
"text/plain"
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {
"multipart/form-data"
};
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
if (localVarContentType != null) {
localVarHeaderParams.put("Content-Type", localVarContentType);
}
String[] localVarAuthNames = new String[] { };
return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call testBodyMultipartFormdataArrayOfBinaryValidateBeforeCall(List<File> files, final ApiCallback _callback) throws ApiException {
// verify the required parameter 'files' is set
if (files == null) {
throw new ApiException("Missing the required parameter 'files' when calling testBodyMultipartFormdataArrayOfBinary(Async)");
}
return testBodyMultipartFormdataArrayOfBinaryCall(files, _callback);
}
/**
* Test array of binary in multipart mime
* Test array of binary in multipart mime
* @param files (required)
* @return String
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> Successful operation </td><td> - </td></tr>
</table>
*/
public String testBodyMultipartFormdataArrayOfBinary(List<File> files) throws ApiException {
ApiResponse<String> localVarResp = testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(files);
return localVarResp.getData();
}
/**
* Test array of binary in multipart mime
* Test array of binary in multipart mime
* @param files (required)
* @return ApiResponse&lt;String&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> Successful operation </td><td> - </td></tr>
</table>
*/
public ApiResponse<String> testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(List<File> files) throws ApiException {
okhttp3.Call localVarCall = testBodyMultipartFormdataArrayOfBinaryValidateBeforeCall(files, null);
Type localVarReturnType = new TypeToken<String>(){}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}
/**
* Test array of binary in multipart mime (asynchronously)
* Test array of binary in multipart mime
* @param files (required)
* @param _callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> Successful operation </td><td> - </td></tr>
</table>
*/
public okhttp3.Call testBodyMultipartFormdataArrayOfBinaryAsync(List<File> files, final ApiCallback<String> _callback) throws ApiException {
okhttp3.Call localVarCall = testBodyMultipartFormdataArrayOfBinaryValidateBeforeCall(files, _callback);
Type localVarReturnType = new TypeToken<String>(){}.getType();
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
/**
* Build call for testEchoBodyFreeFormObjectResponseString
* @param body Free form object (optional)