Skip to content

Commit

Permalink
add tests for query parameter (array of enum) in 3.1 spec (#18310)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 authored Apr 6, 2024
1 parent b11005b commit 3d2e38e
Show file tree
Hide file tree
Showing 10 changed files with 366 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -944,3 +962,9 @@ components:
type: array
items:
$ref: '#/components/schemas/Tag'
CodesEnum:
type: string
enum:
- Code 1
- Code 2
- Code 3
2 changes: 1 addition & 1 deletion openapitools.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions samples/client/petstore/java/okhttp-gson-3.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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)
Expand Down
28 changes: 28 additions & 0 deletions samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 15 additions & 0 deletions samples/client/petstore/java/okhttp-gson-3.1/docs/CodesEnum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


# CodesEnum

## Enum


* `_1` (value: `"Code 1"`)

* `_2` (value: `"Code 2"`)

* `_3` (value: `"Code 3"`)



60 changes: 60 additions & 0 deletions samples/client/petstore/java/okhttp-gson-3.1/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
Expand Down Expand Up @@ -126,6 +127,65 @@ No authorization required
| **201** | Successful Response | - |
| **422** | Validation Error | - |

<a id="op3"></a>
# **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<CodesEnum> queryEnum = Arrays.asList(); // List<CodesEnum> | 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&lt;CodesEnum&gt;**](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 | - |

<a id="refToRefParameter"></a>
# **refToRefParameter**
> String refToRefParameter(refToUuid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.IOException;


import org.openapitools.client.model.CodesEnum;
import java.util.UUID;

import java.lang.reflect.Type;
Expand Down Expand Up @@ -306,6 +307,127 @@ public okhttp3.Call op2Async(final ApiCallback<Object> _callback) throws ApiExce
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
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> Successful Response </td><td> - </td></tr>
</table>
*/
public okhttp3.Call op3Call(List<CodesEnum> 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<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>();

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<CodesEnum> 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
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> Successful Response </td><td> - </td></tr>
</table>
*/
public void op3(List<CodesEnum> queryEnum) throws ApiException {
op3WithHttpInfo(queryEnum);
}

/**
* op3
*
* @param queryEnum query enum test (required)
* @return ApiResponse&lt;Void&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> Successful Response </td><td> - </td></tr>
</table>
*/
public ApiResponse<Void> op3WithHttpInfo(List<CodesEnum> 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
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> Successful Response </td><td> - </td></tr>
</table>
*/
public okhttp3.Call op3Async(List<CodesEnum> queryEnum, final ApiCallback<Void> _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)
Expand Down
Loading

0 comments on commit 3d2e38e

Please sign in to comment.