add tests for query parameter (array of enum) in 3.1 spec (#18310)

This commit is contained in:
William Cheng 2024-04-06 14:36:41 +08:00 committed by GitHub
parent b11005b00d
commit 3d2e38e347
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 366 additions and 1 deletions

View File

@ -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

View File

@ -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"
}
}

View File

@ -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

View File

@ -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)

View File

@ -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:

View File

@ -0,0 +1,15 @@
# CodesEnum
## Enum
* `_1` (value: `"Code 1"`)
* `_2` (value: `"Code 2"`)
* `_3` (value: `"Code 3"`)

View File

@ -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 | - |
<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)

View File

@ -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
<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)

View File

@ -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<CodesEnum> {
@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);
}
}

View File

@ -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
}
}