forked from loafle/openapi-generator-original
Better handling of parameters in inline model resolver (#19460)
* add tests for parameter ref of oneOf * update samples * better handlding of parameters in inline model resolver
This commit is contained in:
parent
d6780e7d43
commit
9579122945
@ -141,11 +141,15 @@ public class InlineModelResolver {
|
||||
}
|
||||
}
|
||||
|
||||
// flatten path-level parameters
|
||||
flattenParameters(pathname, path.getParameters(), null);
|
||||
|
||||
// flatten parameters for each operation
|
||||
for (Map.Entry<HttpMethod, Operation> operationEntry : toFlatten) {
|
||||
Operation operation = operationEntry.getValue();
|
||||
String inlineSchemaName = this.getInlineSchemaName(operationEntry.getKey(), pathname);
|
||||
flattenRequestBody(inlineSchemaName, operation);
|
||||
flattenParameters(inlineSchemaName, operation);
|
||||
flattenParameters(inlineSchemaName, operation.getParameters(), operation.getOperationId());
|
||||
flattenResponses(inlineSchemaName, operation);
|
||||
}
|
||||
}
|
||||
@ -509,15 +513,20 @@ public class InlineModelResolver {
|
||||
* Flatten inline models in parameters
|
||||
*
|
||||
* @param modelName model name
|
||||
* @param operation target operation
|
||||
* @param parameters list of parameters
|
||||
* @param operationId operation Id (optional)
|
||||
*/
|
||||
private void flattenParameters(String modelName, Operation operation) {
|
||||
List<Parameter> parameters = operation.getParameters();
|
||||
private void flattenParameters(String modelName, List<Parameter> parameters, String operationId) {
|
||||
//List<Parameter> parameters = operation.getParameters();
|
||||
if (parameters == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Parameter parameter : parameters) {
|
||||
if (StringUtils.isNotEmpty(parameter.get$ref())) {
|
||||
parameter = ModelUtils.getReferencedParameter(openAPI, parameter);
|
||||
}
|
||||
|
||||
if (parameter.getSchema() == null) {
|
||||
continue;
|
||||
}
|
||||
@ -528,7 +537,7 @@ public class InlineModelResolver {
|
||||
continue;
|
||||
}
|
||||
String schemaName = resolveModelName(parameterSchema.getTitle(),
|
||||
(operation.getOperationId() == null ? modelName : operation.getOperationId()) + "_" + parameter.getName() + "_parameter");
|
||||
(operationId == null ? modelName : operationId) + "_" + parameter.getName() + "_parameter");
|
||||
// Recursively gather/make inline models within this schema if any
|
||||
gatherInlineModels(parameterSchema, schemaName);
|
||||
if (isModelNeeded(parameterSchema)) {
|
||||
|
@ -411,9 +411,7 @@ public class OpenAPINormalizer {
|
||||
parameter = ModelUtils.getReferencedParameter(openAPI, parameter);
|
||||
}
|
||||
|
||||
if (parameter.getSchema() == null) {
|
||||
continue;
|
||||
} else {
|
||||
if (parameter.getSchema() != null) {
|
||||
Schema newSchema = normalizeSchema(parameter.getSchema(), new HashSet<>());
|
||||
parameter.setSchema(newSchema);
|
||||
}
|
||||
|
@ -704,7 +704,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
propertyHash.put(property.name, property);
|
||||
final CodegenProperty parentVar = property.clone();
|
||||
parentVar.isInherited = true;
|
||||
LOGGER.info("adding parent variable {} to {}", property.name, codegenModel.name);
|
||||
LOGGER.debug("adding parent variable {} to {}", property.name, codegenModel.name);
|
||||
codegenModel.parentVars.add(parentVar);
|
||||
Set<String> imports = parentVar.getImports(true, this.importBaseType, generatorMetadata.getFeatureSet()).stream().filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
for (String imp : imports) {
|
||||
|
@ -1340,7 +1340,7 @@ paths:
|
||||
post:
|
||||
tags:
|
||||
- fake
|
||||
summary: fake uploads an image with ref request bodies
|
||||
summary: fake reference parameter
|
||||
description: ''
|
||||
operationId: fake-upload-ref-request-bodies
|
||||
parameters:
|
||||
@ -1364,7 +1364,18 @@ paths:
|
||||
- 'read:pets'
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/upload_body'
|
||||
|
||||
'/fake/pet/{petId}/reference/parameter':
|
||||
post:
|
||||
tags:
|
||||
- fake
|
||||
summary: fake reference parameter
|
||||
description: ''
|
||||
operationId: fake-ref-parameter
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/pet_id'
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
/values:
|
||||
get:
|
||||
tags:
|
||||
@ -1423,6 +1434,16 @@ servers:
|
||||
- url: https://127.0.0.1/no_variable
|
||||
description: The local server without variables
|
||||
components:
|
||||
parameters:
|
||||
pet_id:
|
||||
name: petId
|
||||
in: path
|
||||
description: to test oneOf in parameter $ref
|
||||
required: true
|
||||
schema:
|
||||
oneOf:
|
||||
- type: string
|
||||
- type: integer
|
||||
requestBodies:
|
||||
upload_body:
|
||||
content:
|
||||
|
@ -609,6 +609,28 @@ paths:
|
||||
$ref: '#/components/responses/ref'
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/ref_to_uuid'
|
||||
/ref/ref_to_path_level_parameter_oneof:
|
||||
get:
|
||||
description: to test $ref to path level parameters
|
||||
operationId: ref_to_ref_parameter_oneof
|
||||
tags:
|
||||
- fake
|
||||
responses:
|
||||
'200':
|
||||
description: Successful Response
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/ref_to_oneof'
|
||||
/ref/ref_to_operation_level_parameter_oneof:
|
||||
get:
|
||||
description: to test $ref to operation level parameters
|
||||
operationId: ref_to_ref_parameter_anyof
|
||||
tags:
|
||||
- fake
|
||||
responses:
|
||||
'200':
|
||||
description: Successful Response
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/ref_to_anyof'
|
||||
"/fake/api/changeowner":
|
||||
post:
|
||||
summary: op1
|
||||
@ -720,6 +742,26 @@ components:
|
||||
type: string
|
||||
format: uuid
|
||||
example: 61864654-6e6b-4152-a62f-795fdd606bc2
|
||||
ref_to_oneof:
|
||||
description: to test ref to parameter (oneof)
|
||||
name: ref_to_oneof
|
||||
in: header
|
||||
required: true
|
||||
schema:
|
||||
oneOf:
|
||||
- type: string
|
||||
- type: integer
|
||||
ref_to_anyof:
|
||||
description: to test ref to parameter (anyof)
|
||||
name: ref_to_anyof
|
||||
in: header
|
||||
required: true
|
||||
schema:
|
||||
oneOf:
|
||||
- type: string
|
||||
- type: array
|
||||
items:
|
||||
type: string
|
||||
requestBodies:
|
||||
UserArray:
|
||||
content:
|
||||
@ -1023,4 +1065,4 @@ components:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/SimpleModelWithArrayProperty'
|
||||
myObject:
|
||||
type: object
|
||||
type: object
|
||||
|
@ -22,6 +22,8 @@ docs/OneOfStringOrInt.md
|
||||
docs/Order.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/RefRefToPathLevelParameterOneofRefToOneofParameter.md
|
||||
docs/RefToRefParameterAnyofRefToAnyofParameter.md
|
||||
docs/SimpleModelWithArrayProperty.md
|
||||
docs/StoreApi.md
|
||||
docs/StringOrInt.md
|
||||
@ -78,6 +80,8 @@ src/main/java/org/openapitools/client/model/ModelApiResponse.java
|
||||
src/main/java/org/openapitools/client/model/OneOfStringOrInt.java
|
||||
src/main/java/org/openapitools/client/model/Order.java
|
||||
src/main/java/org/openapitools/client/model/Pet.java
|
||||
src/main/java/org/openapitools/client/model/RefRefToPathLevelParameterOneofRefToOneofParameter.java
|
||||
src/main/java/org/openapitools/client/model/RefToRefParameterAnyofRefToAnyofParameter.java
|
||||
src/main/java/org/openapitools/client/model/SimpleModelWithArrayProperty.java
|
||||
src/main/java/org/openapitools/client/model/StringOrInt.java
|
||||
src/main/java/org/openapitools/client/model/Tag.java
|
||||
|
@ -120,6 +120,8 @@ Class | Method | HTTP request | Description
|
||||
*FakeApi* | [**op2**](docs/FakeApi.md#op2) | **POST** /fake/api/changename | op2
|
||||
*FakeApi* | [**op3**](docs/FakeApi.md#op3) | **POST** /fake/api/query/enum | op3
|
||||
*FakeApi* | [**refToRefParameter**](docs/FakeApi.md#refToRefParameter) | **GET** /ref/ref_to_parameter |
|
||||
*FakeApi* | [**refToRefParameterAnyof**](docs/FakeApi.md#refToRefParameterAnyof) | **GET** /ref/ref_to_operation_level_parameter_oneof |
|
||||
*FakeApi* | [**refToRefParameterOneof**](docs/FakeApi.md#refToRefParameterOneof) | **GET** /ref/ref_to_path_level_parameter_oneof |
|
||||
*FakeApi* | [**responseNoRef**](docs/FakeApi.md#responseNoRef) | **GET** /no_ref |
|
||||
*FakeApi* | [**responseRefToNoRef**](docs/FakeApi.md#responseRefToNoRef) | **GET** /ref/no_ref |
|
||||
*FakeApi* | [**responseRefToRef**](docs/FakeApi.md#responseRefToRef) | **GET** /ref/ref |
|
||||
@ -162,6 +164,8 @@ Class | Method | HTTP request | Description
|
||||
- [OneOfStringOrInt](docs/OneOfStringOrInt.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [RefRefToPathLevelParameterOneofRefToOneofParameter](docs/RefRefToPathLevelParameterOneofRefToOneofParameter.md)
|
||||
- [RefToRefParameterAnyofRefToAnyofParameter](docs/RefToRefParameterAnyofRefToAnyofParameter.md)
|
||||
- [SimpleModelWithArrayProperty](docs/SimpleModelWithArrayProperty.md)
|
||||
- [StringOrInt](docs/StringOrInt.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
|
@ -687,6 +687,34 @@ paths:
|
||||
- text/plain
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/ref_to_uuid'
|
||||
/ref/ref_to_path_level_parameter_oneof:
|
||||
get:
|
||||
description: to test $ref to path level parameters
|
||||
operationId: ref_to_ref_parameter_oneof
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/ref_to_oneof'
|
||||
responses:
|
||||
"200":
|
||||
description: Successful Response
|
||||
tags:
|
||||
- fake
|
||||
x-accepts:
|
||||
- application/json
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/ref_to_oneof'
|
||||
/ref/ref_to_operation_level_parameter_oneof:
|
||||
get:
|
||||
description: to test $ref to operation level parameters
|
||||
operationId: ref_to_ref_parameter_anyof
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/ref_to_anyof'
|
||||
responses:
|
||||
"200":
|
||||
description: Successful Response
|
||||
tags:
|
||||
- fake
|
||||
x-accepts:
|
||||
- application/json
|
||||
/fake/api/changeowner:
|
||||
post:
|
||||
operationId: op1
|
||||
@ -805,6 +833,24 @@ components:
|
||||
format: uuid
|
||||
type: string
|
||||
style: simple
|
||||
ref_to_oneof:
|
||||
description: to test ref to parameter (oneof)
|
||||
explode: false
|
||||
in: header
|
||||
name: ref_to_oneof
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/components/schemas/_ref_ref_to_path_level_parameter_oneof_ref_to_oneof_parameter'
|
||||
style: simple
|
||||
ref_to_anyof:
|
||||
description: to test ref to parameter (anyof)
|
||||
explode: false
|
||||
in: header
|
||||
name: ref_to_anyof
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/components/schemas/ref_to_ref_parameter_anyof_ref_to_anyof_parameter'
|
||||
style: simple
|
||||
requestBodies:
|
||||
UserArray:
|
||||
content:
|
||||
@ -1134,6 +1180,15 @@ components:
|
||||
description: file to upload
|
||||
format: binary
|
||||
type: string
|
||||
_ref_ref_to_path_level_parameter_oneof_ref_to_oneof_parameter:
|
||||
oneOf:
|
||||
- type: string
|
||||
- type: integer
|
||||
ref_to_ref_parameter_anyof_ref_to_anyof_parameter:
|
||||
oneOf:
|
||||
- type: string
|
||||
- items:
|
||||
type: string
|
||||
securitySchemes:
|
||||
petstore_auth:
|
||||
flows:
|
||||
|
@ -11,6 +11,8 @@ All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
| [**op2**](FakeApi.md#op2) | **POST** /fake/api/changename | op2 |
|
||||
| [**op3**](FakeApi.md#op3) | **POST** /fake/api/query/enum | op3 |
|
||||
| [**refToRefParameter**](FakeApi.md#refToRefParameter) | **GET** /ref/ref_to_parameter | |
|
||||
| [**refToRefParameterAnyof**](FakeApi.md#refToRefParameterAnyof) | **GET** /ref/ref_to_operation_level_parameter_oneof | |
|
||||
| [**refToRefParameterOneof**](FakeApi.md#refToRefParameterOneof) | **GET** /ref/ref_to_path_level_parameter_oneof | |
|
||||
| [**responseNoRef**](FakeApi.md#responseNoRef) | **GET** /no_ref | |
|
||||
| [**responseRefToNoRef**](FakeApi.md#responseRefToNoRef) | **GET** /ref/no_ref | |
|
||||
| [**responseRefToRef**](FakeApi.md#responseRefToRef) | **GET** /ref/ref | |
|
||||
@ -417,6 +419,128 @@ No authorization required
|
||||
|-------------|-------------|------------------|
|
||||
| **200** | | - |
|
||||
|
||||
<a id="refToRefParameterAnyof"></a>
|
||||
# **refToRefParameterAnyof**
|
||||
> refToRefParameterAnyof(refToAnyof)
|
||||
|
||||
|
||||
|
||||
to test $ref to operation level parameters
|
||||
|
||||
### 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.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
RefToRefParameterAnyofRefToAnyofParameter refToAnyof = new RefToRefParameterAnyofRefToAnyofParameter(); // RefToRefParameterAnyofRefToAnyofParameter | to test ref to parameter (anyof)
|
||||
try {
|
||||
apiInstance.refToRefParameterAnyof(refToAnyof);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling FakeApi#refToRefParameterAnyof");
|
||||
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 |
|
||||
|------------- | ------------- | ------------- | -------------|
|
||||
| **refToAnyof** | [**RefToRefParameterAnyofRefToAnyofParameter**](.md)| to test ref to parameter (anyof) | |
|
||||
|
||||
### 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** | Successful Response | - |
|
||||
|
||||
<a id="refToRefParameterOneof"></a>
|
||||
# **refToRefParameterOneof**
|
||||
> refToRefParameterOneof(refToOneof)
|
||||
|
||||
|
||||
|
||||
to test $ref to path level parameters
|
||||
|
||||
### 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.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
RefRefToPathLevelParameterOneofRefToOneofParameter refToOneof = new RefRefToPathLevelParameterOneofRefToOneofParameter(); // RefRefToPathLevelParameterOneofRefToOneofParameter | to test ref to parameter (oneof)
|
||||
try {
|
||||
apiInstance.refToRefParameterOneof(refToOneof);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling FakeApi#refToRefParameterOneof");
|
||||
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 |
|
||||
|------------- | ------------- | ------------- | -------------|
|
||||
| **refToOneof** | [**RefRefToPathLevelParameterOneofRefToOneofParameter**](.md)| to test ref to parameter (oneof) | |
|
||||
|
||||
### 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** | Successful Response | - |
|
||||
|
||||
<a id="responseNoRef"></a>
|
||||
# **responseNoRef**
|
||||
> String responseNoRef()
|
||||
|
@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
# RefRefToPathLevelParameterOneofRefToOneofParameter
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
# RefToRefParameterAnyofRefToAnyofParameter
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
# RefToRefParameterOneofRefToOneofParameter
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|
||||
|
||||
|
@ -135,6 +135,8 @@ public class JSON {
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.OneOfStringOrInt.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Order.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Pet.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.RefRefToPathLevelParameterOneofRefToOneofParameter.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.RefToRefParameterAnyofRefToAnyofParameter.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.SimpleModelWithArrayProperty.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.StringOrInt.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Tag.CustomTypeAdapterFactory());
|
||||
|
@ -28,6 +28,8 @@ import java.io.IOException;
|
||||
|
||||
|
||||
import org.openapitools.client.model.CodesEnum;
|
||||
import org.openapitools.client.model.RefRefToPathLevelParameterOneofRefToOneofParameter;
|
||||
import org.openapitools.client.model.RefToRefParameterAnyofRefToAnyofParameter;
|
||||
import java.util.UUID;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
@ -893,6 +895,248 @@ public class FakeApi {
|
||||
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
|
||||
return localVarCall;
|
||||
}
|
||||
/**
|
||||
* Build call for refToRefParameterAnyof
|
||||
* @param refToAnyof to test ref to parameter (anyof) (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> Successful Response </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public okhttp3.Call refToRefParameterAnyofCall(RefToRefParameterAnyofRefToAnyofParameter refToAnyof, 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 = "/ref/ref_to_operation_level_parameter_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 (refToAnyof != null) {
|
||||
localVarHeaderParams.put("ref_to_anyof", localVarApiClient.parameterToString(refToAnyof));
|
||||
}
|
||||
|
||||
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 refToRefParameterAnyofValidateBeforeCall(RefToRefParameterAnyofRefToAnyofParameter refToAnyof, final ApiCallback _callback) throws ApiException {
|
||||
// verify the required parameter 'refToAnyof' is set
|
||||
if (refToAnyof == null) {
|
||||
throw new ApiException("Missing the required parameter 'refToAnyof' when calling refToRefParameterAnyof(Async)");
|
||||
}
|
||||
|
||||
return refToRefParameterAnyofCall(refToAnyof, _callback);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* to test $ref to operation level parameters
|
||||
* @param refToAnyof to test ref to parameter (anyof) (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> Successful Response </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public void refToRefParameterAnyof(RefToRefParameterAnyofRefToAnyofParameter refToAnyof) throws ApiException {
|
||||
refToRefParameterAnyofWithHttpInfo(refToAnyof);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* to test $ref to operation level parameters
|
||||
* @param refToAnyof to test ref to parameter (anyof) (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> Successful Response </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public ApiResponse<Void> refToRefParameterAnyofWithHttpInfo(RefToRefParameterAnyofRefToAnyofParameter refToAnyof) throws ApiException {
|
||||
okhttp3.Call localVarCall = refToRefParameterAnyofValidateBeforeCall(refToAnyof, null);
|
||||
return localVarApiClient.execute(localVarCall);
|
||||
}
|
||||
|
||||
/**
|
||||
* (asynchronously)
|
||||
* to test $ref to operation level parameters
|
||||
* @param refToAnyof to test ref to parameter (anyof) (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> Successful Response </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public okhttp3.Call refToRefParameterAnyofAsync(RefToRefParameterAnyofRefToAnyofParameter refToAnyof, final ApiCallback<Void> _callback) throws ApiException {
|
||||
|
||||
okhttp3.Call localVarCall = refToRefParameterAnyofValidateBeforeCall(refToAnyof, _callback);
|
||||
localVarApiClient.executeAsync(localVarCall, _callback);
|
||||
return localVarCall;
|
||||
}
|
||||
/**
|
||||
* Build call for refToRefParameterOneof
|
||||
* @param refToOneof to test ref to parameter (oneof) (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> Successful Response </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public okhttp3.Call refToRefParameterOneofCall(RefRefToPathLevelParameterOneofRefToOneofParameter refToOneof, 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 = "/ref/ref_to_path_level_parameter_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 (refToOneof != null) {
|
||||
localVarHeaderParams.put("ref_to_oneof", localVarApiClient.parameterToString(refToOneof));
|
||||
}
|
||||
|
||||
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 refToRefParameterOneofValidateBeforeCall(RefRefToPathLevelParameterOneofRefToOneofParameter refToOneof, final ApiCallback _callback) throws ApiException {
|
||||
// verify the required parameter 'refToOneof' is set
|
||||
if (refToOneof == null) {
|
||||
throw new ApiException("Missing the required parameter 'refToOneof' when calling refToRefParameterOneof(Async)");
|
||||
}
|
||||
|
||||
return refToRefParameterOneofCall(refToOneof, _callback);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* to test $ref to path level parameters
|
||||
* @param refToOneof to test ref to parameter (oneof) (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> Successful Response </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public void refToRefParameterOneof(RefRefToPathLevelParameterOneofRefToOneofParameter refToOneof) throws ApiException {
|
||||
refToRefParameterOneofWithHttpInfo(refToOneof);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* to test $ref to path level parameters
|
||||
* @param refToOneof to test ref to parameter (oneof) (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> Successful Response </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public ApiResponse<Void> refToRefParameterOneofWithHttpInfo(RefRefToPathLevelParameterOneofRefToOneofParameter refToOneof) throws ApiException {
|
||||
okhttp3.Call localVarCall = refToRefParameterOneofValidateBeforeCall(refToOneof, null);
|
||||
return localVarApiClient.execute(localVarCall);
|
||||
}
|
||||
|
||||
/**
|
||||
* (asynchronously)
|
||||
* to test $ref to path level parameters
|
||||
* @param refToOneof to test ref to parameter (oneof) (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> Successful Response </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public okhttp3.Call refToRefParameterOneofAsync(RefRefToPathLevelParameterOneofRefToOneofParameter refToOneof, final ApiCallback<Void> _callback) throws ApiException {
|
||||
|
||||
okhttp3.Call localVarCall = refToRefParameterOneofValidateBeforeCall(refToOneof, _callback);
|
||||
localVarApiClient.executeAsync(localVarCall, _callback);
|
||||
return localVarCall;
|
||||
}
|
||||
/**
|
||||
* Build call for responseNoRef
|
||||
* @param _callback Callback for upload/download progress
|
||||
|
@ -0,0 +1,273 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
|
||||
public class RefRefToPathLevelParameterOneofRefToOneofParameter extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(RefRefToPathLevelParameterOneofRefToOneofParameter.class.getName());
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!RefRefToPathLevelParameterOneofRefToOneofParameter.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'RefRefToPathLevelParameterOneofRefToOneofParameter' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<String> adapterString = gson.getDelegateAdapter(this, TypeToken.get(String.class));
|
||||
final TypeAdapter<Integer> adapterInteger = gson.getDelegateAdapter(this, TypeToken.get(Integer.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<RefRefToPathLevelParameterOneofRefToOneofParameter>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, RefRefToPathLevelParameterOneofRefToOneofParameter value) throws IOException {
|
||||
if (value == null || value.getActualInstance() == null) {
|
||||
elementAdapter.write(out, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// check if the actual instance is of the type `String`
|
||||
if (value.getActualInstance() instanceof String) {
|
||||
JsonPrimitive primitive = adapterString.toJsonTree((String)value.getActualInstance()).getAsJsonPrimitive();
|
||||
elementAdapter.write(out, primitive);
|
||||
return;
|
||||
}
|
||||
// check if the actual instance is of the type `Integer`
|
||||
if (value.getActualInstance() instanceof Integer) {
|
||||
JsonPrimitive primitive = adapterInteger.toJsonTree((Integer)value.getActualInstance()).getAsJsonPrimitive();
|
||||
elementAdapter.write(out, primitive);
|
||||
return;
|
||||
}
|
||||
throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: Integer, String");
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefRefToPathLevelParameterOneofRefToOneofParameter read(JsonReader in) throws IOException {
|
||||
Object deserialized = null;
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
|
||||
int match = 0;
|
||||
ArrayList<String> errorMessages = new ArrayList<>();
|
||||
TypeAdapter actualAdapter = elementAdapter;
|
||||
|
||||
// deserialize String
|
||||
try {
|
||||
// validate the JSON object to see if any exception is thrown
|
||||
if (!jsonElement.getAsJsonPrimitive().isString()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type String in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
actualAdapter = adapterString;
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'String'");
|
||||
} catch (Exception e) {
|
||||
// deserialization failed, continue
|
||||
errorMessages.add(String.format("Deserialization for String failed with `%s`.", e.getMessage()));
|
||||
log.log(Level.FINER, "Input data does not match schema 'String'", e);
|
||||
}
|
||||
// deserialize Integer
|
||||
try {
|
||||
// validate the JSON object to see if any exception is thrown
|
||||
if (!jsonElement.getAsJsonPrimitive().isNumber()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
actualAdapter = adapterInteger;
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Integer'");
|
||||
} catch (Exception e) {
|
||||
// deserialization failed, continue
|
||||
errorMessages.add(String.format("Deserialization for Integer failed with `%s`.", e.getMessage()));
|
||||
log.log(Level.FINER, "Input data does not match schema 'Integer'", e);
|
||||
}
|
||||
|
||||
if (match == 1) {
|
||||
RefRefToPathLevelParameterOneofRefToOneofParameter ret = new RefRefToPathLevelParameterOneofRefToOneofParameter();
|
||||
ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement));
|
||||
return ret;
|
||||
}
|
||||
|
||||
throw new IOException(String.format("Failed deserialization for RefRefToPathLevelParameterOneofRefToOneofParameter: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString()));
|
||||
}
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
public static final Map<String, Class<?>> schemas = new HashMap<String, Class<?>>();
|
||||
|
||||
public RefRefToPathLevelParameterOneofRefToOneofParameter() {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
}
|
||||
|
||||
public RefRefToPathLevelParameterOneofRefToOneofParameter(Object o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
static {
|
||||
schemas.put("String", String.class);
|
||||
schemas.put("Integer", Integer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Class<?>> getSchemas() {
|
||||
return RefRefToPathLevelParameterOneofRefToOneofParameter.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas:
|
||||
* Integer, String
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof String) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Integer) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new RuntimeException("Invalid instance type. Must be Integer, String");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance, which can be the following:
|
||||
* Integer, String
|
||||
*
|
||||
* @return The actual instance (Integer, String)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getActualInstance() {
|
||||
return super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `String`. If the actual instance is not `String`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `String`
|
||||
* @throws ClassCastException if the instance is not `String`
|
||||
*/
|
||||
public String getString() throws ClassCastException {
|
||||
return (String)super.getActualInstance();
|
||||
}
|
||||
/**
|
||||
* Get the actual instance of `Integer`. If the actual instance is not `Integer`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `Integer`
|
||||
* @throws ClassCastException if the instance is not `Integer`
|
||||
*/
|
||||
public Integer getInteger() throws ClassCastException {
|
||||
return (Integer)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to RefRefToPathLevelParameterOneofRefToOneofParameter
|
||||
*/
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
// validate oneOf schemas one by one
|
||||
int validCount = 0;
|
||||
ArrayList<String> errorMessages = new ArrayList<>();
|
||||
// validate the json string with String
|
||||
try {
|
||||
if (!jsonElement.getAsJsonPrimitive().isString()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type String in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
validCount++;
|
||||
} catch (Exception e) {
|
||||
errorMessages.add(String.format("Deserialization for String failed with `%s`.", e.getMessage()));
|
||||
// continue to the next one
|
||||
}
|
||||
// validate the json string with Integer
|
||||
try {
|
||||
if (!jsonElement.getAsJsonPrimitive().isNumber()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
validCount++;
|
||||
} catch (Exception e) {
|
||||
errorMessages.add(String.format("Deserialization for Integer failed with `%s`.", e.getMessage()));
|
||||
// continue to the next one
|
||||
}
|
||||
if (validCount != 1) {
|
||||
throw new IOException(String.format("The JSON string is invalid for RefRefToPathLevelParameterOneofRefToOneofParameter with oneOf schemas: Integer, String. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of RefRefToPathLevelParameterOneofRefToOneofParameter given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of RefRefToPathLevelParameterOneofRefToOneofParameter
|
||||
* @throws IOException if the JSON string is invalid with respect to RefRefToPathLevelParameterOneofRefToOneofParameter
|
||||
*/
|
||||
public static RefRefToPathLevelParameterOneofRefToOneofParameter fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, RefRefToPathLevelParameterOneofRefToOneofParameter.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of RefRefToPathLevelParameterOneofRefToOneofParameter to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,294 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
|
||||
public class RefToRefParameterAnyofRefToAnyofParameter extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(RefToRefParameterAnyofRefToAnyofParameter.class.getName());
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!RefToRefParameterAnyofRefToAnyofParameter.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'RefToRefParameterAnyofRefToAnyofParameter' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<String> adapterString = gson.getDelegateAdapter(this, TypeToken.get(String.class));
|
||||
|
||||
final Type typeInstanceListString = new TypeToken<List<String>>(){}.getType();
|
||||
final TypeAdapter<List<String>> adapterListString = (TypeAdapter<List<String>>) gson.getDelegateAdapter(this, TypeToken.get(typeInstanceListString));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<RefToRefParameterAnyofRefToAnyofParameter>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, RefToRefParameterAnyofRefToAnyofParameter value) throws IOException {
|
||||
if (value == null || value.getActualInstance() == null) {
|
||||
elementAdapter.write(out, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// check if the actual instance is of the type `String`
|
||||
if (value.getActualInstance() instanceof String) {
|
||||
JsonPrimitive primitive = adapterString.toJsonTree((String)value.getActualInstance()).getAsJsonPrimitive();
|
||||
elementAdapter.write(out, primitive);
|
||||
return;
|
||||
}
|
||||
// check if the actual instance is of the type `List<String>`
|
||||
if (value.getActualInstance() instanceof List<?>) {
|
||||
JsonPrimitive primitive = adapterListString.toJsonTree((List<String>)value.getActualInstance()).getAsJsonPrimitive();
|
||||
elementAdapter.write(out, primitive);
|
||||
return;
|
||||
}
|
||||
throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: List<String>, String");
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefToRefParameterAnyofRefToAnyofParameter read(JsonReader in) throws IOException {
|
||||
Object deserialized = null;
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
|
||||
int match = 0;
|
||||
ArrayList<String> errorMessages = new ArrayList<>();
|
||||
TypeAdapter actualAdapter = elementAdapter;
|
||||
|
||||
// deserialize String
|
||||
try {
|
||||
// validate the JSON object to see if any exception is thrown
|
||||
if (!jsonElement.getAsJsonPrimitive().isString()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type String in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
actualAdapter = adapterString;
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'String'");
|
||||
} catch (Exception e) {
|
||||
// deserialization failed, continue
|
||||
errorMessages.add(String.format("Deserialization for String failed with `%s`.", e.getMessage()));
|
||||
log.log(Level.FINER, "Input data does not match schema 'String'", e);
|
||||
}
|
||||
// deserialize List<String>
|
||||
try {
|
||||
// validate the JSON object to see if any exception is thrown
|
||||
if (!jsonElement.isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be a array type in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
|
||||
JsonArray array = jsonElement.getAsJsonArray();
|
||||
// validate array items
|
||||
for(JsonElement element : array) {
|
||||
if (!element.getAsJsonPrimitive().isString()) {
|
||||
throw new IllegalArgumentException(String.format("Expected array items to be of type String in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
actualAdapter = adapterListString;
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'List<String>'");
|
||||
} catch (Exception e) {
|
||||
// deserialization failed, continue
|
||||
errorMessages.add(String.format("Deserialization for List<String> failed with `%s`.", e.getMessage()));
|
||||
log.log(Level.FINER, "Input data does not match schema 'List<String>'", e);
|
||||
}
|
||||
|
||||
if (match == 1) {
|
||||
RefToRefParameterAnyofRefToAnyofParameter ret = new RefToRefParameterAnyofRefToAnyofParameter();
|
||||
ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement));
|
||||
return ret;
|
||||
}
|
||||
|
||||
throw new IOException(String.format("Failed deserialization for RefToRefParameterAnyofRefToAnyofParameter: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString()));
|
||||
}
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
public static final Map<String, Class<?>> schemas = new HashMap<String, Class<?>>();
|
||||
|
||||
public RefToRefParameterAnyofRefToAnyofParameter() {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
}
|
||||
|
||||
public RefToRefParameterAnyofRefToAnyofParameter(Object o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
static {
|
||||
schemas.put("String", String.class);
|
||||
schemas.put("List<String>", List.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Class<?>> getSchemas() {
|
||||
return RefToRefParameterAnyofRefToAnyofParameter.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas:
|
||||
* List<String>, String
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof String) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof List<?>) {
|
||||
List<?> list = (List<?>) instance;
|
||||
if (list.get(0) instanceof String) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("Invalid instance type. Must be List<String>, String");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance, which can be the following:
|
||||
* List<String>, String
|
||||
*
|
||||
* @return The actual instance (List<String>, String)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getActualInstance() {
|
||||
return super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `String`. If the actual instance is not `String`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `String`
|
||||
* @throws ClassCastException if the instance is not `String`
|
||||
*/
|
||||
public String getString() throws ClassCastException {
|
||||
return (String)super.getActualInstance();
|
||||
}
|
||||
/**
|
||||
* Get the actual instance of `List<String>`. If the actual instance is not `List<String>`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `List<String>`
|
||||
* @throws ClassCastException if the instance is not `List<String>`
|
||||
*/
|
||||
public List<String> getListString() throws ClassCastException {
|
||||
return (List<String>)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to RefToRefParameterAnyofRefToAnyofParameter
|
||||
*/
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
// validate oneOf schemas one by one
|
||||
int validCount = 0;
|
||||
ArrayList<String> errorMessages = new ArrayList<>();
|
||||
// validate the json string with String
|
||||
try {
|
||||
if (!jsonElement.getAsJsonPrimitive().isString()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type String in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
validCount++;
|
||||
} catch (Exception e) {
|
||||
errorMessages.add(String.format("Deserialization for String failed with `%s`.", e.getMessage()));
|
||||
// continue to the next one
|
||||
}
|
||||
// validate the json string with List<String>
|
||||
try {
|
||||
if (!jsonElement.isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be a array type in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
JsonArray array = jsonElement.getAsJsonArray();
|
||||
// validate array items
|
||||
for(JsonElement element : array) {
|
||||
if (!element.getAsJsonPrimitive().isString()) {
|
||||
throw new IllegalArgumentException(String.format("Expected array items to be of type String in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
validCount++;
|
||||
} catch (Exception e) {
|
||||
errorMessages.add(String.format("Deserialization for List<String> failed with `%s`.", e.getMessage()));
|
||||
// continue to the next one
|
||||
}
|
||||
if (validCount != 1) {
|
||||
throw new IOException(String.format("The JSON string is invalid for RefToRefParameterAnyofRefToAnyofParameter with oneOf schemas: List<String>, String. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of RefToRefParameterAnyofRefToAnyofParameter given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of RefToRefParameterAnyofRefToAnyofParameter
|
||||
* @throws IOException if the JSON string is invalid with respect to RefToRefParameterAnyofRefToAnyofParameter
|
||||
*/
|
||||
public static RefToRefParameterAnyofRefToAnyofParameter fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, RefToRefParameterAnyofRefToAnyofParameter.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of RefToRefParameterAnyofRefToAnyofParameter to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,273 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
|
||||
public class RefToRefParameterOneofRefToOneofParameter extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(RefToRefParameterOneofRefToOneofParameter.class.getName());
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!RefToRefParameterOneofRefToOneofParameter.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'RefToRefParameterOneofRefToOneofParameter' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<String> adapterString = gson.getDelegateAdapter(this, TypeToken.get(String.class));
|
||||
final TypeAdapter<Integer> adapterInteger = gson.getDelegateAdapter(this, TypeToken.get(Integer.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<RefToRefParameterOneofRefToOneofParameter>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, RefToRefParameterOneofRefToOneofParameter value) throws IOException {
|
||||
if (value == null || value.getActualInstance() == null) {
|
||||
elementAdapter.write(out, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// check if the actual instance is of the type `String`
|
||||
if (value.getActualInstance() instanceof String) {
|
||||
JsonPrimitive primitive = adapterString.toJsonTree((String)value.getActualInstance()).getAsJsonPrimitive();
|
||||
elementAdapter.write(out, primitive);
|
||||
return;
|
||||
}
|
||||
// check if the actual instance is of the type `Integer`
|
||||
if (value.getActualInstance() instanceof Integer) {
|
||||
JsonPrimitive primitive = adapterInteger.toJsonTree((Integer)value.getActualInstance()).getAsJsonPrimitive();
|
||||
elementAdapter.write(out, primitive);
|
||||
return;
|
||||
}
|
||||
throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: Integer, String");
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefToRefParameterOneofRefToOneofParameter read(JsonReader in) throws IOException {
|
||||
Object deserialized = null;
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
|
||||
int match = 0;
|
||||
ArrayList<String> errorMessages = new ArrayList<>();
|
||||
TypeAdapter actualAdapter = elementAdapter;
|
||||
|
||||
// deserialize String
|
||||
try {
|
||||
// validate the JSON object to see if any exception is thrown
|
||||
if (!jsonElement.getAsJsonPrimitive().isString()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type String in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
actualAdapter = adapterString;
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'String'");
|
||||
} catch (Exception e) {
|
||||
// deserialization failed, continue
|
||||
errorMessages.add(String.format("Deserialization for String failed with `%s`.", e.getMessage()));
|
||||
log.log(Level.FINER, "Input data does not match schema 'String'", e);
|
||||
}
|
||||
// deserialize Integer
|
||||
try {
|
||||
// validate the JSON object to see if any exception is thrown
|
||||
if (!jsonElement.getAsJsonPrimitive().isNumber()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
actualAdapter = adapterInteger;
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Integer'");
|
||||
} catch (Exception e) {
|
||||
// deserialization failed, continue
|
||||
errorMessages.add(String.format("Deserialization for Integer failed with `%s`.", e.getMessage()));
|
||||
log.log(Level.FINER, "Input data does not match schema 'Integer'", e);
|
||||
}
|
||||
|
||||
if (match == 1) {
|
||||
RefToRefParameterOneofRefToOneofParameter ret = new RefToRefParameterOneofRefToOneofParameter();
|
||||
ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement));
|
||||
return ret;
|
||||
}
|
||||
|
||||
throw new IOException(String.format("Failed deserialization for RefToRefParameterOneofRefToOneofParameter: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString()));
|
||||
}
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
public static final Map<String, Class<?>> schemas = new HashMap<String, Class<?>>();
|
||||
|
||||
public RefToRefParameterOneofRefToOneofParameter() {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
}
|
||||
|
||||
public RefToRefParameterOneofRefToOneofParameter(Object o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
static {
|
||||
schemas.put("String", String.class);
|
||||
schemas.put("Integer", Integer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Class<?>> getSchemas() {
|
||||
return RefToRefParameterOneofRefToOneofParameter.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas:
|
||||
* Integer, String
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof String) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Integer) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new RuntimeException("Invalid instance type. Must be Integer, String");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance, which can be the following:
|
||||
* Integer, String
|
||||
*
|
||||
* @return The actual instance (Integer, String)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getActualInstance() {
|
||||
return super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `String`. If the actual instance is not `String`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `String`
|
||||
* @throws ClassCastException if the instance is not `String`
|
||||
*/
|
||||
public String getString() throws ClassCastException {
|
||||
return (String)super.getActualInstance();
|
||||
}
|
||||
/**
|
||||
* Get the actual instance of `Integer`. If the actual instance is not `Integer`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `Integer`
|
||||
* @throws ClassCastException if the instance is not `Integer`
|
||||
*/
|
||||
public Integer getInteger() throws ClassCastException {
|
||||
return (Integer)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to RefToRefParameterOneofRefToOneofParameter
|
||||
*/
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
// validate oneOf schemas one by one
|
||||
int validCount = 0;
|
||||
ArrayList<String> errorMessages = new ArrayList<>();
|
||||
// validate the json string with String
|
||||
try {
|
||||
if (!jsonElement.getAsJsonPrimitive().isString()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type String in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
validCount++;
|
||||
} catch (Exception e) {
|
||||
errorMessages.add(String.format("Deserialization for String failed with `%s`.", e.getMessage()));
|
||||
// continue to the next one
|
||||
}
|
||||
// validate the json string with Integer
|
||||
try {
|
||||
if (!jsonElement.getAsJsonPrimitive().isNumber()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
validCount++;
|
||||
} catch (Exception e) {
|
||||
errorMessages.add(String.format("Deserialization for Integer failed with `%s`.", e.getMessage()));
|
||||
// continue to the next one
|
||||
}
|
||||
if (validCount != 1) {
|
||||
throw new IOException(String.format("The JSON string is invalid for RefToRefParameterOneofRefToOneofParameter with oneOf schemas: Integer, String. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of RefToRefParameterOneofRefToOneofParameter given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of RefToRefParameterOneofRefToOneofParameter
|
||||
* @throws IOException if the JSON string is invalid with respect to RefToRefParameterOneofRefToOneofParameter
|
||||
*/
|
||||
public static RefToRefParameterOneofRefToOneofParameter fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, RefToRefParameterOneofRefToOneofParameter.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of RefToRefParameterOneofRefToOneofParameter to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Model tests for RefRefToPathLevelParameterOneofRefToOneofParameter
|
||||
*/
|
||||
public class RefRefToPathLevelParameterOneofRefToOneofParameterTest {
|
||||
private final RefRefToPathLevelParameterOneofRefToOneofParameter model = new RefRefToPathLevelParameterOneofRefToOneofParameter();
|
||||
|
||||
/**
|
||||
* Model tests for RefRefToPathLevelParameterOneofRefToOneofParameter
|
||||
*/
|
||||
@Test
|
||||
public void testRefRefToPathLevelParameterOneofRefToOneofParameter() {
|
||||
// TODO: test RefRefToPathLevelParameterOneofRefToOneofParameter
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Model tests for RefToRefParameterAnyofRefToAnyofParameter
|
||||
*/
|
||||
public class RefToRefParameterAnyofRefToAnyofParameterTest {
|
||||
private final RefToRefParameterAnyofRefToAnyofParameter model = new RefToRefParameterAnyofRefToAnyofParameter();
|
||||
|
||||
/**
|
||||
* Model tests for RefToRefParameterAnyofRefToAnyofParameter
|
||||
*/
|
||||
@Test
|
||||
public void testRefToRefParameterAnyofRefToAnyofParameter() {
|
||||
// TODO: test RefToRefParameterAnyofRefToAnyofParameter
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Model tests for RefToRefParameterOneofRefToOneofParameter
|
||||
*/
|
||||
public class RefToRefParameterOneofRefToOneofParameterTest {
|
||||
private final RefToRefParameterOneofRefToOneofParameter model = new RefToRefParameterOneofRefToOneofParameter();
|
||||
|
||||
/**
|
||||
* Model tests for RefToRefParameterOneofRefToOneofParameter
|
||||
*/
|
||||
@Test
|
||||
public void testRefToRefParameterOneofRefToOneofParameter() {
|
||||
// TODO: test RefToRefParameterOneofRefToOneofParameter
|
||||
}
|
||||
|
||||
}
|
@ -46,6 +46,7 @@ docs/FakeAnyOfWIthSameErasureGet200Response.md
|
||||
docs/FakeApi.md
|
||||
docs/FakeClassnameTags123Api.md
|
||||
docs/FakeOneOfWIthSameErasureGet200Response.md
|
||||
docs/FakeRefParameterPetIdParameter.md
|
||||
docs/FileSchemaTestClass.md
|
||||
docs/Foo.md
|
||||
docs/FooGetDefaultResponse.md
|
||||
@ -190,6 +191,7 @@ src/main/java/org/openapitools/client/model/EnumTest.java
|
||||
src/main/java/org/openapitools/client/model/EquilateralTriangle.java
|
||||
src/main/java/org/openapitools/client/model/FakeAnyOfWIthSameErasureGet200Response.java
|
||||
src/main/java/org/openapitools/client/model/FakeOneOfWIthSameErasureGet200Response.java
|
||||
src/main/java/org/openapitools/client/model/FakeRefParameterPetIdParameter.java
|
||||
src/main/java/org/openapitools/client/model/FileSchemaTestClass.java
|
||||
src/main/java/org/openapitools/client/model/Foo.java
|
||||
src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java
|
||||
|
@ -127,7 +127,8 @@ Class | Method | HTTP request | Description
|
||||
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
|
||||
*FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
|
||||
*FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string |
|
||||
*FakeApi* | [**fakeUploadRefRequestBodies**](docs/FakeApi.md#fakeUploadRefRequestBodies) | **POST** /fake/pet/{petId}/uploadImage | fake uploads an image with ref request bodies
|
||||
*FakeApi* | [**fakeRefParameter**](docs/FakeApi.md#fakeRefParameter) | **POST** /fake/pet/{petId}/reference/parameter | fake reference parameter
|
||||
*FakeApi* | [**fakeUploadRefRequestBodies**](docs/FakeApi.md#fakeUploadRefRequestBodies) | **POST** /fake/pet/{petId}/uploadImage | fake reference parameter
|
||||
*FakeApi* | [**getFakeArrayofenums**](docs/FakeApi.md#getFakeArrayofenums) | **GET** /fake/array-of-enums | Array of Enums
|
||||
*FakeApi* | [**getFakeHealth**](docs/FakeApi.md#getFakeHealth) | **GET** /fake/health | Health check endpoint
|
||||
*FakeApi* | [**getParameterNameMapping**](docs/FakeApi.md#getParameterNameMapping) | **GET** /fake/parameter-name-mapping | parameter name mapping test
|
||||
@ -207,6 +208,7 @@ Class | Method | HTTP request | Description
|
||||
- [EquilateralTriangle](docs/EquilateralTriangle.md)
|
||||
- [FakeAnyOfWIthSameErasureGet200Response](docs/FakeAnyOfWIthSameErasureGet200Response.md)
|
||||
- [FakeOneOfWIthSameErasureGet200Response](docs/FakeOneOfWIthSameErasureGet200Response.md)
|
||||
- [FakeRefParameterPetIdParameter](docs/FakeRefParameterPetIdParameter.md)
|
||||
- [FileSchemaTestClass](docs/FileSchemaTestClass.md)
|
||||
- [Foo](docs/Foo.md)
|
||||
- [FooGetDefaultResponse](docs/FooGetDefaultResponse.md)
|
||||
|
@ -1459,12 +1459,33 @@ paths:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: fake uploads an image with ref request bodies
|
||||
summary: fake reference parameter
|
||||
tags:
|
||||
- fake
|
||||
x-content-type: multipart/form-data
|
||||
x-accepts:
|
||||
- application/json
|
||||
/fake/pet/{petId}/reference/parameter:
|
||||
post:
|
||||
description: ""
|
||||
operationId: fake-ref-parameter
|
||||
parameters:
|
||||
- description: to test oneOf in parameter $ref
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/components/schemas/fake_ref_parameter_petId_parameter'
|
||||
style: simple
|
||||
responses:
|
||||
"200":
|
||||
description: successful operation
|
||||
summary: fake reference parameter
|
||||
tags:
|
||||
- fake
|
||||
x-accepts:
|
||||
- application/json
|
||||
/values:
|
||||
get:
|
||||
description: ""
|
||||
@ -1502,6 +1523,16 @@ paths:
|
||||
x-accepts:
|
||||
- application/json
|
||||
components:
|
||||
parameters:
|
||||
pet_id:
|
||||
description: to test oneOf in parameter $ref
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/components/schemas/fake_ref_parameter_petId_parameter'
|
||||
style: simple
|
||||
requestBodies:
|
||||
upload_body:
|
||||
content:
|
||||
@ -2985,6 +3016,10 @@ components:
|
||||
required:
|
||||
- requiredFile
|
||||
type: object
|
||||
fake_ref_parameter_petId_parameter:
|
||||
oneOf:
|
||||
- type: string
|
||||
- type: integer
|
||||
FreeFormObjectTestClass_properties:
|
||||
oneOf:
|
||||
- type: string
|
||||
|
@ -9,7 +9,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
| [**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | |
|
||||
| [**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | |
|
||||
| [**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | |
|
||||
| [**fakeUploadRefRequestBodies**](FakeApi.md#fakeUploadRefRequestBodies) | **POST** /fake/pet/{petId}/uploadImage | fake uploads an image with ref request bodies |
|
||||
| [**fakeRefParameter**](FakeApi.md#fakeRefParameter) | **POST** /fake/pet/{petId}/reference/parameter | fake reference parameter |
|
||||
| [**fakeUploadRefRequestBodies**](FakeApi.md#fakeUploadRefRequestBodies) | **POST** /fake/pet/{petId}/uploadImage | fake reference parameter |
|
||||
| [**getFakeArrayofenums**](FakeApi.md#getFakeArrayofenums) | **GET** /fake/array-of-enums | Array of Enums |
|
||||
| [**getFakeHealth**](FakeApi.md#getFakeHealth) | **GET** /fake/health | Health check endpoint |
|
||||
| [**getParameterNameMapping**](FakeApi.md#getParameterNameMapping) | **GET** /fake/parameter-name-mapping | parameter name mapping test |
|
||||
@ -333,11 +334,72 @@ No authorization required
|
||||
|-------------|-------------|------------------|
|
||||
| **200** | Output string | - |
|
||||
|
||||
<a id="fakeRefParameter"></a>
|
||||
# **fakeRefParameter**
|
||||
> fakeRefParameter(petId)
|
||||
|
||||
fake reference parameter
|
||||
|
||||
|
||||
|
||||
### 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.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
FakeRefParameterPetIdParameter petId = new FakeRefParameterPetIdParameter(); // FakeRefParameterPetIdParameter | to test oneOf in parameter $ref
|
||||
try {
|
||||
apiInstance.fakeRefParameter(petId);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling FakeApi#fakeRefParameter");
|
||||
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 |
|
||||
|------------- | ------------- | ------------- | -------------|
|
||||
| **petId** | [**FakeRefParameterPetIdParameter**](.md)| to test oneOf in parameter $ref | |
|
||||
|
||||
### 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** | successful operation | - |
|
||||
|
||||
<a id="fakeUploadRefRequestBodies"></a>
|
||||
# **fakeUploadRefRequestBodies**
|
||||
> ModelApiResponse fakeUploadRefRequestBodies(petId, additionalMetadata, _file)
|
||||
|
||||
fake uploads an image with ref request bodies
|
||||
fake reference parameter
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
# FakeRefParameterPetIdParameter
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|
||||
|
||||
|
@ -276,6 +276,7 @@ public class JSON {
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.EquilateralTriangle.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.FakeAnyOfWIthSameErasureGet200Response.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.FakeOneOfWIthSameErasureGet200Response.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.FakeRefParameterPetIdParameter.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.FileSchemaTestClass.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Foo.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.FooGetDefaultResponse.CustomTypeAdapterFactory());
|
||||
|
@ -29,6 +29,7 @@ import java.io.IOException;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.client.model.Client;
|
||||
import org.openapitools.client.model.FakeRefParameterPetIdParameter;
|
||||
import java.io.File;
|
||||
import org.openapitools.client.model.FileSchemaTestClass;
|
||||
import org.openapitools.client.model.FreeFormObjectTestClass;
|
||||
@ -669,6 +670,124 @@ public class FakeApi {
|
||||
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
|
||||
return localVarCall;
|
||||
}
|
||||
/**
|
||||
* Build call for fakeRefParameter
|
||||
* @param petId to test oneOf in parameter $ref (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> successful operation </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public okhttp3.Call fakeRefParameterCall(FakeRefParameterPetIdParameter petId, 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/pet/{petId}/reference/parameter"
|
||||
.replace("{" + "petId" + "}", localVarApiClient.escapeString(petId.toString()));
|
||||
|
||||
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>();
|
||||
|
||||
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, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private okhttp3.Call fakeRefParameterValidateBeforeCall(FakeRefParameterPetIdParameter petId, final ApiCallback _callback) throws ApiException {
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == null) {
|
||||
throw new ApiException("Missing the required parameter 'petId' when calling fakeRefParameter(Async)");
|
||||
}
|
||||
|
||||
return fakeRefParameterCall(petId, _callback);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* fake reference parameter
|
||||
*
|
||||
* @param petId to test oneOf in parameter $ref (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> successful operation </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public void fakeRefParameter(FakeRefParameterPetIdParameter petId) throws ApiException {
|
||||
fakeRefParameterWithHttpInfo(petId);
|
||||
}
|
||||
|
||||
/**
|
||||
* fake reference parameter
|
||||
*
|
||||
* @param petId to test oneOf in parameter $ref (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> successful operation </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public ApiResponse<Void> fakeRefParameterWithHttpInfo(FakeRefParameterPetIdParameter petId) throws ApiException {
|
||||
okhttp3.Call localVarCall = fakeRefParameterValidateBeforeCall(petId, null);
|
||||
return localVarApiClient.execute(localVarCall);
|
||||
}
|
||||
|
||||
/**
|
||||
* fake reference parameter (asynchronously)
|
||||
*
|
||||
* @param petId to test oneOf in parameter $ref (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> successful operation </td><td> - </td></tr>
|
||||
</table>
|
||||
*/
|
||||
public okhttp3.Call fakeRefParameterAsync(FakeRefParameterPetIdParameter petId, final ApiCallback<Void> _callback) throws ApiException {
|
||||
|
||||
okhttp3.Call localVarCall = fakeRefParameterValidateBeforeCall(petId, _callback);
|
||||
localVarApiClient.executeAsync(localVarCall, _callback);
|
||||
return localVarCall;
|
||||
}
|
||||
/**
|
||||
* Build call for fakeUploadRefRequestBodies
|
||||
* @param petId ID of pet to update (required)
|
||||
@ -749,7 +868,7 @@ public class FakeApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* fake uploads an image with ref request bodies
|
||||
* fake reference parameter
|
||||
*
|
||||
* @param petId ID of pet to update (required)
|
||||
* @param additionalMetadata Additional data to pass to server (optional)
|
||||
@ -768,7 +887,7 @@ public class FakeApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* fake uploads an image with ref request bodies
|
||||
* fake reference parameter
|
||||
*
|
||||
* @param petId ID of pet to update (required)
|
||||
* @param additionalMetadata Additional data to pass to server (optional)
|
||||
@ -788,7 +907,7 @@ public class FakeApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* fake uploads an image with ref request bodies (asynchronously)
|
||||
* fake reference parameter (asynchronously)
|
||||
*
|
||||
* @param petId ID of pet to update (required)
|
||||
* @param additionalMetadata Additional data to pass to server (optional)
|
||||
|
@ -0,0 +1,273 @@
|
||||
/*
|
||||
* 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: \" \\
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
|
||||
public class FakeRefParameterPetIdParameter extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(FakeRefParameterPetIdParameter.class.getName());
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!FakeRefParameterPetIdParameter.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'FakeRefParameterPetIdParameter' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<String> adapterString = gson.getDelegateAdapter(this, TypeToken.get(String.class));
|
||||
final TypeAdapter<Integer> adapterInteger = gson.getDelegateAdapter(this, TypeToken.get(Integer.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<FakeRefParameterPetIdParameter>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, FakeRefParameterPetIdParameter value) throws IOException {
|
||||
if (value == null || value.getActualInstance() == null) {
|
||||
elementAdapter.write(out, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// check if the actual instance is of the type `String`
|
||||
if (value.getActualInstance() instanceof String) {
|
||||
JsonPrimitive primitive = adapterString.toJsonTree((String)value.getActualInstance()).getAsJsonPrimitive();
|
||||
elementAdapter.write(out, primitive);
|
||||
return;
|
||||
}
|
||||
// check if the actual instance is of the type `Integer`
|
||||
if (value.getActualInstance() instanceof Integer) {
|
||||
JsonPrimitive primitive = adapterInteger.toJsonTree((Integer)value.getActualInstance()).getAsJsonPrimitive();
|
||||
elementAdapter.write(out, primitive);
|
||||
return;
|
||||
}
|
||||
throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: Integer, String");
|
||||
}
|
||||
|
||||
@Override
|
||||
public FakeRefParameterPetIdParameter read(JsonReader in) throws IOException {
|
||||
Object deserialized = null;
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
|
||||
int match = 0;
|
||||
ArrayList<String> errorMessages = new ArrayList<>();
|
||||
TypeAdapter actualAdapter = elementAdapter;
|
||||
|
||||
// deserialize String
|
||||
try {
|
||||
// validate the JSON object to see if any exception is thrown
|
||||
if (!jsonElement.getAsJsonPrimitive().isString()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type String in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
actualAdapter = adapterString;
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'String'");
|
||||
} catch (Exception e) {
|
||||
// deserialization failed, continue
|
||||
errorMessages.add(String.format("Deserialization for String failed with `%s`.", e.getMessage()));
|
||||
log.log(Level.FINER, "Input data does not match schema 'String'", e);
|
||||
}
|
||||
// deserialize Integer
|
||||
try {
|
||||
// validate the JSON object to see if any exception is thrown
|
||||
if (!jsonElement.getAsJsonPrimitive().isNumber()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
actualAdapter = adapterInteger;
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Integer'");
|
||||
} catch (Exception e) {
|
||||
// deserialization failed, continue
|
||||
errorMessages.add(String.format("Deserialization for Integer failed with `%s`.", e.getMessage()));
|
||||
log.log(Level.FINER, "Input data does not match schema 'Integer'", e);
|
||||
}
|
||||
|
||||
if (match == 1) {
|
||||
FakeRefParameterPetIdParameter ret = new FakeRefParameterPetIdParameter();
|
||||
ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement));
|
||||
return ret;
|
||||
}
|
||||
|
||||
throw new IOException(String.format("Failed deserialization for FakeRefParameterPetIdParameter: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString()));
|
||||
}
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
public static final Map<String, Class<?>> schemas = new HashMap<String, Class<?>>();
|
||||
|
||||
public FakeRefParameterPetIdParameter() {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
}
|
||||
|
||||
public FakeRefParameterPetIdParameter(Object o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
static {
|
||||
schemas.put("String", String.class);
|
||||
schemas.put("Integer", Integer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Class<?>> getSchemas() {
|
||||
return FakeRefParameterPetIdParameter.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas:
|
||||
* Integer, String
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof String) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Integer) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new RuntimeException("Invalid instance type. Must be Integer, String");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance, which can be the following:
|
||||
* Integer, String
|
||||
*
|
||||
* @return The actual instance (Integer, String)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getActualInstance() {
|
||||
return super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `String`. If the actual instance is not `String`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `String`
|
||||
* @throws ClassCastException if the instance is not `String`
|
||||
*/
|
||||
public String getString() throws ClassCastException {
|
||||
return (String)super.getActualInstance();
|
||||
}
|
||||
/**
|
||||
* Get the actual instance of `Integer`. If the actual instance is not `Integer`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `Integer`
|
||||
* @throws ClassCastException if the instance is not `Integer`
|
||||
*/
|
||||
public Integer getInteger() throws ClassCastException {
|
||||
return (Integer)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to FakeRefParameterPetIdParameter
|
||||
*/
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
// validate oneOf schemas one by one
|
||||
int validCount = 0;
|
||||
ArrayList<String> errorMessages = new ArrayList<>();
|
||||
// validate the json string with String
|
||||
try {
|
||||
if (!jsonElement.getAsJsonPrimitive().isString()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type String in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
validCount++;
|
||||
} catch (Exception e) {
|
||||
errorMessages.add(String.format("Deserialization for String failed with `%s`.", e.getMessage()));
|
||||
// continue to the next one
|
||||
}
|
||||
// validate the json string with Integer
|
||||
try {
|
||||
if (!jsonElement.getAsJsonPrimitive().isNumber()) {
|
||||
throw new IllegalArgumentException(String.format("Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString()));
|
||||
}
|
||||
validCount++;
|
||||
} catch (Exception e) {
|
||||
errorMessages.add(String.format("Deserialization for Integer failed with `%s`.", e.getMessage()));
|
||||
// continue to the next one
|
||||
}
|
||||
if (validCount != 1) {
|
||||
throw new IOException(String.format("The JSON string is invalid for FakeRefParameterPetIdParameter with oneOf schemas: Integer, String. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of FakeRefParameterPetIdParameter given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of FakeRefParameterPetIdParameter
|
||||
* @throws IOException if the JSON string is invalid with respect to FakeRefParameterPetIdParameter
|
||||
*/
|
||||
public static FakeRefParameterPetIdParameter fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, FakeRefParameterPetIdParameter.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of FakeRefParameterPetIdParameter to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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: \" \\
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Model tests for FakeRefParameterPetIdParameter
|
||||
*/
|
||||
public class FakeRefParameterPetIdParameterTest {
|
||||
private final FakeRefParameterPetIdParameter model = new FakeRefParameterPetIdParameter();
|
||||
|
||||
/**
|
||||
* Model tests for FakeRefParameterPetIdParameter
|
||||
*/
|
||||
@Test
|
||||
public void testFakeRefParameterPetIdParameter() {
|
||||
// TODO: test FakeRefParameterPetIdParameter
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user