diff --git a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml index 0bf7e4f6684..460bb4223df 100644 --- a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml @@ -1138,6 +1138,23 @@ paths: responses: 200: description: OK + /fake/parameter-string-number: + get: + tags: + - another_fake + summary: parameter string number + operationId: getParameterStringNumber + parameters: + - name: string_number + in: header + description: string number + required: true + schema: + type: string + format: number + responses: + 200: + description: OK /values: get: tags: diff --git a/samples/client/petstore/java/okhttp-gson/README.md b/samples/client/petstore/java/okhttp-gson/README.md index d582a2fceb2..6098ec22136 100644 --- a/samples/client/petstore/java/okhttp-gson/README.md +++ b/samples/client/petstore/java/okhttp-gson/README.md @@ -114,6 +114,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags +*AnotherFakeApi* | [**getParameterStringNumber**](docs/AnotherFakeApi.md#getParameterStringNumber) | **GET** /fake/parameter-string-number | parameter string number *DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooGet) | **GET** /foo | *FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint *FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | diff --git a/samples/client/petstore/java/okhttp-gson/api/openapi.yaml b/samples/client/petstore/java/okhttp-gson/api/openapi.yaml index 45829b3ca51..9bb8dc69d5f 100644 --- a/samples/client/petstore/java/okhttp-gson/api/openapi.yaml +++ b/samples/client/petstore/java/okhttp-gson/api/openapi.yaml @@ -1168,6 +1168,26 @@ paths: tags: - fake x-accepts: application/json + /fake/parameter-string-number: + get: + operationId: getParameterStringNumber + parameters: + - description: string number + explode: false + in: header + name: string_number + required: true + schema: + format: number + type: string + style: simple + responses: + "200": + description: OK + summary: parameter string number + tags: + - another_fake + x-accepts: application/json /values: get: description: "" diff --git a/samples/client/petstore/java/okhttp-gson/docs/AnotherFakeApi.md b/samples/client/petstore/java/okhttp-gson/docs/AnotherFakeApi.md index 727c13a88e9..4ab44475b39 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/AnotherFakeApi.md +++ b/samples/client/petstore/java/okhttp-gson/docs/AnotherFakeApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |------------- | ------------- | -------------| | [**call123testSpecialTags**](AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags | +| [**getParameterStringNumber**](AnotherFakeApi.md#getParameterStringNumber) | **GET** /fake/parameter-string-number | parameter string number | @@ -69,3 +70,62 @@ No authorization required |-------------|-------------|------------------| | **200** | successful operation | - | + +# **getParameterStringNumber** +> getParameterStringNumber(stringNumber) + +parameter string number + +### Example +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.AnotherFakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + AnotherFakeApi apiInstance = new AnotherFakeApi(defaultClient); + BigDecimal stringNumber = new BigDecimal(78); // BigDecimal | string number + try { + apiInstance.getParameterStringNumber(stringNumber); + } catch (ApiException e) { + System.err.println("Exception when calling AnotherFakeApi#getParameterStringNumber"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **stringNumber** | **BigDecimal**| string number | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index 4eae861ab85..2711ffbb8a6 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -27,6 +27,7 @@ import com.google.gson.reflect.TypeToken; import java.io.IOException; +import java.math.BigDecimal; import org.openapitools.client.model.Client; import java.lang.reflect.Type; @@ -195,4 +196,125 @@ public class AnotherFakeApi { localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for getParameterStringNumber + * @param stringNumber string number (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK -
+ */ + public okhttp3.Call getParameterStringNumberCall(BigDecimal stringNumber, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/fake/parameter-string-number"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (stringNumber != null) { + localVarHeaderParams.put("string_number", localVarApiClient.parameterToString(stringNumber)); + } + + final String[] localVarAccepts = { + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getParameterStringNumberValidateBeforeCall(BigDecimal stringNumber, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'stringNumber' is set + if (stringNumber == null) { + throw new ApiException("Missing the required parameter 'stringNumber' when calling getParameterStringNumber(Async)"); + } + + return getParameterStringNumberCall(stringNumber, _callback); + + } + + /** + * parameter string number + * + * @param stringNumber string number (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK -
+ */ + public void getParameterStringNumber(BigDecimal stringNumber) throws ApiException { + getParameterStringNumberWithHttpInfo(stringNumber); + } + + /** + * parameter string number + * + * @param stringNumber string number (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK -
+ */ + public ApiResponse getParameterStringNumberWithHttpInfo(BigDecimal stringNumber) throws ApiException { + okhttp3.Call localVarCall = getParameterStringNumberValidateBeforeCall(stringNumber, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * parameter string number (asynchronously) + * + * @param stringNumber string number (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK -
+ */ + public okhttp3.Call getParameterStringNumberAsync(BigDecimal stringNumber, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getParameterStringNumberValidateBeforeCall(stringNumber, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } } diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java index 0f49c5e2e01..b6162a1f3e3 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java @@ -2,23 +2,31 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * - * OpenAPI spec version: 1.0.0 - * + * The version of the OpenAPI document: 1.0.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package org.openapitools.client.api; - +import org.openapitools.client.ApiException; +import java.math.BigDecimal; +import org.openapitools.client.model.Client; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.openapitools.client.ApiException; -import org.openapitools.client.model.Client; -/** API tests for AnotherFakeApi */ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * API tests for AnotherFakeApi + */ @Disabled public class AnotherFakeApiTest { @@ -27,15 +35,27 @@ public class AnotherFakeApiTest { /** * To test special tags * - *

To test special tags and operation ID starting with number + * To test special tags and operation ID starting with number * * @throws ApiException if the Api call fails */ @Test public void call123testSpecialTagsTest() throws ApiException { - Client body = null; - Client response = api.call123testSpecialTags(body); - + Client client = null; + Client response = api.call123testSpecialTags(client); // TODO: test validations } + + /** + * parameter string number + * + * @throws ApiException if the Api call fails + */ + @Test + public void getParameterStringNumberTest() throws ApiException { + BigDecimal stringNumber = null; + api.getParameterStringNumber(stringNumber); + // TODO: test validations + } + }