mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-03 00:43:46 +00:00
* updating test to use the Java RESTEasy echo api client (#17367) * regenerated samples * set source and target to 1.8 to fix workflow failure, adapted parser
This commit is contained in:
@@ -114,6 +114,8 @@ Class | Method | HTTP request | Description
|
||||
*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* | [**testBodyMultipartFormdataSingleBinary**](docs/BodyApi.md#testBodyMultipartFormdataSingleBinary) | **POST** /body/application/octetstream/single_binary | Test single binary in multipart mime
|
||||
*BodyApi* | [**testBodyMultipartFormdataSingleBinaryWithHttpInfo**](docs/BodyApi.md#testBodyMultipartFormdataSingleBinaryWithHttpInfo) | **POST** /body/application/octetstream/single_binary | Test single binary in multipart mime
|
||||
*BodyApi* | [**testEchoBodyAllOfPet**](docs/BodyApi.md#testEchoBodyAllOfPet) | **POST** /echo/body/allOf/Pet | Test body parameter(s)
|
||||
*BodyApi* | [**testEchoBodyAllOfPetWithHttpInfo**](docs/BodyApi.md#testEchoBodyAllOfPetWithHttpInfo) | **POST** /echo/body/allOf/Pet | Test body parameter(s)
|
||||
*BodyApi* | [**testEchoBodyFreeFormObjectResponseString**](docs/BodyApi.md#testEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object
|
||||
|
||||
@@ -513,6 +513,27 @@ paths:
|
||||
tags:
|
||||
- body
|
||||
x-accepts: image/gif
|
||||
/body/application/octetstream/single_binary:
|
||||
post:
|
||||
description: Test single binary in multipart mime
|
||||
operationId: test/body/multipart/formdata/single_binary
|
||||
requestBody:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
$ref: '#/components/schemas/test_body_multipart_formdata_single_binary_request'
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
description: Successful operation
|
||||
summary: Test single binary in multipart mime
|
||||
tags:
|
||||
- body
|
||||
x-content-type: multipart/form-data
|
||||
x-accepts: text/plain
|
||||
/body/application/octetstream/array_of_binary:
|
||||
post:
|
||||
description: Test array of binary in multipart mime
|
||||
@@ -825,6 +846,12 @@ components:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Bird'
|
||||
- $ref: '#/components/schemas/Category'
|
||||
test_body_multipart_formdata_single_binary_request:
|
||||
properties:
|
||||
my-file:
|
||||
format: binary
|
||||
type: string
|
||||
type: object
|
||||
test_body_multipart_formdata_array_of_binary_request:
|
||||
properties:
|
||||
files:
|
||||
|
||||
@@ -10,6 +10,8 @@ All URIs are relative to *http://localhost:3000*
|
||||
| [**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 |
|
||||
| [**testBodyMultipartFormdataSingleBinary**](BodyApi.md#testBodyMultipartFormdataSingleBinary) | **POST** /body/application/octetstream/single_binary | Test single binary in multipart mime |
|
||||
| [**testBodyMultipartFormdataSingleBinaryWithHttpInfo**](BodyApi.md#testBodyMultipartFormdataSingleBinaryWithHttpInfo) | **POST** /body/application/octetstream/single_binary | Test single binary in multipart mime |
|
||||
| [**testEchoBodyAllOfPet**](BodyApi.md#testEchoBodyAllOfPet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) |
|
||||
| [**testEchoBodyAllOfPetWithHttpInfo**](BodyApi.md#testEchoBodyAllOfPetWithHttpInfo) | **POST** /echo/body/allOf/Pet | Test body parameter(s) |
|
||||
| [**testEchoBodyFreeFormObjectResponseString**](BodyApi.md#testEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object |
|
||||
@@ -417,6 +419,140 @@ No authorization required
|
||||
| **200** | Successful operation | - |
|
||||
|
||||
|
||||
## testBodyMultipartFormdataSingleBinary
|
||||
|
||||
> String testBodyMultipartFormdataSingleBinary(myFile)
|
||||
|
||||
Test single binary in multipart mime
|
||||
|
||||
Test single 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);
|
||||
File myFile = new File("/path/to/file"); // File |
|
||||
try {
|
||||
String result = apiInstance.testBodyMultipartFormdataSingleBinary(myFile);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling BodyApi#testBodyMultipartFormdataSingleBinary");
|
||||
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 |
|
||||
|------------- | ------------- | ------------- | -------------|
|
||||
| **myFile** | **File**| | [optional] |
|
||||
|
||||
### 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 | - |
|
||||
|
||||
## testBodyMultipartFormdataSingleBinaryWithHttpInfo
|
||||
|
||||
> ApiResponse<String> testBodyMultipartFormdataSingleBinary testBodyMultipartFormdataSingleBinaryWithHttpInfo(myFile)
|
||||
|
||||
Test single binary in multipart mime
|
||||
|
||||
Test single 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);
|
||||
File myFile = new File("/path/to/file"); // File |
|
||||
try {
|
||||
ApiResponse<String> response = apiInstance.testBodyMultipartFormdataSingleBinaryWithHttpInfo(myFile);
|
||||
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#testBodyMultipartFormdataSingleBinary");
|
||||
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 |
|
||||
|------------- | ------------- | ------------- | -------------|
|
||||
| **myFile** | **File**| | [optional] |
|
||||
|
||||
### 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 | - |
|
||||
|
||||
|
||||
## testEchoBodyAllOfPet
|
||||
|
||||
> Pet testEchoBodyAllOfPet(pet)
|
||||
|
||||
@@ -349,6 +349,114 @@ public class BodyApi {
|
||||
}
|
||||
return localVarRequestBuilder;
|
||||
}
|
||||
/**
|
||||
* Test single binary in multipart mime
|
||||
* Test single binary in multipart mime
|
||||
* @param myFile (optional)
|
||||
* @return String
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public String testBodyMultipartFormdataSingleBinary(File myFile) throws ApiException {
|
||||
ApiResponse<String> localVarResponse = testBodyMultipartFormdataSingleBinaryWithHttpInfo(myFile);
|
||||
return localVarResponse.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test single binary in multipart mime
|
||||
* Test single binary in multipart mime
|
||||
* @param myFile (optional)
|
||||
* @return ApiResponse<String>
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public ApiResponse<String> testBodyMultipartFormdataSingleBinaryWithHttpInfo(File myFile) throws ApiException {
|
||||
HttpRequest.Builder localVarRequestBuilder = testBodyMultipartFormdataSingleBinaryRequestBuilder(myFile);
|
||||
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("testBodyMultipartFormdataSingleBinary", 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 testBodyMultipartFormdataSingleBinaryRequestBuilder(File myFile) throws ApiException {
|
||||
|
||||
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
|
||||
|
||||
String localVarPath = "/body/application/octetstream/single_binary";
|
||||
|
||||
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
|
||||
|
||||
localVarRequestBuilder.header("Accept", "text/plain");
|
||||
|
||||
MultipartEntityBuilder multiPartBuilder = MultipartEntityBuilder.create();
|
||||
boolean hasFiles = false;
|
||||
multiPartBuilder.addBinaryBody("my-file", myFile);
|
||||
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 body parameter(s)
|
||||
* Test body parameter(s)
|
||||
|
||||
Reference in New Issue
Block a user