diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0a41d14fa26a..0e596306d9dd 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -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. diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 8ae9935e190c..6bbbdb567c11 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -1019,7 +1019,7 @@ public void preprocessOpenAPI(OpenAPI openAPI) { if (op.getValue().getResponses() != null) { for (Map.Entry 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 @@ protected void handleMethodResponse(Operation operation, CodegenOperation op, ApiResponse methodResponse, Map 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 CodegenResponse fromResponse(String responseCode, ApiResponse response) { } else { r.code = responseCode; switch (r.code.charAt(0)) { + case '1': r.is1xx = true; break; @@ -4835,12 +4836,11 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) { 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 diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java index ebe004e8fe58..115e05ea06b8 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java @@ -188,7 +188,8 @@ void normalize() { } normalizePaths(); - normalizeComponents(); + normalizeComponentsSchemas(); + normalizeComponentsResponses(); } /** @@ -346,7 +347,7 @@ private void normalizeHeaders(Map headers) { /** * Normalizes schemas in components */ - private void normalizeComponents() { + private void normalizeComponentsSchemas() { Map schemas = openAPI.getComponents().getSchemas(); if (schemas == null) { return; @@ -364,6 +365,33 @@ private void normalizeComponents() { } } + /** + * Normalizes responses in components + */ + private void normalizeComponentsResponses() { + Map schemas = openAPI.getComponents().getResponses(); + if (schemas == null) { + return; + } + + List schemaNames = new ArrayList(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 entry : content.entrySet()) { + Schema entryResult = normalizeSchema(entry.getValue().getSchema(), new HashSet<>()); + entry.getValue().setSchema(entryResult); + } + } + } + } + /** * Normalizes a schema * diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java index 97616dcaf3ca..92bdcfcba52b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java @@ -573,7 +573,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation 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 example : op.examples) { example.put("example", escapeText(example.get("example"))); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java index 755cf3aac272..aceefd0f3c4b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java @@ -244,7 +244,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation 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); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java index 032f53f08a01..ca90e4b89560 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java @@ -294,7 +294,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation 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); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java index 3cfe890f600b..a5e6be37b78b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java @@ -530,7 +530,7 @@ public ExtendedCodegenOperation fromOperation(String path, String httpMethod, Op } 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); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java index dc967b95f277..8a4069ea5c2a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java @@ -1009,11 +1009,12 @@ public static Schema getSchemaFromRequestBody(RequestBody requestBody) { /** * 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()); } /** diff --git a/modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml b/modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml index 10bd7699fa2e..8436db263809 100644 --- a/modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml @@ -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 diff --git a/samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES b/samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES index af9fa6831fb6..a90799f32aab 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES +++ b/samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES @@ -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 diff --git a/samples/client/petstore/java/okhttp-gson-3.1/README.md b/samples/client/petstore/java/okhttp-gson-3.1/README.md index 4d1472eaa92a..c285ab1f2b66 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/README.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/README.md @@ -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 diff --git a/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml b/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml index bc23e2bb6c6c..9a17e6da6e45 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml +++ b/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml @@ -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: diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/FakeApi.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/FakeApi.md new file mode 100644 index 000000000000..ac0793307ab9 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/FakeApi.md @@ -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 | | + + + +# **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 | - | + + +# **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** | | - | + + +# **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** | | - | + diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/FakeApi.java new file mode 100644 index 000000000000..d20d03caea52 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/FakeApi.java @@ -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 + + + +
Status Code Description Response Headers
200 required to pass validation -
+ */ + 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 localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + 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 + + + +
Status Code Description Response Headers
200 required to pass validation -
+ */ + public String responseNoRef() throws ApiException { + ApiResponse localVarResp = responseNoRefWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * + * + * @return ApiResponse<String> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 required to pass validation -
+ */ + public ApiResponse responseNoRefWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = responseNoRefValidateBeforeCall(null); + Type localVarReturnType = new TypeToken(){}.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 + + + +
Status Code Description Response Headers
200 required to pass validation -
+ */ + public okhttp3.Call responseNoRefAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = responseNoRefValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken(){}.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 + + + +
Status Code Description Response Headers
200 -
+ */ + 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 localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + 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 + + + +
Status Code Description Response Headers
200 -
+ */ + public String responseRefToNoRef() throws ApiException { + ApiResponse localVarResp = responseRefToNoRefWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * + * + * @return ApiResponse<String> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 -
+ */ + public ApiResponse responseRefToNoRefWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = responseRefToNoRefValidateBeforeCall(null); + Type localVarReturnType = new TypeToken(){}.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 + + + +
Status Code Description Response Headers
200 -
+ */ + public okhttp3.Call responseRefToNoRefAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = responseRefToNoRefValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken(){}.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 + + + +
Status Code Description Response Headers
200 -
+ */ + 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 localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + 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 + + + +
Status Code Description Response Headers
200 -
+ */ + public String responseRefToRef() throws ApiException { + ApiResponse localVarResp = responseRefToRefWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * + * + * @return ApiResponse<String> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 -
+ */ + public ApiResponse responseRefToRefWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = responseRefToRefValidateBeforeCall(null); + Type localVarReturnType = new TypeToken(){}.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 + + + +
Status Code Description Response Headers
200 -
+ */ + public okhttp3.Call responseRefToRefAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = responseRefToRefValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/test/java/org/openapitools/client/api/FakeApiTest.java b/samples/client/petstore/java/okhttp-gson-3.1/src/test/java/org/openapitools/client/api/FakeApiTest.java new file mode 100644 index 000000000000..097e64f0218d --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/test/java/org/openapitools/client/api/FakeApiTest.java @@ -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 + } + +}