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 ebdaa239ea9..1524ddb2d76 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 @@ -647,6 +647,24 @@ paths: application/json: schema: "$ref": "#/components/schemas/HTTPValidationError" + "/fake/api/query/enum": + post: + summary: op3 + operationId: op3 + tags: + - fake + parameters: + - name: query_enum + in: query + description: query enum test + required: true + schema: + type: array + items: + "$ref": "#/components/schemas/CodesEnum" + responses: + '200': + description: Successful Response externalDocs: description: Find out more about Swagger url: 'http://swagger.io' @@ -944,3 +962,9 @@ components: type: array items: $ref: '#/components/schemas/Tag' + CodesEnum: + type: string + enum: + - Code 1 + - Code 2 + - Code 3 diff --git a/openapitools.json b/openapitools.json index 03392961f6f..5120fb6ecf7 100644 --- a/openapitools.json +++ b/openapitools.json @@ -2,6 +2,6 @@ "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", "spaces": 2, "generator-cli": { - "version": "6.3.0" + "version": "7.4.0" } } 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 47d0d7f85f7..67ba8225ef5 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 @@ -14,6 +14,7 @@ docs/Category.md docs/CircularReference1.md docs/CircularReference2.md docs/CircularReference3.md +docs/CodesEnum.md docs/Dog.md docs/FakeApi.md docs/ModelApiResponse.md @@ -70,6 +71,7 @@ src/main/java/org/openapitools/client/model/Category.java src/main/java/org/openapitools/client/model/CircularReference1.java src/main/java/org/openapitools/client/model/CircularReference2.java src/main/java/org/openapitools/client/model/CircularReference3.java +src/main/java/org/openapitools/client/model/CodesEnum.java src/main/java/org/openapitools/client/model/Dog.java src/main/java/org/openapitools/client/model/ModelApiResponse.java src/main/java/org/openapitools/client/model/OneOfStringOrInt.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 05de45aa90e..da8355dc0e8 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/README.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/README.md @@ -115,6 +115,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *FakeApi* | [**op1**](docs/FakeApi.md#op1) | **POST** /fake/api/changeowner | op1 *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* | [**responseNoRef**](docs/FakeApi.md#responseNoRef) | **GET** /no_ref | *FakeApi* | [**responseRefToNoRef**](docs/FakeApi.md#responseRefToNoRef) | **GET** /ref/no_ref | @@ -152,6 +153,7 @@ Class | Method | HTTP request | Description - [CircularReference1](docs/CircularReference1.md) - [CircularReference2](docs/CircularReference2.md) - [CircularReference3](docs/CircularReference3.md) + - [CodesEnum](docs/CodesEnum.md) - [Dog](docs/Dog.md) - [ModelApiResponse](docs/ModelApiResponse.md) - [OneOfStringOrInt](docs/OneOfStringOrInt.md) 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 6d512e1d644..0cfe3e02a4c 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 @@ -729,6 +729,28 @@ paths: - fake x-accepts: - application/json + /fake/api/query/enum: + post: + operationId: op3 + parameters: + - description: query enum test + explode: true + in: query + name: query_enum + required: true + schema: + items: + $ref: '#/components/schemas/CodesEnum' + type: array + style: form + responses: + "200": + description: Successful Response + summary: op3 + tags: + - fake + x-accepts: + - application/json components: parameters: ref_to_uuid: @@ -1041,6 +1063,12 @@ components: items: $ref: '#/components/schemas/Tag' type: array + CodesEnum: + enum: + - Code 1 + - Code 2 + - Code 3 + type: string updatePetWithForm_request: properties: name: diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/CodesEnum.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/CodesEnum.md new file mode 100644 index 00000000000..efdb32e2ce3 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/CodesEnum.md @@ -0,0 +1,15 @@ + + +# CodesEnum + +## Enum + + +* `_1` (value: `"Code 1"`) + +* `_2` (value: `"Code 2"`) + +* `_3` (value: `"Code 3"`) + + + 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 index a4c5c8b350e..12709419253 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/FakeApi.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/FakeApi.md @@ -6,6 +6,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* |------------- | ------------- | -------------| | [**op1**](FakeApi.md#op1) | **POST** /fake/api/changeowner | op1 | | [**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 | | | [**responseNoRef**](FakeApi.md#responseNoRef) | **GET** /no_ref | | | [**responseRefToNoRef**](FakeApi.md#responseRefToNoRef) | **GET** /ref/no_ref | | @@ -126,6 +127,65 @@ No authorization required | **201** | Successful Response | - | | **422** | Validation Error | - | + +# **op3** +> op3(queryEnum) + +op3 + +### 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); + List queryEnum = Arrays.asList(); // List | query enum test + try { + apiInstance.op3(queryEnum); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#op3"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **queryEnum** | [**List<CodesEnum>**](CodesEnum.md)| query enum test | | + +### 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 | - | + # **refToRefParameter** > String refToRefParameter(refToUuid) 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 index 54a7d12652a..198eb7a1ba6 100644 --- 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 @@ -27,6 +27,7 @@ import com.google.gson.reflect.TypeToken; import java.io.IOException; +import org.openapitools.client.model.CodesEnum; import java.util.UUID; import java.lang.reflect.Type; @@ -306,6 +307,127 @@ public class FakeApi { localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for op3 + * @param queryEnum query enum test (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 Successful Response -
+ */ + public okhttp3.Call op3Call(List queryEnum, 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/api/query/enum"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (queryEnum != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("multi", "query_enum", queryEnum)); + } + + 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 op3ValidateBeforeCall(List queryEnum, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'queryEnum' is set + if (queryEnum == null) { + throw new ApiException("Missing the required parameter 'queryEnum' when calling op3(Async)"); + } + + return op3Call(queryEnum, _callback); + + } + + /** + * op3 + * + * @param queryEnum query enum test (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 Successful Response -
+ */ + public void op3(List queryEnum) throws ApiException { + op3WithHttpInfo(queryEnum); + } + + /** + * op3 + * + * @param queryEnum query enum test (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 Successful Response -
+ */ + public ApiResponse op3WithHttpInfo(List queryEnum) throws ApiException { + okhttp3.Call localVarCall = op3ValidateBeforeCall(queryEnum, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * op3 (asynchronously) + * + * @param queryEnum query enum test (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 Successful Response -
+ */ + public okhttp3.Call op3Async(List queryEnum, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = op3ValidateBeforeCall(queryEnum, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } /** * Build call for refToRefParameter * @param refToUuid to test ref to parameter (uuid) (required) diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/CodesEnum.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/CodesEnum.java new file mode 100644 index 00000000000..9d6d575fa55 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/CodesEnum.java @@ -0,0 +1,80 @@ +/* + * 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 com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets CodesEnum + */ +@JsonAdapter(CodesEnum.Adapter.class) +public enum CodesEnum { + + _1("Code 1"), + + _2("Code 2"), + + _3("Code 3"); + + private String value; + + CodesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CodesEnum fromValue(String value) { + for (CodesEnum b : CodesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CodesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CodesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CodesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CodesEnum.fromValue(value); + } +} + diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/test/java/org/openapitools/client/model/CodesEnumTest.java b/samples/client/petstore/java/okhttp-gson-3.1/src/test/java/org/openapitools/client/model/CodesEnumTest.java new file mode 100644 index 00000000000..37a98f3899c --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/test/java/org/openapitools/client/model/CodesEnumTest.java @@ -0,0 +1,32 @@ +/* + * 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 com.google.gson.annotations.SerializedName; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for CodesEnum + */ +public class CodesEnumTest { + /** + * Model tests for CodesEnum + */ + @Test + public void testCodesEnum() { + // TODO: test CodesEnum + } + +}