Skip to content

Commit 3d2e38e

Browse files
authored
add tests for query parameter (array of enum) in 3.1 spec (OpenAPITools#18310)
1 parent b11005b commit 3d2e38e

File tree

10 files changed

+366
-1
lines changed

10 files changed

+366
-1
lines changed

modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,24 @@ paths:
647647
application/json:
648648
schema:
649649
"$ref": "#/components/schemas/HTTPValidationError"
650+
"/fake/api/query/enum":
651+
post:
652+
summary: op3
653+
operationId: op3
654+
tags:
655+
- fake
656+
parameters:
657+
- name: query_enum
658+
in: query
659+
description: query enum test
660+
required: true
661+
schema:
662+
type: array
663+
items:
664+
"$ref": "#/components/schemas/CodesEnum"
665+
responses:
666+
'200':
667+
description: Successful Response
650668
externalDocs:
651669
description: Find out more about Swagger
652670
url: 'http://swagger.io'
@@ -944,3 +962,9 @@ components:
944962
type: array
945963
items:
946964
$ref: '#/components/schemas/Tag'
965+
CodesEnum:
966+
type: string
967+
enum:
968+
- Code 1
969+
- Code 2
970+
- Code 3

openapitools.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
33
"spaces": 2,
44
"generator-cli": {
5-
"version": "6.3.0"
5+
"version": "7.4.0"
66
}
77
}

samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ docs/Category.md
1414
docs/CircularReference1.md
1515
docs/CircularReference2.md
1616
docs/CircularReference3.md
17+
docs/CodesEnum.md
1718
docs/Dog.md
1819
docs/FakeApi.md
1920
docs/ModelApiResponse.md
@@ -70,6 +71,7 @@ src/main/java/org/openapitools/client/model/Category.java
7071
src/main/java/org/openapitools/client/model/CircularReference1.java
7172
src/main/java/org/openapitools/client/model/CircularReference2.java
7273
src/main/java/org/openapitools/client/model/CircularReference3.java
74+
src/main/java/org/openapitools/client/model/CodesEnum.java
7375
src/main/java/org/openapitools/client/model/Dog.java
7476
src/main/java/org/openapitools/client/model/ModelApiResponse.java
7577
src/main/java/org/openapitools/client/model/OneOfStringOrInt.java

