forked from loafle/openapi-generator-original
[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:
@@ -17,6 +17,7 @@ import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.ApiResponse;
|
||||
import org.openapitools.client.Pair;
|
||||
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -92,11 +93,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 {
|
||||
ApiResponse<String> localVarResponse = testHeaderIntegerBooleanStringWithHttpInfo(integerHeader, booleanHeader, stringHeader);
|
||||
public String testHeaderIntegerBooleanStringEnums(Integer integerHeader, Boolean booleanHeader, String stringHeader, String enumNonrefStringHeader, StringEnumRef enumRefStringHeader) throws ApiException {
|
||||
ApiResponse<String> localVarResponse = testHeaderIntegerBooleanStringEnumsWithHttpInfo(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader);
|
||||
return localVarResponse.getData();
|
||||
}
|
||||
|
||||
@@ -106,11 +109,13 @@ public class HeaderApi {
|
||||
* @param integerHeader (optional)
|
||||
* @param booleanHeader (optional)
|
||||
* @param stringHeader (optional)
|
||||
* @param enumNonrefStringHeader (optional)
|
||||
* @param enumRefStringHeader (optional)
|
||||
* @return ApiResponse<String>
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public ApiResponse<String> testHeaderIntegerBooleanStringWithHttpInfo(Integer integerHeader, Boolean booleanHeader, String stringHeader) throws ApiException {
|
||||
HttpRequest.Builder localVarRequestBuilder = testHeaderIntegerBooleanStringRequestBuilder(integerHeader, booleanHeader, stringHeader);
|
||||
public ApiResponse<String> testHeaderIntegerBooleanStringEnumsWithHttpInfo(Integer integerHeader, Boolean booleanHeader, String stringHeader, String enumNonrefStringHeader, StringEnumRef enumRefStringHeader) throws ApiException {
|
||||
HttpRequest.Builder localVarRequestBuilder = testHeaderIntegerBooleanStringEnumsRequestBuilder(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader);
|
||||
try {
|
||||
HttpResponse<InputStream> localVarResponse = memberVarHttpClient.send(
|
||||
localVarRequestBuilder.build(),
|
||||
@@ -120,7 +125,7 @@ public class HeaderApi {
|
||||
}
|
||||
try {
|
||||
if (localVarResponse.statusCode()/ 100 != 2) {
|
||||
throw getApiException("testHeaderIntegerBooleanString", localVarResponse);
|
||||
throw getApiException("testHeaderIntegerBooleanStringEnums", localVarResponse);
|
||||
}
|
||||
// for plain text response
|
||||
if (localVarResponse.headers().map().containsKey("Content-Type") &&
|
||||
@@ -146,11 +151,11 @@ public class HeaderApi {
|
||||
}
|
||||
}
|
||||
|
||||
private HttpRequest.Builder testHeaderIntegerBooleanStringRequestBuilder(Integer integerHeader, Boolean booleanHeader, String stringHeader) throws ApiException {
|
||||
private HttpRequest.Builder testHeaderIntegerBooleanStringEnumsRequestBuilder(Integer integerHeader, Boolean booleanHeader, String stringHeader, String enumNonrefStringHeader, StringEnumRef enumRefStringHeader) throws ApiException {
|
||||
|
||||
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
|
||||
|
||||
String localVarPath = "/header/integer/boolean/string";
|
||||
String localVarPath = "/header/integer/boolean/string/enums";
|
||||
|
||||
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
|
||||
|
||||
@@ -163,6 +168,12 @@ public class HeaderApi {
|
||||
if (stringHeader != null) {
|
||||
localVarRequestBuilder.header("string_header", stringHeader.toString());
|
||||
}
|
||||
if (enumNonrefStringHeader != null) {
|
||||
localVarRequestBuilder.header("enum_nonref_string_header", enumNonrefStringHeader.toString());
|
||||
}
|
||||
if (enumRefStringHeader != null) {
|
||||
localVarRequestBuilder.header("enum_ref_string_header", enumRefStringHeader.toString());
|
||||
}
|
||||
localVarRequestBuilder.header("Accept", "text/plain");
|
||||
|
||||
localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.ApiResponse;
|
||||
import org.openapitools.client.Pair;
|
||||
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -91,11 +92,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 {
|
||||
ApiResponse<String> localVarResponse = testsPathStringPathStringIntegerPathIntegerWithHttpInfo(pathString, pathInteger);
|
||||
public String testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(String pathString, Integer pathInteger, String enumNonrefStringPath, StringEnumRef enumRefStringPath) throws ApiException {
|
||||
ApiResponse<String> localVarResponse = testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath);
|
||||
return localVarResponse.getData();
|
||||
}
|
||||
|
||||
@@ -104,11 +107,13 @@ public class PathApi {
|
||||
* Test path parameter(s)
|
||||
* @param pathString (required)
|
||||
* @param pathInteger (required)
|
||||
* @param enumNonrefStringPath (required)
|
||||
* @param enumRefStringPath (required)
|
||||
* @return ApiResponse<String>
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public ApiResponse<String> testsPathStringPathStringIntegerPathIntegerWithHttpInfo(String pathString, Integer pathInteger) throws ApiException {
|
||||
HttpRequest.Builder localVarRequestBuilder = testsPathStringPathStringIntegerPathIntegerRequestBuilder(pathString, pathInteger);
|
||||
public ApiResponse<String> testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo(String pathString, Integer pathInteger, String enumNonrefStringPath, StringEnumRef enumRefStringPath) throws ApiException {
|
||||
HttpRequest.Builder localVarRequestBuilder = testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathRequestBuilder(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath);
|
||||
try {
|
||||
HttpResponse<InputStream> localVarResponse = memberVarHttpClient.send(
|
||||
localVarRequestBuilder.build(),
|
||||
@@ -118,7 +123,7 @@ public class PathApi {
|
||||
}
|
||||
try {
|
||||
if (localVarResponse.statusCode()/ 100 != 2) {
|
||||
throw getApiException("testsPathStringPathStringIntegerPathInteger", localVarResponse);
|
||||
throw getApiException("testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath", localVarResponse);
|
||||
}
|
||||
// for plain text response
|
||||
if (localVarResponse.headers().map().containsKey("Content-Type") &&
|
||||
@@ -144,21 +149,31 @@ public class PathApi {
|
||||
}
|
||||
}
|
||||
|
||||
private HttpRequest.Builder testsPathStringPathStringIntegerPathIntegerRequestBuilder(String pathString, Integer pathInteger) throws ApiException {
|
||||
private HttpRequest.Builder testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathRequestBuilder(String pathString, Integer pathInteger, String enumNonrefStringPath, StringEnumRef enumRefStringPath) throws ApiException {
|
||||
// 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");
|
||||
}
|
||||
|
||||
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
|
||||
|
||||
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}"
|
||||
.replace("{path_string}", ApiClient.urlEncode(pathString.toString()))
|
||||
.replace("{path_integer}", ApiClient.urlEncode(pathInteger.toString()));
|
||||
.replace("{path_integer}", ApiClient.urlEncode(pathInteger.toString()))
|
||||
.replace("{enum_nonref_string_path}", ApiClient.urlEncode(enumNonrefStringPath.toString()))
|
||||
.replace("{enum_ref_string_path}", ApiClient.urlEncode(enumRefStringPath.toString()));
|
||||
|
||||
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
|
||||
|
||||
|
||||
@@ -96,24 +96,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 {
|
||||
ApiResponse<String> localVarResponse = testEnumRefStringWithHttpInfo(enumRefStringQuery);
|
||||
public String testEnumRefString(String enumNonrefStringQuery, StringEnumRef enumRefStringQuery) throws ApiException {
|
||||
ApiResponse<String> localVarResponse = testEnumRefStringWithHttpInfo(enumNonrefStringQuery, enumRefStringQuery);
|
||||
return localVarResponse.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test query parameter(s)
|
||||
* Test query parameter(s)
|
||||
* @param enumNonrefStringQuery (optional)
|
||||
* @param enumRefStringQuery (optional)
|
||||
* @return ApiResponse<String>
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public ApiResponse<String> testEnumRefStringWithHttpInfo(StringEnumRef enumRefStringQuery) throws ApiException {
|
||||
HttpRequest.Builder localVarRequestBuilder = testEnumRefStringRequestBuilder(enumRefStringQuery);
|
||||
public ApiResponse<String> testEnumRefStringWithHttpInfo(String enumNonrefStringQuery, StringEnumRef enumRefStringQuery) throws ApiException {
|
||||
HttpRequest.Builder localVarRequestBuilder = testEnumRefStringRequestBuilder(enumNonrefStringQuery, enumRefStringQuery);
|
||||
try {
|
||||
HttpResponse<InputStream> localVarResponse = memberVarHttpClient.send(
|
||||
localVarRequestBuilder.build(),
|
||||
@@ -149,7 +151,7 @@ public class QueryApi {
|
||||
}
|
||||
}
|
||||
|
||||
private HttpRequest.Builder testEnumRefStringRequestBuilder(StringEnumRef enumRefStringQuery) throws ApiException {
|
||||
private HttpRequest.Builder testEnumRefStringRequestBuilder(String enumNonrefStringQuery, StringEnumRef enumRefStringQuery) throws ApiException {
|
||||
|
||||
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
|
||||
|
||||
@@ -158,6 +160,8 @@ public class QueryApi {
|
||||
List<Pair> localVarQueryParams = new ArrayList<>();
|
||||
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
|
||||
String localVarQueryParameterBaseName;
|
||||
localVarQueryParameterBaseName = "enum_nonref_string_query";
|
||||
localVarQueryParams.addAll(ApiClient.parameterToPairs("enum_nonref_string_query", enumNonrefStringQuery));
|
||||
localVarQueryParameterBaseName = "enum_ref_string_query";
|
||||
localVarQueryParams.addAll(ApiClient.parameterToPairs("enum_ref_string_query", enumRefStringQuery));
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -42,12 +43,14 @@ 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 enumNonrefStringHeader = null;
|
||||
StringEnumRef enumRefStringHeader = null;
|
||||
String response =
|
||||
api.testHeaderIntegerBooleanString(integerHeader, booleanHeader, stringHeader);
|
||||
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;
|
||||
|
||||
@@ -42,11 +43,13 @@ 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 enumNonrefStringPath = null;
|
||||
StringEnumRef enumRefStringPath = null;
|
||||
String response =
|
||||
api.testsPathStringPathStringIntegerPathInteger(pathString, pathInteger);
|
||||
api.testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user