mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-19 14:07:11 +00:00
[python] Add tests and fix enum path parameters (#16769)
* test: Tests for enum params in path, query and header * fix: Get enum ref values correctly in path parameters Closes #16688 * fix java tests failure --------- Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.Pair;
|
||||
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -56,11 +57,13 @@ public class HeaderApi {
|
||||
* @param integerHeader (optional)
|
||||
* @param booleanHeader (optional)
|
||||
* @param stringHeader (optional)
|
||||
* @param enumNonrefStringHeader (optional)
|
||||
* @param enumRefStringHeader (optional)
|
||||
* @return String
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public String testHeaderIntegerBooleanString(Integer integerHeader, Boolean booleanHeader, String stringHeader) throws ApiException {
|
||||
return this.testHeaderIntegerBooleanString(integerHeader, booleanHeader, stringHeader, Collections.emptyMap());
|
||||
public String testHeaderIntegerBooleanStringEnums(Integer integerHeader, Boolean booleanHeader, String stringHeader, String enumNonrefStringHeader, StringEnumRef enumRefStringHeader) throws ApiException {
|
||||
return this.testHeaderIntegerBooleanStringEnums(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader, Collections.emptyMap());
|
||||
}
|
||||
|
||||
|
||||
@@ -70,15 +73,17 @@ public class HeaderApi {
|
||||
* @param integerHeader (optional)
|
||||
* @param booleanHeader (optional)
|
||||
* @param stringHeader (optional)
|
||||
* @param enumNonrefStringHeader (optional)
|
||||
* @param enumRefStringHeader (optional)
|
||||
* @param additionalHeaders additionalHeaders for this call
|
||||
* @return String
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public String testHeaderIntegerBooleanString(Integer integerHeader, Boolean booleanHeader, String stringHeader, Map<String, String> additionalHeaders) throws ApiException {
|
||||
public String testHeaderIntegerBooleanStringEnums(Integer integerHeader, Boolean booleanHeader, String stringHeader, String enumNonrefStringHeader, StringEnumRef enumRefStringHeader, Map<String, String> additionalHeaders) throws ApiException {
|
||||
Object localVarPostBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/header/integer/boolean/string";
|
||||
String localVarPath = "/header/integer/boolean/string/enums";
|
||||
|
||||
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
|
||||
String localVarQueryParameterBaseName;
|
||||
@@ -94,6 +99,10 @@ if (booleanHeader != null)
|
||||
localVarHeaderParams.put("boolean_header", apiClient.parameterToString(booleanHeader));
|
||||
if (stringHeader != null)
|
||||
localVarHeaderParams.put("string_header", apiClient.parameterToString(stringHeader));
|
||||
if (enumNonrefStringHeader != null)
|
||||
localVarHeaderParams.put("enum_nonref_string_header", apiClient.parameterToString(enumNonrefStringHeader));
|
||||
if (enumRefStringHeader != null)
|
||||
localVarHeaderParams.put("enum_ref_string_header", apiClient.parameterToString(enumRefStringHeader));
|
||||
|
||||
localVarHeaderParams.putAll(additionalHeaders);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.Pair;
|
||||
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -55,11 +56,13 @@ public class PathApi {
|
||||
* Test path parameter(s)
|
||||
* @param pathString (required)
|
||||
* @param pathInteger (required)
|
||||
* @param enumNonrefStringPath (required)
|
||||
* @param enumRefStringPath (required)
|
||||
* @return String
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public String testsPathStringPathStringIntegerPathInteger(String pathString, Integer pathInteger) throws ApiException {
|
||||
return this.testsPathStringPathStringIntegerPathInteger(pathString, pathInteger, Collections.emptyMap());
|
||||
public String testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(String pathString, Integer pathInteger, String enumNonrefStringPath, StringEnumRef enumRefStringPath) throws ApiException {
|
||||
return this.testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath, Collections.emptyMap());
|
||||
}
|
||||
|
||||
|
||||
@@ -68,27 +71,41 @@ public class PathApi {
|
||||
* Test path parameter(s)
|
||||
* @param pathString (required)
|
||||
* @param pathInteger (required)
|
||||
* @param enumNonrefStringPath (required)
|
||||
* @param enumRefStringPath (required)
|
||||
* @param additionalHeaders additionalHeaders for this call
|
||||
* @return String
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public String testsPathStringPathStringIntegerPathInteger(String pathString, Integer pathInteger, Map<String, String> additionalHeaders) throws ApiException {
|
||||
public String testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(String pathString, Integer pathInteger, String enumNonrefStringPath, StringEnumRef enumRefStringPath, Map<String, String> additionalHeaders) throws ApiException {
|
||||
Object localVarPostBody = null;
|
||||
|
||||
// verify the required parameter 'pathString' is set
|
||||
if (pathString == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'pathString' when calling testsPathStringPathStringIntegerPathInteger");
|
||||
throw new ApiException(400, "Missing the required parameter 'pathString' when calling testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath");
|
||||
}
|
||||
|
||||
// verify the required parameter 'pathInteger' is set
|
||||
if (pathInteger == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'pathInteger' when calling testsPathStringPathStringIntegerPathInteger");
|
||||
throw new ApiException(400, "Missing the required parameter 'pathInteger' when calling testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath");
|
||||
}
|
||||
|
||||
// verify the required parameter 'enumNonrefStringPath' is set
|
||||
if (enumNonrefStringPath == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'enumNonrefStringPath' when calling testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath");
|
||||
}
|
||||
|
||||
// verify the required parameter 'enumRefStringPath' is set
|
||||
if (enumRefStringPath == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'enumRefStringPath' when calling testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/path/string/{path_string}/integer/{path_integer}"
|
||||
String localVarPath = "/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}"
|
||||
.replaceAll("\\{" + "path_string" + "\\}", apiClient.escapeString(pathString.toString()))
|
||||
.replaceAll("\\{" + "path_integer" + "\\}", apiClient.escapeString(pathInteger.toString()));
|
||||
.replaceAll("\\{" + "path_integer" + "\\}", apiClient.escapeString(pathInteger.toString()))
|
||||
.replaceAll("\\{" + "enum_nonref_string_path" + "\\}", apiClient.escapeString(enumNonrefStringPath.toString()))
|
||||
.replaceAll("\\{" + "enum_ref_string_path" + "\\}", apiClient.escapeString(enumRefStringPath.toString()));
|
||||
|
||||
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
|
||||
String localVarQueryParameterBaseName;
|
||||
|
||||
@@ -60,24 +60,26 @@ public class QueryApi {
|
||||
/**
|
||||
* Test query parameter(s)
|
||||
* Test query parameter(s)
|
||||
* @param enumNonrefStringQuery (optional)
|
||||
* @param enumRefStringQuery (optional)
|
||||
* @return String
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public String testEnumRefString(StringEnumRef enumRefStringQuery) throws ApiException {
|
||||
return this.testEnumRefString(enumRefStringQuery, Collections.emptyMap());
|
||||
public String testEnumRefString(String enumNonrefStringQuery, StringEnumRef enumRefStringQuery) throws ApiException {
|
||||
return this.testEnumRefString(enumNonrefStringQuery, enumRefStringQuery, Collections.emptyMap());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test query parameter(s)
|
||||
* Test query parameter(s)
|
||||
* @param enumNonrefStringQuery (optional)
|
||||
* @param enumRefStringQuery (optional)
|
||||
* @param additionalHeaders additionalHeaders for this call
|
||||
* @return String
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public String testEnumRefString(StringEnumRef enumRefStringQuery, Map<String, String> additionalHeaders) throws ApiException {
|
||||
public String testEnumRefString(String enumNonrefStringQuery, StringEnumRef enumRefStringQuery, Map<String, String> additionalHeaders) throws ApiException {
|
||||
Object localVarPostBody = null;
|
||||
|
||||
// create path and map variables
|
||||
@@ -91,6 +93,7 @@ public class QueryApi {
|
||||
Map<String, String> localVarCookieParams = new HashMap<String, String>();
|
||||
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
|
||||
|
||||
localVarQueryParams.addAll(apiClient.parameterToPair("enum_nonref_string_query", enumNonrefStringQuery));
|
||||
localVarQueryParams.addAll(apiClient.parameterToPair("enum_ref_string_query", enumRefStringQuery));
|
||||
|
||||
localVarHeaderParams.putAll(additionalHeaders);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
package org.openapitools.client.api;
|
||||
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Assert;
|
||||
@@ -42,11 +43,13 @@ public class HeaderApiTest {
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testHeaderIntegerBooleanStringTest() throws ApiException {
|
||||
public void testHeaderIntegerBooleanStringEnumsTest() throws ApiException {
|
||||
Integer integerHeader = null;
|
||||
Boolean booleanHeader = null;
|
||||
String stringHeader = null;
|
||||
String response = api.testHeaderIntegerBooleanString(integerHeader, booleanHeader, stringHeader);
|
||||
String enumNonrefStringHeader = null;
|
||||
StringEnumRef enumRefStringHeader = null;
|
||||
String response = api.testHeaderIntegerBooleanStringEnums(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
package org.openapitools.client.api;
|
||||
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Assert;
|
||||
@@ -42,10 +43,12 @@ public class PathApiTest {
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testsPathStringPathStringIntegerPathIntegerTest() throws ApiException {
|
||||
public void testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathTest() throws ApiException {
|
||||
String pathString = null;
|
||||
Integer pathInteger = null;
|
||||
String response = api.testsPathStringPathStringIntegerPathInteger(pathString, pathInteger);
|
||||
String enumNonrefStringPath = null;
|
||||
StringEnumRef enumRefStringPath = null;
|
||||
String response = api.testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user