Skip to content

Commit

Permalink
Add a sample of an enum model array in query params (#12107)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhnroyal authored Apr 12, 2022
1 parent 15e9d4e commit 478ed9b
Show file tree
Hide file tree
Showing 46 changed files with 315 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ dev_dependencies:
built_value_generator: '>=8.1.0 <9.0.0'
build_runner: any
{{/useBuiltValue}}
test: '>=1.16.0 <1.17.0'
test: ^1.16.0
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ dynamic encodeQueryParameter(
return serialized;
}

ListParam<T> encodeCollectionQueryParameter<T>(
ListParam<Object?> encodeCollectionQueryParameter<T>(
Serializers serializers,
dynamic value,
FullType type, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,12 @@ paths:
enum:
- 1.1
- -1.2
- name: enum_query_model_array
in: query
schema:
type: array
items:
$ref: '#/components/schemas/EnumClass'
responses:
'400':
description: Invalid request
Expand Down
6 changes: 4 additions & 2 deletions samples/client/petstore/csharp/OpenAPIClient/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ void (empty response body)

## TestEnumParameters

> void TestEnumParameters (List<string> enumHeaderStringArray = null, string enumHeaderString = null, List<string> enumQueryStringArray = null, string enumQueryString = null, int? enumQueryInteger = null, double? enumQueryDouble = null, List<string> enumFormStringArray = null, string enumFormString = null)
> void TestEnumParameters (List<string> enumHeaderStringArray = null, string enumHeaderString = null, List<string> enumQueryStringArray = null, string enumQueryString = null, int? enumQueryInteger = null, double? enumQueryDouble = null, List<EnumClass> enumQueryModelArray = null, List<string> enumFormStringArray = null, string enumFormString = null)
To test enum parameters

Expand Down Expand Up @@ -982,13 +982,14 @@ namespace Example
var enumQueryString = "_abc"; // string | Query parameter enum test (string) (optional) (default to -efg)
var enumQueryInteger = 1; // int? | Query parameter enum test (double) (optional)
var enumQueryDouble = 1.1D; // double? | Query parameter enum test (double) (optional)
var enumQueryModelArray = new List<EnumClass>(); // List<EnumClass> | (optional)
var enumFormStringArray = new List<string>(); // List<string> | Form parameter enum test (string array) (optional) (default to $)
var enumFormString = "_abc"; // string | Form parameter enum test (string) (optional) (default to -efg)
try
{
// To test enum parameters
apiInstance.TestEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString);
apiInstance.TestEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumQueryModelArray, enumFormStringArray, enumFormString);
}
catch (ApiException e)
{
Expand All @@ -1012,6 +1013,7 @@ Name | Type | Description | Notes
**enumQueryString** | **string**| Query parameter enum test (string) | [optional] [default to -efg]
**enumQueryInteger** | **int?**| Query parameter enum test (double) | [optional]
**enumQueryDouble** | **double?**| Query parameter enum test (double) | [optional]
**enumQueryModelArray** | [**List&lt;EnumClass&gt;**](EnumClass.md)| | [optional]
**enumFormStringArray** | [**List&lt;string&gt;**](string.md)| Form parameter enum test (string array) | [optional] [default to $]
**enumFormString** | **string**| Form parameter enum test (string) | [optional] [default to -efg]

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ defmodule OpenapiPetstore.Api.Fake do
- :enum_query_string (String.t): Query parameter enum test (string)
- :enum_query_integer (integer()): Query parameter enum test (double)
- :enum_query_double (float()): Query parameter enum test (double)
- :enum_query_model_array ([OpenapiPetstore.Model.EnumClass.t]):
- :enum_form_string_array ([String.t]): Form parameter enum test (string array)
- :enum_form_string (String.t): Form parameter enum test (string)
## Returns
Expand All @@ -407,6 +408,7 @@ defmodule OpenapiPetstore.Api.Fake do
:"enum_query_string" => :query,
:"enum_query_integer" => :query,
:"enum_query_double" => :query,
:"enum_query_model_array" => :query,
:"enum_form_string_array" => :form,
:"enum_form_string" => :form
}
Expand Down
9 changes: 9 additions & 0 deletions samples/client/petstore/java/feign/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,15 @@ paths:
format: double
type: number
style: form
- explode: true
in: query
name: enum_query_model_array
required: false
schema:
items:
$ref: '#/components/schemas/EnumClass'
type: array
style: form
requestBody:
$ref: '#/components/requestBodies/inline_object_2'
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.math.BigDecimal;
import org.openapitools.client.model.Client;
import org.openapitools.client.model.EnumClass;
import java.io.File;
import org.openapitools.client.model.FileSchemaTestClass;
import org.openapitools.client.model.HealthCheckResult;
Expand Down Expand Up @@ -511,18 +512,19 @@ public TestBodyWithQueryParamsQueryParams query(final String value) {
* @param enumQueryString Query parameter enum test (string) (optional, default to -efg)
* @param enumQueryInteger Query parameter enum test (double) (optional)
* @param enumQueryDouble Query parameter enum test (double) (optional)
* @param enumQueryModelArray (optional)
* @param enumFormStringArray Form parameter enum test (string array) (optional)
* @param enumFormString Form parameter enum test (string) (optional, default to -efg)
*/
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}&enum_query_double={enumQueryDouble}")
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}&enum_query_double={enumQueryDouble}&enum_query_model_array={enumQueryModelArray}")
@Headers({
"Content-Type: application/x-www-form-urlencoded",
"Accept: application/json",
"enum_header_string_array: {enumHeaderStringArray}",

"enum_header_string: {enumHeaderString}"
})
void testEnumParameters(@Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List<String> enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble, @Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString);
void testEnumParameters(@Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List<String> enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble, @Param("enumQueryModelArray") List<EnumClass> enumQueryModelArray, @Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString);

