Better handling of API response in 3.1 spec (#16986)

* better handling of API response in 3.1 spec

* update PR template

* add tests
This commit is contained in:
William Cheng
2023-11-05 15:24:02 +08:00
committed by GitHub
parent db9fd9a094
commit de8599906e
15 changed files with 797 additions and 27 deletions

View File

@@ -11,13 +11,11 @@
./bin/generate-samples.sh ./bin/configs/*.yaml
./bin/utils/export_docs_generators.sh
```
(For Windows users, please run the script in [Git BASH](https://gitforwindows.org/))
Commit all changed files.
This is important, as CI jobs will verify _all_ generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example `./bin/generate-samples.sh bin/configs/java*`.
For Windows users, please run the script in [Git BASH](https://gitforwindows.org/).
Do **NOT** purge any folders (e.g. tests) when regenerating the samples.
IMPORTANT: Do **NOT** purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master` (upcoming 7.1.0 minor release - breaking changes with fallbacks), `8.0.x` (breaking changes without fallbacks)
- [ ] If your PR is targeting a particular programming language, @mention the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) members, so they are more likely to review the pull request.

View File

@@ -1019,7 +1019,7 @@ public class DefaultCodegen implements CodegenConfig {
if (op.getValue().getResponses() != null) {
for (Map.Entry<String, ApiResponse> ar : op.getValue().getResponses().entrySet()) {
ApiResponse a = ModelUtils.getReferencedApiResponse(openAPI, ar.getValue());
Schema responseSchema = ModelUtils.getSchemaFromResponse(a);
Schema responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(openAPI, a));
if (responseSchema != null) {
schemas.put(opId + ar.getKey(), responseSchema);
}
@@ -4379,7 +4379,7 @@ public class DefaultCodegen implements CodegenConfig {
CodegenOperation op,
ApiResponse methodResponse,
Map<String, String> schemaMappings) {
Schema responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(methodResponse));
Schema responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(openAPI, methodResponse));
if (responseSchema != null) {
CodegenProperty cm = fromProperty("response", responseSchema, false);
@@ -4813,6 +4813,7 @@ public class DefaultCodegen implements CodegenConfig {
} else {
r.code = responseCode;
switch (r.code.charAt(0)) {
case '1':
r.is1xx = true;
break;
@@ -4835,12 +4836,11 @@ public class DefaultCodegen implements CodegenConfig {
Schema responseSchema;
if (this.openAPI != null && this.openAPI.getComponents() != null) {
responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(response));
responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(openAPI, response));
} else { // no model/alias defined
responseSchema = ModelUtils.getSchemaFromResponse(response);
responseSchema = ModelUtils.getSchemaFromResponse(openAPI, response);
}
r.schema = responseSchema;
r.message = escapeText(response.getDescription());
// TODO need to revise and test examples in responses
// ApiResponse does not support examples at the moment

View File

@@ -188,7 +188,8 @@ public class OpenAPINormalizer {
}
normalizePaths();
normalizeComponents();
normalizeComponentsSchemas();
normalizeComponentsResponses();
}
/**
@@ -346,7 +347,7 @@ public class OpenAPINormalizer {
/**
* Normalizes schemas in components
*/
private void normalizeComponents() {
private void normalizeComponentsSchemas() {
Map<String, Schema> schemas = openAPI.getComponents().getSchemas();
if (schemas == null) {
return;
@@ -364,6 +365,33 @@ public class OpenAPINormalizer {
}
}
/**
* Normalizes responses in components
*/
private void normalizeComponentsResponses() {
Map<String, ApiResponse> schemas = openAPI.getComponents().getResponses();
if (schemas == null) {
return;
}
List<String> schemaNames = new ArrayList<String>(schemas.keySet());
for (String schemaName : schemaNames) {
ApiResponse schema = schemas.get(schemaName);
if (schema == null) {
LOGGER.warn("{} not fount found in openapi/components/schemas.", schemaName);
} else {
Content content = ModelUtils.getReferencedApiResponse(openAPI, schema).getContent();
if (content == null || content.isEmpty()) {
continue;
}
for (Map.Entry<String, MediaType> entry : content.entrySet()) {
Schema entryResult = normalizeSchema(entry.getValue().getSchema(), new HashSet<>());
entry.getValue().setSchema(entryResult);
}
}
}
}
/**
* Normalizes a schema
*

View File

@@ -573,7 +573,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
if (op.getHasExamples()) {
// prepare examples for Apex test classes
ApiResponse apiResponse = findMethodResponse(operation.getResponses());
final Schema responseSchema = ModelUtils.getSchemaFromResponse(apiResponse);
final Schema responseSchema = ModelUtils.getSchemaFromResponse(openAPI, apiResponse);
String deserializedExample = toExampleValue(responseSchema);
for (Map<String, String> example : op.examples) {
example.put("example", escapeText(example.get("example")));

View File

@@ -244,7 +244,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
ApiResponse apiResponse = findMethodResponse(operation.getResponses());
if (apiResponse != null) {
Schema response = ModelUtils.getSchemaFromResponse(apiResponse);
Schema response = ModelUtils.getSchemaFromResponse(openAPI, apiResponse);
if (response != null) {
CodegenProperty cm = fromProperty("response", response, false);
op.vendorExtensions.put("x-codegen-response", cm);

View File

@@ -294,7 +294,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
ApiResponse methodResponse = findMethodResponse(operation.getResponses());
if (methodResponse != null) {
Schema response = ModelUtils.getSchemaFromResponse(methodResponse);
Schema response = ModelUtils.getSchemaFromResponse(openAPI, methodResponse);
response = unaliasSchema(response);
if (response != null) {
CodegenProperty cm = fromProperty("response", response, false);

View File

@@ -530,7 +530,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
}
if (!op.hasReturnPassthroughVoid) {
Schema responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(methodResponse));
Schema responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(openAPI, methodResponse));
ExtendedCodegenProperty cp = null;
if (op.returnPassthrough instanceof String && cm != null) {
cp = (ExtendedCodegenProperty) this.processCodeGenModel(cm).vars.get(1);

View File

@@ -1009,11 +1009,12 @@ public class ModelUtils {
/**
* Return the first defined Schema for a ApiResponse
*
* @param openAPI OpenAPI spec.
* @param response api response of the operation
* @return firstSchema
*/
public static Schema getSchemaFromResponse(ApiResponse response) {
return getSchemaFromContent(response.getContent());
public static Schema getSchemaFromResponse(OpenAPI openAPI, ApiResponse response) {
return getSchemaFromContent(getReferencedApiResponse(openAPI, response).getContent());
}
/**

View File

@@ -569,6 +569,36 @@ paths:
description: User not found
security:
- api_key: []
/no_ref:
get:
operationId: response_no_ref
tags:
- fake
responses:
'200':
description: required to pass validation
content:
text/plain:
schema:
type: string
/ref/no_ref:
get:
operationId: response_ref_to_no_ref
tags:
- fake
responses:
'200':
$ref: '#/components/responses/no_ref'
/ref/ref:
get:
operationId: response_ref_to_ref
tags:
- fake
responses:
'200':
$ref: '#/components/responses/ref'
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'
@@ -593,6 +623,20 @@ components:
$ref: '#/components/schemas/Pet'
description: Pet object that needs to be added to the store
required: true
responses:
no_ref:
description: required to pass validation
content:
text/plain:
schema:
type: string
ref:
description: required to pass validation
content:
text/plain:
schema:
$ref: '#/components/schemas/simple_text'
securitySchemes:
petstore_auth:
type: oauth2
@@ -773,3 +817,5 @@ components:
color:
type: string
default: red
simple_text:
type: string

View File

@@ -9,6 +9,7 @@ docs/Animal.md
docs/Cat.md
docs/Category.md
docs/Dog.md
docs/FakeApi.md
docs/ModelApiResponse.md
docs/OneOfStringOrInt.md
docs/Order.md
@@ -41,6 +42,7 @@ src/main/java/org/openapitools/client/ProgressResponseBody.java
src/main/java/org/openapitools/client/ServerConfiguration.java
src/main/java/org/openapitools/client/ServerVariable.java
src/main/java/org/openapitools/client/StringUtil.java
src/main/java/org/openapitools/client/api/FakeApi.java
src/main/java/org/openapitools/client/api/PetApi.java
src/main/java/org/openapitools/client/api/StoreApi.java
src/main/java/org/openapitools/client/api/UserApi.java

View File

@@ -82,26 +82,20 @@ Please follow the [installation](#installation) instruction and execute the foll
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.auth.*;
import org.openapitools.client.models.*;
import org.openapitools.client.api.PetApi;
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");
// Configure OAuth2 access token for authorization: petstore_auth
OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth");
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");
PetApi apiInstance = new PetApi(defaultClient);
Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store
FakeApi apiInstance = new FakeApi(defaultClient);
try {
Pet result = apiInstance.addPet(pet);
String result = apiInstance.responseNoRef();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PetApi#addPet");
System.err.println("Exception when calling FakeApi#responseNoRef");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
@@ -118,6 +112,9 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*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 |
*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status

View File

@@ -610,6 +610,37 @@ paths:
- user
x-content-type: application/json
x-accepts: application/json
/no_ref:
get:
operationId: response_no_ref
responses:
"200":
content:
text/plain:
schema:
type: string
description: required to pass validation
tags:
- fake
x-accepts: text/plain
/ref/no_ref:
get:
operationId: response_ref_to_no_ref
responses:
"200":
$ref: '#/components/responses/no_ref'
tags:
- fake
x-accepts: text/plain
/ref/ref:
get:
operationId: response_ref_to_ref
responses:
"200":
$ref: '#/components/responses/ref'
tags:
- fake
x-accepts: text/plain
components:
requestBodies:
UserArray:
@@ -631,6 +662,19 @@ components:
$ref: '#/components/schemas/Pet'
description: Pet object that needs to be added to the store
required: true
responses:
no_ref:
content:
text/plain:
schema:
type: string
description: required to pass validation
ref:
content:
text/plain:
schema:
$ref: '#/components/schemas/simple_text'
description: required to pass validation
schemas:
Order:
description: An order for a pets from the pet store
@@ -833,6 +877,8 @@ components:
type: string
required:
- className
simple_text:
type: string
updatePetWithForm_request:
properties:
name:

View File

@@ -0,0 +1,179 @@
# FakeApi
All URIs are relative to *http://petstore.swagger.io/v2*
| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**responseNoRef**](FakeApi.md#responseNoRef) | **GET** /no_ref | |
| [**responseRefToNoRef**](FakeApi.md#responseRefToNoRef) | **GET** /ref/no_ref | |
| [**responseRefToRef**](FakeApi.md#responseRefToRef) | **GET** /ref/ref | |
<a id="responseNoRef"></a>
# **responseNoRef**
> String responseNoRef()
### 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);
try {
String result = apiInstance.responseNoRef();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#responseNoRef");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
**String**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | required to pass validation | - |
<a id="responseRefToNoRef"></a>
# **responseRefToNoRef**
> String responseRefToNoRef()
### 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);
try {
String result = apiInstance.responseRefToNoRef();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#responseRefToNoRef");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
**String**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | | - |
<a id="responseRefToRef"></a>
# **responseRefToRef**
> String responseRefToRef()
### 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);
try {
String result = apiInstance.responseRefToRef();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#responseRefToRef");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
**String**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | | - |

View File

@@ -0,0 +1,413 @@
/*
* 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.api;
import org.openapitools.client.ApiCallback;
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.ApiResponse;
import org.openapitools.client.Configuration;
import org.openapitools.client.Pair;
import org.openapitools.client.ProgressRequestBody;
import org.openapitools.client.ProgressResponseBody;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FakeApi {
private ApiClient localVarApiClient;
private int localHostIndex;
private String localCustomBaseUrl;
public FakeApi() {
this(Configuration.getDefaultApiClient());
}
public FakeApi(ApiClient apiClient) {
this.localVarApiClient = apiClient;
}
public ApiClient getApiClient() {
return localVarApiClient;
}
public void setApiClient(ApiClient apiClient) {
this.localVarApiClient = apiClient;
}
public int getHostIndex() {
return localHostIndex;
}
public void setHostIndex(int hostIndex) {
this.localHostIndex = hostIndex;
}
public String getCustomBaseUrl() {
return localCustomBaseUrl;
}
public void setCustomBaseUrl(String customBaseUrl) {
this.localCustomBaseUrl = customBaseUrl;
}
/**
* Build call for responseNoRef
* @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> required to pass validation </td><td> - </td></tr>
</table>
*/
public okhttp3.Call responseNoRefCall(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 = "/no_ref";
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 = {
"text/plain"
};
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 responseNoRefValidateBeforeCall(final ApiCallback _callback) throws ApiException {
return responseNoRefCall(_callback);
}
/**
*
*
* @return String
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> required to pass validation </td><td> - </td></tr>
</table>
*/
public String responseNoRef() throws ApiException {
ApiResponse<String> localVarResp = responseNoRefWithHttpInfo();
return localVarResp.getData();
}
/**
*
*
* @return ApiResponse&lt;String&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> required to pass validation </td><td> - </td></tr>
</table>
*/
public ApiResponse<String> responseNoRefWithHttpInfo() throws ApiException {
okhttp3.Call localVarCall = responseNoRefValidateBeforeCall(null);
Type localVarReturnType = new TypeToken<String>(){}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}
/**
* (asynchronously)
*
* @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> required to pass validation </td><td> - </td></tr>
</table>
*/
public okhttp3.Call responseNoRefAsync(final ApiCallback<String> _callback) throws ApiException {
okhttp3.Call localVarCall = responseNoRefValidateBeforeCall(_callback);
Type localVarReturnType = new TypeToken<String>(){}.getType();
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
/**
* Build call for responseRefToNoRef
* @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> </td><td> - </td></tr>
</table>
*/
public okhttp3.Call responseRefToNoRefCall(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/no_ref";
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 = {
"text/plain"
};
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 responseRefToNoRefValidateBeforeCall(final ApiCallback _callback) throws ApiException {
return responseRefToNoRefCall(_callback);
}
/**
*
*
* @return String
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> </td><td> - </td></tr>
</table>
*/
public String responseRefToNoRef() throws ApiException {
ApiResponse<String> localVarResp = responseRefToNoRefWithHttpInfo();
return localVarResp.getData();
}
/**
*
*
* @return ApiResponse&lt;String&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> </td><td> - </td></tr>
</table>
*/
public ApiResponse<String> responseRefToNoRefWithHttpInfo() throws ApiException {
okhttp3.Call localVarCall = responseRefToNoRefValidateBeforeCall(null);
Type localVarReturnType = new TypeToken<String>(){}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}
/**
* (asynchronously)
*
* @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> </td><td> - </td></tr>
</table>
*/
public okhttp3.Call responseRefToNoRefAsync(final ApiCallback<String> _callback) throws ApiException {
okhttp3.Call localVarCall = responseRefToNoRefValidateBeforeCall(_callback);
Type localVarReturnType = new TypeToken<String>(){}.getType();
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
/**
* Build call for responseRefToRef
* @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> </td><td> - </td></tr>
</table>
*/
public okhttp3.Call responseRefToRefCall(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";
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 = {
"text/plain"
};
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 responseRefToRefValidateBeforeCall(final ApiCallback _callback) throws ApiException {
return responseRefToRefCall(_callback);
}
/**
*
*
* @return String
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> </td><td> - </td></tr>
</table>
*/
public String responseRefToRef() throws ApiException {
ApiResponse<String> localVarResp = responseRefToRefWithHttpInfo();
return localVarResp.getData();
}
/**
*
*
* @return ApiResponse&lt;String&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> </td><td> - </td></tr>
</table>
*/
public ApiResponse<String> responseRefToRefWithHttpInfo() throws ApiException {
okhttp3.Call localVarCall = responseRefToRefValidateBeforeCall(null);
Type localVarReturnType = new TypeToken<String>(){}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}
/**
* (asynchronously)
*
* @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> </td><td> - </td></tr>
</table>
*/
public okhttp3.Call responseRefToRefAsync(final ApiCallback<String> _callback) throws ApiException {
okhttp3.Call localVarCall = responseRefToRefValidateBeforeCall(_callback);
Type localVarReturnType = new TypeToken<String>(){}.getType();
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
}

View File

@@ -0,0 +1,60 @@
/*
* 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.api;
import org.openapitools.client.ApiException;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* API tests for FakeApi
*/
@Disabled
public class FakeApiTest {
private final FakeApi api = new FakeApi();
/**
* @throws ApiException if the Api call fails
*/
@Test
public void responseNoRefTest() throws ApiException {
String response = api.responseNoRef();
// TODO: test validations
}
/**
* @throws ApiException if the Api call fails
*/
@Test
public void responseRefToNoRefTest() throws ApiException {
String response = api.responseRefToNoRef();
// TODO: test validations
}
/**
* @throws ApiException if the Api call fails
*/
@Test
public void responseRefToRefTest() throws ApiException {
String response = api.responseRefToRef();
// TODO: test validations
}
}