[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

@@ -113,6 +113,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 |
@@ -77,3 +78,79 @@ No authorization required
|-------------|-------------|------------------|
| **200** | Successful operation | - |
## 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

@@ -129,4 +129,95 @@ if (stringForm != null)
);
}
/**
* 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 fails to make API call
*/
public String testFormOneof(String form1, Integer form2, String form3, Boolean form4, Long id, String name) throws ApiException {
return this.testFormOneof(form1, form2, form3, form4, id, name, Collections.emptyMap());
}
/**
* 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)
* @param additionalHeaders additionalHeaders for this call
* @return String
* @throws ApiException if fails to make API call
*/
public String testFormOneof(String form1, Integer form2, String form3, Boolean form4, Long id, String name, Map<String, String> additionalHeaders) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/form/oneof";
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 (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 = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
"application/x-www-form-urlencoded"
};
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
);
}
}