/**
* To test enum parameters
Expand All @@ -534,18 +536,19 @@ public TestBodyWithQueryParamsQueryParams query(final String value) {
* @param enumQueryString Query parameter enum test (string) (optional, default to -efg)
* @param enumQueryInteger Query parameter enum test (double) (optional)
* @param enumQueryDouble Query parameter enum test (double) (optional)
* @param enumQueryModelArray (optional)
* @param enumFormStringArray Form parameter enum test (string array) (optional)
* @param enumFormString Form parameter enum test (string) (optional, default to -efg)
*/
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}&enum_query_double={enumQueryDouble}")
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}&enum_query_double={enumQueryDouble}&enum_query_model_array={enumQueryModelArray}")
@Headers({
"Content-Type: application/x-www-form-urlencoded",
"Accept: application/json",
"enum_header_string_array: {enumHeaderStringArray}",

"enum_header_string: {enumHeaderString}"
})
ApiResponse<Void> testEnumParametersWithHttpInfo(@Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List<String> enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble, @Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString);
ApiResponse<Void> testEnumParametersWithHttpInfo(@Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List<String> enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble, @Param("enumQueryModelArray") List<EnumClass> enumQueryModelArray, @Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString);


/**
Expand All @@ -567,9 +570,10 @@ public TestBodyWithQueryParamsQueryParams query(final String value) {
* <li>enumQueryString - Query parameter enum test (string) (optional, default to -efg)</li>
* <li>enumQueryInteger - Query parameter enum test (double) (optional)</li>
* <li>enumQueryDouble - Query parameter enum test (double) (optional)</li>
* <li>enumQueryModelArray - (optional)</li>
* </ul>
*/
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}&enum_query_double={enumQueryDouble}")
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}&enum_query_double={enumQueryDouble}&enum_query_model_array={enumQueryModelArray}")
@Headers({
"Content-Type: application/x-www-form-urlencoded",
"Accept: application/json",
Expand All @@ -595,9 +599,10 @@ public TestBodyWithQueryParamsQueryParams query(final String value) {
* <li>enumQueryString - Query parameter enum test (string) (optional, default to -efg)</li>
* <li>enumQueryInteger - Query parameter enum test (double) (optional)</li>
* <li>enumQueryDouble - Query parameter enum test (double) (optional)</li>
* <li>enumQueryModelArray - (optional)</li>
* </ul>
*/
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}&enum_query_double={enumQueryDouble}")
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}&enum_query_double={enumQueryDouble}&enum_query_model_array={enumQueryModelArray}")
@Headers({
"Content-Type: application/x-www-form-urlencoded",
"Accept: application/json",
Expand Down Expand Up @@ -629,6 +634,10 @@ public TestEnumParametersQueryParams enumQueryDouble(final Double value) {
put("enum_query_double", EncodingUtils.encode(value));
return this;
}
public TestEnumParametersQueryParams enumQueryModelArray(final List<EnumClass> value) {
put("enum_query_model_array", EncodingUtils.encodeCollection(value, "multi"));
return this;
}
}

/**
Expand Down
9 changes: 9 additions & 0 deletions samples/client/petstore/java/webclient/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,15 @@ paths:
format: double
type: number
style: form
- explode: true
in: query
name: enum_query_model_array
required: false
schema:
items:
$ref: '#/components/schemas/EnumClass'
type: array
style: form
requestBody:
$ref: '#/components/requestBodies/inline_object_2'
content:
Expand Down
6 changes: 4 additions & 2 deletions samples/client/petstore/java/webclient/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ null (empty response body)

## testEnumParameters

> testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString)
> testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumQueryModelArray, enumFormStringArray, enumFormString)
To test enum parameters

Expand Down Expand Up @@ -872,10 +872,11 @@ public class Example {
String enumQueryString = "_abc"; // String | Query parameter enum test (string)
Integer enumQueryInteger = 1; // Integer | Query parameter enum test (double)
Double enumQueryDouble = 1.1D; // Double | Query parameter enum test (double)
List<EnumClass> enumQueryModelArray = Arrays.asList(-efg); // List<EnumClass> |
List<String> enumFormStringArray = Arrays.asList("$"); // List<String> | Form parameter enum test (string array)
String enumFormString = "_abc"; // String | Form parameter enum test (string)
try {
apiInstance.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString);
apiInstance.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumQueryModelArray, enumFormStringArray, enumFormString);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testEnumParameters");
System.err.println("Status code: " + e.getCode());
Expand All @@ -898,6 +899,7 @@ public class Example {
| **enumQueryString** | **String**| Query parameter enum test (string) | [optional] [default to -efg] [enum: _abc, -efg, (xyz)] |
| **enumQueryInteger** | **Integer**| Query parameter enum test (double) | [optional] [enum: 1, -2] |
| **enumQueryDouble** | **Double**| Query parameter enum test (double) | [optional] [enum: 1.1, -1.2] |
| **enumQueryModelArray** | [**List&lt;EnumClass&gt;**](EnumClass.md)| | [optional] |
| **enumFormStringArray** | [**List&lt;String&gt;**](String.md)| Form parameter enum test (string array) | [optional] [enum: >, $] |
| **enumFormString** | **String**| Form parameter enum test (string) | [optional] [default to -efg] [enum: _abc, -efg, (xyz)] |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.math.BigDecimal;
import org.openapitools.client.model.Client;
import org.openapitools.client.model.EnumClass;
import java.io.File;
import org.openapitools.client.model.FileSchemaTestClass;
import org.openapitools.client.model.HealthCheckResult;
Expand Down Expand Up @@ -756,11 +757,12 @@ public Mono<ResponseEntity<Void>> testEndpointParametersWithHttpInfo(BigDecimal
* @param enumQueryString Query parameter enum test (string)
* @param enumQueryInteger Query parameter enum test (double)
* @param enumQueryDouble Query parameter enum test (double)
* @param enumQueryModelArray The enumQueryModelArray parameter
* @param enumFormStringArray Form parameter enum test (string array)
* @param enumFormString Form parameter enum test (string)
* @throws WebClientResponseException if an error occurs while attempting to invoke the API
*/
private ResponseSpec testEnumParametersRequestCreation(List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List<String> enumFormStringArray, String enumFormString) throws WebClientResponseException {
private ResponseSpec testEnumParametersRequestCreation(List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List<EnumClass> enumQueryModelArray, List<String> enumFormStringArray, String enumFormString) throws WebClientResponseException {
Object postBody = null;
// create path and map variables
final Map<String, Object> pathParams = new HashMap<String, Object>();
Expand All @@ -774,6 +776,7 @@ private ResponseSpec testEnumParametersRequestCreation(List<String> enumHeaderSt
queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_string", enumQueryString));
queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_integer", enumQueryInteger));
queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_double", enumQueryDouble));
queryParams.putAll(apiClient.parameterToMultiValueMap(ApiClient.CollectionFormat.valueOf("multi".toUpperCase(Locale.ROOT)), "enum_query_model_array", enumQueryModelArray));

if (enumHeaderStringArray != null)
headerParams.add("enum_header_string_array", apiClient.parameterToString(enumHeaderStringArray));
Expand Down Expand Up @@ -808,18 +811,19 @@ private ResponseSpec testEnumParametersRequestCreation(List<String> enumHeaderSt
* @param enumQueryString Query parameter enum test (string)
* @param enumQueryInteger Query parameter enum test (double)
* @param enumQueryDouble Query parameter enum test (double)
* @param enumQueryModelArray The enumQueryModelArray parameter
* @param enumFormStringArray Form parameter enum test (string array)
* @param enumFormString Form parameter enum test (string)
* @throws WebClientResponseException if an error occurs while attempting to invoke the API
*/
public Mono<Void> testEnumParameters(List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List<String> enumFormStringArray, String enumFormString) throws WebClientResponseException {
public Mono<Void> testEnumParameters(List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List<EnumClass> enumQueryModelArray, List<String> enumFormStringArray, String enumFormString) throws WebClientResponseException {
ParameterizedTypeReference<Void> localVarReturnType = new ParameterizedTypeReference<Void>() {};
return testEnumParametersRequestCreation(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString).bodyToMono(localVarReturnType);
return testEnumParametersRequestCreation(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumQueryModelArray, enumFormStringArray, enumFormString).bodyToMono(localVarReturnType);
}

public Mono<ResponseEntity<Void>> testEnumParametersWithHttpInfo(List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List<String> enumFormStringArray, String enumFormString) throws WebClientResponseException {
public Mono<ResponseEntity<Void>> testEnumParametersWithHttpInfo(List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List<EnumClass> enumQueryModelArray, List<String> enumFormStringArray, String enumFormString) throws WebClientResponseException {
ParameterizedTypeReference<Void> localVarReturnType = new ParameterizedTypeReference<Void>() {};
return testEnumParametersRequestCreation(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString).toEntity(localVarReturnType);
return testEnumParametersRequestCreation(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumQueryModelArray, enumFormStringArray, enumFormString).toEntity(localVarReturnType);
}
/**
* Fake endpoint to test group parameters (optional)
Expand Down
Loading

0 comments on commit 478ed9b

Please sign in to comment.