samples/client/petstore/java/okhttp-gson-3.1/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ Class | Method | HTTP request | Description
115115
------------ | ------------- | ------------- | -------------
116116
*FakeApi* | [**op1**](docs/FakeApi.md#op1) | **POST** /fake/api/changeowner | op1
117117
*FakeApi* | [**op2**](docs/FakeApi.md#op2) | **POST** /fake/api/changename | op2
118+
*FakeApi* | [**op3**](docs/FakeApi.md#op3) | **POST** /fake/api/query/enum | op3
118119
*FakeApi* | [**refToRefParameter**](docs/FakeApi.md#refToRefParameter) | **GET** /ref/ref_to_parameter |
119120
*FakeApi* | [**responseNoRef**](docs/FakeApi.md#responseNoRef) | **GET** /no_ref |
120121
*FakeApi* | [**responseRefToNoRef**](docs/FakeApi.md#responseRefToNoRef) | **GET** /ref/no_ref |
@@ -152,6 +153,7 @@ Class | Method | HTTP request | Description
152153
- [CircularReference1](docs/CircularReference1.md)
153154
- [CircularReference2](docs/CircularReference2.md)
154155
- [CircularReference3](docs/CircularReference3.md)
156+
- [CodesEnum](docs/CodesEnum.md)
155157
- [Dog](docs/Dog.md)
156158
- [ModelApiResponse](docs/ModelApiResponse.md)
157159
- [OneOfStringOrInt](docs/OneOfStringOrInt.md)

samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,28 @@ paths:
729729
- fake
730730
x-accepts:
731731
- application/json
732+
/fake/api/query/enum:
733+
post:
734+
operationId: op3
735+
parameters:
736+
- description: query enum test
737+
explode: true
738+
in: query
739+
name: query_enum
740+
required: true
741+
schema:
742+
items:
743+
$ref: '#/components/schemas/CodesEnum'
744+
type: array
745+
style: form
746+
responses:
747+
"200":
748+
description: Successful Response
749+
summary: op3
750+
tags:
751+
- fake
752+
x-accepts:
753+
- application/json
732754
components:
733755
parameters:
734756
ref_to_uuid:
@@ -1041,6 +1063,12 @@ components:
10411063
items:
10421064
$ref: '#/components/schemas/Tag'
10431065
type: array
1066+
CodesEnum:
1067+
enum:
1068+
- Code 1
1069+
- Code 2
1070+
- Code 3
1071+
type: string
10441072
updatePetWithForm_request:
10451073
properties:
10461074
name:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
3+
# CodesEnum
4+
5+
## Enum
6+
7+
8+
* `_1` (value: `"Code 1"`)
9+
10+
* `_2` (value: `"Code 2"`)
11+
12+
* `_3` (value: `"Code 3"`)
13+
14+
15+

samples/client/petstore/java/okhttp-gson-3.1/docs/FakeApi.md

+60
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All URIs are relative to *http://petstore.swagger.io/v2*
66
|------------- | ------------- | -------------|
77
| [**op1**](FakeApi.md#op1) | **POST** /fake/api/changeowner | op1 |
88
| [**op2**](FakeApi.md#op2) | **POST** /fake/api/changename | op2 |
9+
| [**op3**](FakeApi.md#op3) | **POST** /fake/api/query/enum | op3 |
910
| [**refToRefParameter**](FakeApi.md#refToRefParameter) | **GET** /ref/ref_to_parameter | |
1011
| [**responseNoRef**](FakeApi.md#responseNoRef) | **GET** /no_ref | |
1112
| [**responseRefToNoRef**](FakeApi.md#responseRefToNoRef) | **GET** /ref/no_ref | |
@@ -126,6 +127,65 @@ No authorization required
126127
| **201** | Successful Response | - |
127128
| **422** | Validation Error | - |
128129

130+
<a id="op3"></a>
131+
# **op3**
132+
> op3(queryEnum)
133+
134+
op3
135+
136+
### Example
137+
```java
138+
// Import classes:
139+
import org.openapitools.client.ApiClient;
140+
import org.openapitools.client.ApiException;
141+
import org.openapitools.client.Configuration;
142+
import org.openapitools.client.models.*;
143+
import org.openapitools.client.api.FakeApi;
144+
145+
public class Example {
146+
public static void main(String[] args) {
147+
ApiClient defaultClient = Configuration.getDefaultApiClient();
148+
defaultClient.setBasePath("http://petstore.swagger.io/v2");
149+
150+
FakeApi apiInstance = new FakeApi(defaultClient);
151+
List<CodesEnum> queryEnum = Arrays.asList(); // List<CodesEnum> | query enum test
152+
try {
153+
apiInstance.op3(queryEnum);
154+
} catch (ApiException e) {
155+
System.err.println("Exception when calling FakeApi#op3");
156+
System.err.println("Status code: " + e.getCode());
157+
System.err.println("Reason: " + e.getResponseBody());
158+
System.err.println("Response headers: " + e.getResponseHeaders());
159+
e.printStackTrace();
160+
}
161+
}
162+
}
163+
```
164+
165+
### Parameters
166+
167+
| Name | Type | Description | Notes |
168+
|------------- | ------------- | ------------- | -------------|
169+
| **queryEnum** | [**List&lt;CodesEnum&gt;**](CodesEnum.md)| query enum test | |
170+
171+
### Return type
172+
173+
null (empty response body)
174+
175+
### Authorization
176+
177+
No authorization required
178+
179+
### HTTP request headers
180+
181+
- **Content-Type**: Not defined
182+
- **Accept**: Not defined
183+
184+
### HTTP response details
185+
| Status code | Description | Response headers |
186+
|-------------|-------------|------------------|
187+
| **200** | Successful Response | - |
188+
129189
<a id="refToRefParameter"></a>
130190
# **refToRefParameter**
131191
> String refToRefParameter(refToUuid)

samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/FakeApi.java

+122
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.io.IOException;
2828

2929

30+
import org.openapitools.client.model.CodesEnum;
3031
import java.util.UUID;
3132

3233
import java.lang.reflect.Type;
@@ -306,6 +307,127 @@ public okhttp3.Call op2Async(final ApiCallback<Object> _callback) throws ApiExce
306307
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
307308
return localVarCall;
308309
}
310+
/**
311+
* Build call for op3
312+
* @param queryEnum query enum test (required)
313+
* @param _callback Callback for upload/download progress
314+
* @return Call to execute
315+
* @throws ApiException If fail to serialize the request body object
316+
* @http.response.details
317+
<table summary="Response Details" border="1">
318+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
319+
<tr><td> 200 </td><td> Successful Response </td><td> - </td></tr>
320+
</table>
321+
*/
322+
public okhttp3.Call op3Call(List<CodesEnum> queryEnum, final ApiCallback _callback) throws ApiException {
323+
String basePath = null;
324+
// Operation Servers
325+
String[] localBasePaths = new String[] { };
326+
327+
// Determine Base Path to Use
328+
if (localCustomBaseUrl != null){
329+
basePath = localCustomBaseUrl;
330+
} else if ( localBasePaths.length > 0 ) {
331+
basePath = localBasePaths[localHostIndex];
332+
} else {
333+
basePath = null;
334+
}
335+
336+
Object localVarPostBody = null;
337+
338+
// create path and map variables
339+
String localVarPath = "/fake/api/query/enum";
340+
341+
List<Pair> localVarQueryParams = new ArrayList<Pair>();
342+
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
343+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
344+
Map<String, String> localVarCookieParams = new HashMap<String, String>();
345+
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
346+
347+
if (queryEnum != null) {
348+
localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("multi", "query_enum", queryEnum));
349+
}
350+
351+
final String[] localVarAccepts = {
352+
};
353+
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
354+
if (localVarAccept != null) {
355+
localVarHeaderParams.put("Accept", localVarAccept);
356+
}
357+
358+
final String[] localVarContentTypes = {
359+
};
360+
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
361+
if (localVarContentType != null) {
362+
localVarHeaderParams.put("Content-Type", localVarContentType);
363+
}
364+
365+
String[] localVarAuthNames = new String[] { };
366+
return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
367+
}
368+
369+
@SuppressWarnings("rawtypes")
370+
private okhttp3.Call op3ValidateBeforeCall(List<CodesEnum> queryEnum, final ApiCallback _callback) throws ApiException {
371+
// verify the required parameter 'queryEnum' is set
372+
if (queryEnum == null) {
373+
throw new ApiException("Missing the required parameter 'queryEnum' when calling op3(Async)");
374+
}
375+
376+
return op3Call(queryEnum, _callback);
377+
378+
}
379+
380+
/**
381+
* op3
382+
*
383+
* @param queryEnum query enum test (required)
384+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
385+
* @http.response.details
386+
<table summary="Response Details" border="1">
387+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
388+
<tr><td> 200 </td><td> Successful Response </td><td> - </td></tr>
389+
</table>
390+
*/
391+
public void op3(List<CodesEnum> queryEnum) throws ApiException {
392+
op3WithHttpInfo(queryEnum);
393+
}
394+
395+
/**
396+
* op3
397+
*
398+
* @param queryEnum query enum test (required)
399+
* @return ApiResponse&lt;Void&gt;
400+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
401+
* @http.response.details
402+
<table summary="Response Details" border="1">
403+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
404+
<tr><td> 200 </td><td> Successful Response </td><td> - </td></tr>
405+
</table>
406+
*/
407+
public ApiResponse<Void> op3WithHttpInfo(List<CodesEnum> queryEnum) throws ApiException {
408+
okhttp3.Call localVarCall = op3ValidateBeforeCall(queryEnum, null);
409+
return localVarApiClient.execute(localVarCall);
410+
}
411+
412+
/**
413+
* op3 (asynchronously)
414+
*
415+
* @param queryEnum query enum test (required)
416+
* @param _callback The callback to be executed when the API call finishes
417+
* @return The request call
418+
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
419+
* @http.response.details
420+
<table summary="Response Details" border="1">
421+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
422+
<tr><td> 200 </td><td> Successful Response </td><td> - </td></tr>
423+
</table>
424+
*/
425+
public okhttp3.Call op3Async(List<CodesEnum> queryEnum, final ApiCallback<Void> _callback) throws ApiException {
426+
427+
okhttp3.Call localVarCall = op3ValidateBeforeCall(queryEnum, _callback);
428+
localVarApiClient.executeAsync(localVarCall, _callback);
429+
return localVarCall;
430+
}
309431
/**
310432
* Build call for refToRefParameter
311433
* @param refToUuid to test ref to parameter (uuid) (required)

0 commit comments

Comments
 (0)