forked from loafle/openapi-generator-original
fix cast exception in array default value (java gen) (#16434)
This commit is contained in:
parent
020415facc
commit
b5867ebf2b
@ -986,10 +986,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
final_values.add(element.asText());
|
final_values.add(element.asText());
|
||||||
});
|
});
|
||||||
} else if (schema.getDefault() instanceof Collection) {
|
} else if (schema.getDefault() instanceof Collection) {
|
||||||
var _default = (Collection<String>) schema.getDefault();
|
var _default = (Collection<Object>) schema.getDefault();
|
||||||
List<String> final_values = _values;
|
List<String> final_values = _values;
|
||||||
_default.forEach((element) -> {
|
_default.forEach((element) -> {
|
||||||
final_values.add(element);
|
final_values.add(String.valueOf(element));
|
||||||
});
|
});
|
||||||
} else { // single value
|
} else { // single value
|
||||||
_values = java.util.Collections.singletonList(String.valueOf(schema.getDefault()));
|
_values = java.util.Collections.singletonList(String.valueOf(schema.getDefault()));
|
||||||
|
@ -1155,6 +1155,26 @@ paths:
|
|||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: OK
|
description: OK
|
||||||
|
/fake/parameter-array-number:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- another_fake
|
||||||
|
summary: parameter array number default value
|
||||||
|
operationId: getParameterArrayNumber
|
||||||
|
parameters:
|
||||||
|
- name: array
|
||||||
|
in: header
|
||||||
|
description: array integer
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: integer
|
||||||
|
default:
|
||||||
|
- 1
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: OK
|
||||||
/values:
|
/values:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
|
@ -114,6 +114,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
|
|||||||
Class | Method | HTTP request | Description
|
Class | Method | HTTP request | Description
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
*AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
|
*AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
|
||||||
|
*AnotherFakeApi* | [**getParameterArrayNumber**](docs/AnotherFakeApi.md#getParameterArrayNumber) | **GET** /fake/parameter-array-number | parameter array number default value
|
||||||
*AnotherFakeApi* | [**getParameterStringNumber**](docs/AnotherFakeApi.md#getParameterStringNumber) | **GET** /fake/parameter-string-number | parameter string number
|
*AnotherFakeApi* | [**getParameterStringNumber**](docs/AnotherFakeApi.md#getParameterStringNumber) | **GET** /fake/parameter-string-number | parameter string number
|
||||||
*DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooGet) | **GET** /foo |
|
*DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooGet) | **GET** /foo |
|
||||||
*FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint
|
*FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint
|
||||||
|
@ -1188,6 +1188,29 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- another_fake
|
- another_fake
|
||||||
x-accepts: application/json
|
x-accepts: application/json
|
||||||
|
/fake/parameter-array-number:
|
||||||
|
get:
|
||||||
|
operationId: getParameterArrayNumber
|
||||||
|
parameters:
|
||||||
|
- description: array integer
|
||||||
|
explode: false
|
||||||
|
in: header
|
||||||
|
name: array
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
default:
|
||||||
|
- 1
|
||||||
|
items:
|
||||||
|
type: integer
|
||||||
|
type: array
|
||||||
|
style: simple
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
summary: parameter array number default value
|
||||||
|
tags:
|
||||||
|
- another_fake
|
||||||
|
x-accepts: application/json
|
||||||
/values:
|
/values:
|
||||||
get:
|
get:
|
||||||
description: ""
|
description: ""
|
||||||
|
@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
|
|||||||
| Method | HTTP request | Description |
|
| Method | HTTP request | Description |
|
||||||
|------------- | ------------- | -------------|
|
|------------- | ------------- | -------------|
|
||||||
| [**call123testSpecialTags**](AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags |
|
| [**call123testSpecialTags**](AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags |
|
||||||
|
| [**getParameterArrayNumber**](AnotherFakeApi.md#getParameterArrayNumber) | **GET** /fake/parameter-array-number | parameter array number default value |
|
||||||
| [**getParameterStringNumber**](AnotherFakeApi.md#getParameterStringNumber) | **GET** /fake/parameter-string-number | parameter string number |
|
| [**getParameterStringNumber**](AnotherFakeApi.md#getParameterStringNumber) | **GET** /fake/parameter-string-number | parameter string number |
|
||||||
|
|
||||||
|
|
||||||
@ -70,6 +71,65 @@ No authorization required
|
|||||||
|-------------|-------------|------------------|
|
|-------------|-------------|------------------|
|
||||||
| **200** | successful operation | - |
|
| **200** | successful operation | - |
|
||||||
|
|
||||||
|
<a id="getParameterArrayNumber"></a>
|
||||||
|
# **getParameterArrayNumber**
|
||||||
|
> getParameterArrayNumber(array)
|
||||||
|
|
||||||
|
parameter array number default value
|
||||||
|
|
||||||
|
### 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);
|
||||||
|
List<Integer> array = Arrays.asList(); // List<Integer> | array integer
|
||||||
|
try {
|
||||||
|
apiInstance.getParameterArrayNumber(array);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling AnotherFakeApi#getParameterArrayNumber");
|
||||||
|
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 |
|
||||||
|
|------------- | ------------- | ------------- | -------------|
|
||||||
|
| **array** | [**List<Integer>**](Integer.md)| array integer | |
|
||||||
|
|
||||||
|
### 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 | - |
|
||||||
|
|
||||||
<a id="getParameterStringNumber"></a>
|
<a id="getParameterStringNumber"></a>
|
||||||
# **getParameterStringNumber**
|
# **getParameterStringNumber**
|
||||||
> getParameterStringNumber(stringNumber)
|
> getParameterStringNumber(stringNumber)
|
||||||
|
@ -196,6 +196,127 @@ public class AnotherFakeApi {
|
|||||||
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
|
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
|
||||||
return localVarCall;
|
return localVarCall;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Build call for getParameterArrayNumber
|
||||||
|
* @param array array integer (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 getParameterArrayNumberCall(List<Integer> array, 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-array-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 (array != null) {
|
||||||
|
localVarHeaderParams.put("array", localVarApiClient.parameterToString(array));
|
||||||
|
}
|
||||||
|
|
||||||
|
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 getParameterArrayNumberValidateBeforeCall(List<Integer> array, final ApiCallback _callback) throws ApiException {
|
||||||
|
// verify the required parameter 'array' is set
|
||||||
|
if (array == null) {
|
||||||
|
throw new ApiException("Missing the required parameter 'array' when calling getParameterArrayNumber(Async)");
|
||||||
|
}
|
||||||
|
|
||||||
|
return getParameterArrayNumberCall(array, _callback);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parameter array number default value
|
||||||
|
*
|
||||||
|
* @param array array integer (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 getParameterArrayNumber(List<Integer> array) throws ApiException {
|
||||||
|
getParameterArrayNumberWithHttpInfo(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parameter array number default value
|
||||||
|
*
|
||||||
|
* @param array array integer (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> getParameterArrayNumberWithHttpInfo(List<Integer> array) throws ApiException {
|
||||||
|
okhttp3.Call localVarCall = getParameterArrayNumberValidateBeforeCall(array, null);
|
||||||
|
return localVarApiClient.execute(localVarCall);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parameter array number default value (asynchronously)
|
||||||
|
*
|
||||||
|
* @param array array integer (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 getParameterArrayNumberAsync(List<Integer> array, final ApiCallback<Void> _callback) throws ApiException {
|
||||||
|
|
||||||
|
okhttp3.Call localVarCall = getParameterArrayNumberValidateBeforeCall(array, _callback);
|
||||||
|
localVarApiClient.executeAsync(localVarCall, _callback);
|
||||||
|
return localVarCall;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Build call for getParameterStringNumber
|
* Build call for getParameterStringNumber
|
||||||
* @param stringNumber string number (required)
|
* @param stringNumber string number (required)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user