[java][native] Add tests for oneOf form parameters (#16487)

* add tests for oneOf form parameters

* update samples
This commit is contained in:
William Cheng
2023-09-03 16:15:54 +08:00
committed by GitHub
parent 69c3f567ce
commit ebc9bcda44
23 changed files with 1601 additions and 0 deletions

View File

@@ -120,6 +120,7 @@ Class | Method | HTTP request | Description
*BodyApi* | [**testEchoBodyPetResponseString**](docs/BodyApi.md#testEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body
*BodyApi* | [**testEchoBodyTagResponseString**](docs/BodyApi.md#testEchoBodyTagResponseString) | **POST** /echo/body/Tag/response_string | Test empty json (request body)
*FormApi* | [**testFormIntegerBooleanString**](docs/FormApi.md#testFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s)
*FormApi* | [**testFormOneof**](docs/FormApi.md#testFormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema
*HeaderApi* | [**testHeaderIntegerBooleanString**](docs/HeaderApi.md#testHeaderIntegerBooleanString) | **GET** /header/integer/boolean/string | Test header parameter(s)
*PathApi* | [**testsPathStringPathStringIntegerPathInteger**](docs/PathApi.md#testsPathStringPathStringIntegerPathInteger) | **GET** /path/string/{path_string}/integer/{path_integer} | Test path parameter(s)
*QueryApi* | [**testEnumRefString**](docs/QueryApi.md#testEnumRefString) | **GET** /query/enum_ref_string | Test query parameter(s)

View File

@@ -62,6 +62,27 @@ paths:
- form
x-content-type: application/x-www-form-urlencoded
x-accepts: text/plain
/form/oneof:
post:
description: Test form parameter(s) for oneOf schema
operationId: test/form/oneof
requestBody:
content:
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/test_form_oneof_request'
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test form parameter(s) for oneOf schema
tags:
- form
x-content-type: application/x-www-form-urlencoded
x-accepts: text/plain
/header/integer/boolean/string:
get:
description: Test header parameter(s)
@@ -667,6 +688,26 @@ components:
string_form:
type: string
type: object
test_form_oneof_request_oneOf:
properties:
form1:
type: string
form2:
type: integer
type: object
test_form_oneof_request_oneOf_1:
properties:
form3:
type: string
form4:
type: boolean
type: object
test_form_oneof_request:
oneOf:
- $ref: '#/components/schemas/test_form_oneof_request_oneOf'
- $ref: '#/components/schemas/test_form_oneof_request_oneOf_1'
- $ref: '#/components/schemas/Tag'
type: object
test_query_style_form_explode_true_array_string_query_object_parameter:
properties:
values:

View File

@@ -5,6 +5,7 @@ All URIs are relative to *http://localhost:3000*
| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**testFormIntegerBooleanString**](FormApi.md#testFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s) |
| [**testFormOneof**](FormApi.md#testFormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema |
<a id="testFormIntegerBooleanString"></a>
@@ -73,3 +74,75 @@ No authorization required
|-------------|-------------|------------------|
| **200** | Successful operation | - |
<a id="testFormOneof"></a>
# **testFormOneof**
> String testFormOneof(form1, form2, form3, form4, id, name)
Test form parameter(s) for oneOf schema
Test form parameter(s) for oneOf schema
### 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.FormApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost:3000");
FormApi apiInstance = new FormApi(defaultClient);
String form1 = "form1_example"; // String |
Integer form2 = 56; // Integer |
String form3 = "form3_example"; // String |
Boolean form4 = true; // Boolean |
Long id = 56L; // Long |
String name = "name_example"; // String |
try {
String result = apiInstance.testFormOneof(form1, form2, form3, form4, id, name);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FormApi#testFormOneof");
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 |
|------------- | ------------- | ------------- | -------------|
| **form1** | **String**| | [optional] |
| **form2** | **Integer**| | [optional] |
| **form3** | **String**| | [optional] |
| **form4** | **Boolean**| | [optional] |
| **id** | **Long**| | [optional] |
| **name** | **String**| | [optional] |
### Return type
**String**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Successful operation | - |

View File

@@ -209,4 +209,166 @@ public class FormApi {
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
/**
* Build call for testFormOneof
* @param form1 (optional)
* @param form2 (optional)
* @param form3 (optional)
* @param form4 (optional)
* @param id (optional)
* @param name (optional)
* @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 testFormOneofCall(String form1, Integer form2, String form3, Boolean form4, Long id, String name, 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 = "/form/oneof";
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 (form1 != null) {
localVarFormParams.put("form1", form1);
}
if (form2 != null) {
localVarFormParams.put("form2", form2);
}
if (form3 != null) {
localVarFormParams.put("form3", form3);
}
if (form4 != null) {
localVarFormParams.put("form4", form4);
}
if (id != null) {
localVarFormParams.put("id", id);
}
if (name != null) {
localVarFormParams.put("name", name);
}
final String[] localVarAccepts = {
"text/plain"
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {
"application/x-www-form-urlencoded"
};
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 testFormOneofValidateBeforeCall(String form1, Integer form2, String form3, Boolean form4, Long id, String name, final ApiCallback _callback) throws ApiException {
return testFormOneofCall(form1, form2, form3, form4, id, name, _callback);
}
/**
* Test form parameter(s) for oneOf schema
* Test form parameter(s) for oneOf schema
* @param form1 (optional)
* @param form2 (optional)
* @param form3 (optional)
* @param form4 (optional)
* @param id (optional)
* @param name (optional)
* @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 testFormOneof(String form1, Integer form2, String form3, Boolean form4, Long id, String name) throws ApiException {
ApiResponse<String> localVarResp = testFormOneofWithHttpInfo(form1, form2, form3, form4, id, name);
return localVarResp.getData();
}
/**
* Test form parameter(s) for oneOf schema
* Test form parameter(s) for oneOf schema
* @param form1 (optional)
* @param form2 (optional)
* @param form3 (optional)
* @param form4 (optional)
* @param id (optional)
* @param name (optional)
* @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> testFormOneofWithHttpInfo(String form1, Integer form2, String form3, Boolean form4, Long id, String name) throws ApiException {
okhttp3.Call localVarCall = testFormOneofValidateBeforeCall(form1, form2, form3, form4, id, name, null);
Type localVarReturnType = new TypeToken<String>(){}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}
/**
* Test form parameter(s) for oneOf schema (asynchronously)
* Test form parameter(s) for oneOf schema
* @param form1 (optional)
* @param form2 (optional)
* @param form3 (optional)
* @param form4 (optional)
* @param id (optional)
* @param name (optional)
* @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 testFormOneofAsync(String form1, Integer form2, String form3, Boolean form4, Long id, String name, final ApiCallback<String> _callback) throws ApiException {
okhttp3.Call localVarCall = testFormOneofValidateBeforeCall(form1, form2, form3, form4, id, name, _callback);
Type localVarReturnType = new TypeToken<String>(){}.getType();
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
}