forked from loafle/openapi-generator-original
Add a test for BigDecimal parameter in java client (#16263)
* add a test for BigDecimal parameter in java client * update tests
This commit is contained in:
parent
e299382a42
commit
f0b100a9ad
@ -1138,6 +1138,23 @@ paths:
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
/fake/parameter-string-number:
|
||||
get:
|
||||
tags:
|
||||
- another_fake
|
||||
summary: parameter string number
|
||||
operationId: getParameterStringNumber
|
||||
parameters:
|
||||
- name: string_number
|
||||
in: header
|
||||
description: string number
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
format: number
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
/values:
|
||||
get:
|
||||
tags:
|
||||
|
@ -114,6 +114,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
*AnotherFakeApi* | [**getParameterStringNumber**](docs/AnotherFakeApi.md#getParameterStringNumber) | **GET** /fake/parameter-string-number | parameter string number
|
||||
*DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooGet) | **GET** /foo |
|
||||
*FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint
|
||||
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
|
||||
|
@ -1168,6 +1168,26 @@ paths:
|
||||
tags:
|
||||
- fake
|
||||
x-accepts: application/json
|
||||
/fake/parameter-string-number:
|
||||
get:
|
||||
operationId: getParameterStringNumber
|
||||
parameters:
|
||||
- description: string number
|
||||
explode: false
|
||||
in: header
|
||||
name: string_number
|
||||
required: true
|
||||
schema:
|
||||
format: number
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
summary: parameter string number
|
||||
tags:
|
||||
- another_fake
|
||||
x-accepts: application/json
|
||||
/values:
|
||||
get:
|
||||
description: ""
|
||||
|
@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
| Method | HTTP request | Description |
|
||||
|------------- | ------------- | -------------|
|
||||
| [**call123testSpecialTags**](AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags |
|
||||
| [**getParameterStringNumber**](AnotherFakeApi.md#getParameterStringNumber) | **GET** /fake/parameter-string-number | parameter string number |
|
||||
|
||||
|
||||
<a id="call123testSpecialTags"></a>
|
||||
@ -69,3 +70,62 @@ No authorization required
|
||||
|-------------|-------------|------------------|
|
||||
| **200** | successful operation | - |
|
||||
|
||||
<a id="getParameterStringNumber"></a>
|
||||
# **getParameterStringNumber**
|
||||
> getParameterStringNumber(stringNumber)
|
||||
|
||||
parameter string number
|
||||
|
||||
### 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.AnotherFakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
AnotherFakeApi apiInstance = new AnotherFakeApi(defaultClient);
|
||||
BigDecimal stringNumber = new BigDecimal(78); // BigDecimal | string number
|
||||
try {
|
||||
apiInstance.getParameterStringNumber(stringNumber);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling AnotherFakeApi#getParameterStringNumber");
|
||||
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 |
|
||||
|------------- | ------------- | ------------- | -------------|
|
||||
| **stringNumber** | **BigDecimal**| string number | |
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
| **200** | OK | - |
|
||||
|
||||
|
@ -27,6 +27,7 @@ import com.google.gson.reflect.TypeToken;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.client.model.Client;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
@ -195,4 +196,125 @@ public class AnotherFakeApi {
|
||||
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
|
||||
return localVarCall;
|
||||
}
|
||||
/**
|
||||
* Build call for getParameterStringNumber
|
||||
* @param stringNumber string number (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> OK </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public okhttp3.Call getParameterStringNumberCall(BigDecimal stringNumber, 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 = "/fake/parameter-string-number";
|
||||
|
||||
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 (stringNumber != null) {
|
||||
localVarHeaderParams.put("string_number", localVarApiClient.parameterToString(stringNumber));
|
||||
}
|
||||
|
||||
final String[] localVarAccepts = {
|
||||
};
|
||||
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
|
||||
if (localVarAccept != null) {
|
||||
localVarHeaderParams.put("Accept", localVarAccept);
|
||||
}
|
||||
|
||||
final String[] localVarContentTypes = {
|
||||
};
|
||||
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
|
||||
if (localVarContentType != null) {
|
||||
localVarHeaderParams.put("Content-Type", localVarContentType);
|
||||
}
|
||||
|
||||
String[] localVarAuthNames = new String[] { };
|
||||
return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private okhttp3.Call getParameterStringNumberValidateBeforeCall(BigDecimal stringNumber, final ApiCallback _callback) throws ApiException {
|
||||
// verify the required parameter 'stringNumber' is set
|
||||
if (stringNumber == null) {
|
||||
throw new ApiException("Missing the required parameter 'stringNumber' when calling getParameterStringNumber(Async)");
|
||||
}
|
||||
|
||||
return getParameterStringNumberCall(stringNumber, _callback);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* parameter string number
|
||||
*
|
||||
* @param stringNumber string number (required)
|
||||
* @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> OK </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public void getParameterStringNumber(BigDecimal stringNumber) throws ApiException {
|
||||
getParameterStringNumberWithHttpInfo(stringNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* parameter string number
|
||||
*
|
||||
* @param stringNumber string number (required)
|
||||
* @return ApiResponse<Void>
|
||||
* @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> OK </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public ApiResponse<Void> getParameterStringNumberWithHttpInfo(BigDecimal stringNumber) throws ApiException {
|
||||
okhttp3.Call localVarCall = getParameterStringNumberValidateBeforeCall(stringNumber, null);
|
||||
return localVarApiClient.execute(localVarCall);
|
||||
}
|
||||
|
||||
/**
|
||||
* parameter string number (asynchronously)
|
||||
*
|
||||
* @param stringNumber string number (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> OK </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public okhttp3.Call getParameterStringNumberAsync(BigDecimal stringNumber, final ApiCallback<Void> _callback) throws ApiException {
|
||||
|
||||
okhttp3.Call localVarCall = getParameterStringNumberValidateBeforeCall(stringNumber, _callback);
|
||||
localVarApiClient.executeAsync(localVarCall, _callback);
|
||||
return localVarCall;
|
||||
}
|
||||
}
|
||||
|
@ -2,23 +2,31 @@
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.api;
|
||||
|
||||
|
||||
import org.openapitools.client.ApiException;
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.client.model.Client;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.model.Client;
|
||||
|
||||
/** API tests for AnotherFakeApi */
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API tests for AnotherFakeApi
|
||||
*/
|
||||
@Disabled
|
||||
public class AnotherFakeApiTest {
|
||||
|
||||
@ -27,15 +35,27 @@ public class AnotherFakeApiTest {
|
||||
/**
|
||||
* To test special tags
|
||||
*
|
||||
* <p>To test special tags and operation ID starting with number
|
||||
* To test special tags and operation ID starting with number
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void call123testSpecialTagsTest() throws ApiException {
|
||||
Client body = null;
|
||||
Client response = api.call123testSpecialTags(body);
|
||||
|
||||
Client client = null;
|
||||
Client response = api.call123testSpecialTags(client);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* parameter string number
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getParameterStringNumberTest() throws ApiException {
|
||||
BigDecimal stringNumber = null;
|
||||
api.getParameterStringNumber(stringNumber);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user