mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-03-10 08:31:23 +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:
@@ -11,10 +11,10 @@ info:
|
||||
servers:
|
||||
- url: http://localhost:3000/
|
||||
paths:
|
||||
/path/string/{path_string}/integer/{path_integer}:
|
||||
/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}:
|
||||
get:
|
||||
description: Test path parameter(s)
|
||||
operationId: "tests/path/string/{path_string}/integer/{path_integer}"
|
||||
operationId: "tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}"
|
||||
parameters:
|
||||
- explode: false
|
||||
in: path
|
||||
@@ -30,6 +30,24 @@ paths:
|
||||
schema:
|
||||
type: integer
|
||||
style: simple
|
||||
- explode: false
|
||||
in: path
|
||||
name: enum_nonref_string_path
|
||||
required: true
|
||||
schema:
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
type: string
|
||||
style: simple
|
||||
- explode: false
|
||||
in: path
|
||||
name: enum_ref_string_path
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
style: simple
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
@@ -83,10 +101,10 @@ paths:
|
||||
- form
|
||||
x-content-type: application/x-www-form-urlencoded
|
||||
x-accepts: text/plain
|
||||
/header/integer/boolean/string:
|
||||
/header/integer/boolean/string/enums:
|
||||
get:
|
||||
description: Test header parameter(s)
|
||||
operationId: test/header/integer/boolean/string
|
||||
operationId: test/header/integer/boolean/string/enums
|
||||
parameters:
|
||||
- explode: true
|
||||
in: header
|
||||
@@ -109,6 +127,24 @@ paths:
|
||||
schema:
|
||||
type: string
|
||||
style: form
|
||||
- explode: true
|
||||
in: header
|
||||
name: enum_nonref_string_header
|
||||
required: false
|
||||
schema:
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
type: string
|
||||
style: form
|
||||
- explode: true
|
||||
in: header
|
||||
name: enum_ref_string_header
|
||||
required: false
|
||||
schema:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
style: form
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
@@ -125,6 +161,17 @@ paths:
|
||||
description: Test query parameter(s)
|
||||
operationId: test/enum_ref_string
|
||||
parameters:
|
||||
- explode: true
|
||||
in: query
|
||||
name: enum_nonref_string_query
|
||||
required: false
|
||||
schema:
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
type: string
|
||||
style: form
|
||||
- explode: true
|
||||
in: query
|
||||
name: enum_ref_string_query
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.EncodingUtils;
|
||||
import org.openapitools.client.model.ApiResponse;
|
||||
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -21,38 +22,50 @@ public interface HeaderApi extends ApiClient.Api {
|
||||
* @param integerHeader (optional)
|
||||
* @param booleanHeader (optional)
|
||||
* @param stringHeader (optional)
|
||||
* @param enumNonrefStringHeader (optional)
|
||||
* @param enumRefStringHeader (optional)
|
||||
* @return String
|
||||
*/
|
||||
@RequestLine("GET /header/integer/boolean/string")
|
||||
@RequestLine("GET /header/integer/boolean/string/enums")
|
||||
@Headers({
|
||||
"Accept: text/plain",
|
||||
"integer_header: {integerHeader}",
|
||||
|
||||
"boolean_header: {booleanHeader}",
|
||||
|
||||
"string_header: {stringHeader}"
|
||||
"string_header: {stringHeader}",
|
||||
|
||||
"enum_nonref_string_header: {enumNonrefStringHeader}",
|
||||
|
||||
"enum_ref_string_header: {enumRefStringHeader}"
|
||||
})
|
||||
String testHeaderIntegerBooleanString(@Param("integerHeader") Integer integerHeader, @Param("booleanHeader") Boolean booleanHeader, @Param("stringHeader") String stringHeader);
|
||||
String testHeaderIntegerBooleanStringEnums(@Param("integerHeader") Integer integerHeader, @Param("booleanHeader") Boolean booleanHeader, @Param("stringHeader") String stringHeader, @Param("enumNonrefStringHeader") String enumNonrefStringHeader, @Param("enumRefStringHeader") StringEnumRef enumRefStringHeader);
|
||||
|
||||
/**
|
||||
* Test header parameter(s)
|
||||
* Similar to <code>testHeaderIntegerBooleanString</code> but it also returns the http response headers .
|
||||
* Similar to <code>testHeaderIntegerBooleanStringEnums</code> but it also returns the http response headers .
|
||||
* Test header parameter(s)
|
||||
* @param integerHeader (optional)
|
||||
* @param booleanHeader (optional)
|
||||
* @param stringHeader (optional)
|
||||
* @param enumNonrefStringHeader (optional)
|
||||
* @param enumRefStringHeader (optional)
|
||||
* @return A ApiResponse that wraps the response boyd and the http headers.
|
||||
*/
|
||||
@RequestLine("GET /header/integer/boolean/string")
|
||||
@RequestLine("GET /header/integer/boolean/string/enums")
|
||||
@Headers({
|
||||
"Accept: text/plain",
|
||||
"integer_header: {integerHeader}",
|
||||
|
||||
"boolean_header: {booleanHeader}",
|
||||
|
||||
"string_header: {stringHeader}"
|
||||
"string_header: {stringHeader}",
|
||||
|
||||
"enum_nonref_string_header: {enumNonrefStringHeader}",
|
||||
|
||||
"enum_ref_string_header: {enumRefStringHeader}"
|
||||
})
|
||||
ApiResponse<String> testHeaderIntegerBooleanStringWithHttpInfo(@Param("integerHeader") Integer integerHeader, @Param("booleanHeader") Boolean booleanHeader, @Param("stringHeader") String stringHeader);
|
||||
ApiResponse<String> testHeaderIntegerBooleanStringEnumsWithHttpInfo(@Param("integerHeader") Integer integerHeader, @Param("booleanHeader") Boolean booleanHeader, @Param("stringHeader") String stringHeader, @Param("enumNonrefStringHeader") String enumNonrefStringHeader, @Param("enumRefStringHeader") StringEnumRef enumRefStringHeader);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.EncodingUtils;
|
||||
import org.openapitools.client.model.ApiResponse;
|
||||
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -20,27 +21,31 @@ public interface PathApi extends ApiClient.Api {
|
||||
* Test path parameter(s)
|
||||
* @param pathString (required)
|
||||
* @param pathInteger (required)
|
||||
* @param enumNonrefStringPath (required)
|
||||
* @param enumRefStringPath (required)
|
||||
* @return String
|
||||
*/
|
||||
@RequestLine("GET /path/string/{pathString}/integer/{pathInteger}")
|
||||
@RequestLine("GET /path/string/{pathString}/integer/{pathInteger}/{enumNonrefStringPath}/{enumRefStringPath}")
|
||||
@Headers({
|
||||
"Accept: text/plain",
|
||||
})
|
||||
String testsPathStringPathStringIntegerPathInteger(@Param("pathString") String pathString, @Param("pathInteger") Integer pathInteger);
|
||||
String testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(@Param("pathString") String pathString, @Param("pathInteger") Integer pathInteger, @Param("enumNonrefStringPath") String enumNonrefStringPath, @Param("enumRefStringPath") StringEnumRef enumRefStringPath);
|
||||
|
||||
/**
|
||||
* Test path parameter(s)
|
||||
* Similar to <code>testsPathStringPathStringIntegerPathInteger</code> but it also returns the http response headers .
|
||||
* Similar to <code>testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath</code> but it also returns the http response headers .
|
||||
* Test path parameter(s)
|
||||
* @param pathString (required)
|
||||
* @param pathInteger (required)
|
||||
* @param enumNonrefStringPath (required)
|
||||
* @param enumRefStringPath (required)
|
||||
* @return A ApiResponse that wraps the response boyd and the http headers.
|
||||
*/
|
||||
@RequestLine("GET /path/string/{pathString}/integer/{pathInteger}")
|
||||
@RequestLine("GET /path/string/{pathString}/integer/{pathInteger}/{enumNonrefStringPath}/{enumRefStringPath}")
|
||||
@Headers({
|
||||
"Accept: text/plain",
|
||||
})
|
||||
ApiResponse<String> testsPathStringPathStringIntegerPathIntegerWithHttpInfo(@Param("pathString") String pathString, @Param("pathInteger") Integer pathInteger);
|
||||
ApiResponse<String> testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo(@Param("pathString") String pathString, @Param("pathInteger") Integer pathInteger, @Param("enumNonrefStringPath") String enumNonrefStringPath, @Param("enumRefStringPath") StringEnumRef enumRefStringPath);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,27 +25,29 @@ public interface QueryApi extends ApiClient.Api {
|
||||
/**
|
||||
* Test query parameter(s)
|
||||
* Test query parameter(s)
|
||||
* @param enumNonrefStringQuery (optional)
|
||||
* @param enumRefStringQuery (optional)
|
||||
* @return String
|
||||
*/
|
||||
@RequestLine("GET /query/enum_ref_string?enum_ref_string_query={enumRefStringQuery}")
|
||||
@RequestLine("GET /query/enum_ref_string?enum_nonref_string_query={enumNonrefStringQuery}&enum_ref_string_query={enumRefStringQuery}")
|
||||
@Headers({
|
||||
"Accept: text/plain",
|
||||
})
|
||||
String testEnumRefString(@Param("enumRefStringQuery") StringEnumRef enumRefStringQuery);
|
||||
String testEnumRefString(@Param("enumNonrefStringQuery") String enumNonrefStringQuery, @Param("enumRefStringQuery") StringEnumRef enumRefStringQuery);
|
||||
|
||||
/**
|
||||
* Test query parameter(s)
|
||||
* Similar to <code>testEnumRefString</code> but it also returns the http response headers .
|
||||
* Test query parameter(s)
|
||||
* @param enumNonrefStringQuery (optional)
|
||||
* @param enumRefStringQuery (optional)
|
||||
* @return A ApiResponse that wraps the response boyd and the http headers.
|
||||
*/
|
||||
@RequestLine("GET /query/enum_ref_string?enum_ref_string_query={enumRefStringQuery}")
|
||||
@RequestLine("GET /query/enum_ref_string?enum_nonref_string_query={enumNonrefStringQuery}&enum_ref_string_query={enumRefStringQuery}")
|
||||
@Headers({
|
||||
"Accept: text/plain",
|
||||
})
|
||||
ApiResponse<String> testEnumRefStringWithHttpInfo(@Param("enumRefStringQuery") StringEnumRef enumRefStringQuery);
|
||||
ApiResponse<String> testEnumRefStringWithHttpInfo(@Param("enumNonrefStringQuery") String enumNonrefStringQuery, @Param("enumRefStringQuery") StringEnumRef enumRefStringQuery);
|
||||
|
||||
|
||||
/**
|
||||
@@ -59,11 +61,12 @@ public interface QueryApi extends ApiClient.Api {
|
||||
* @param queryParams Map of query parameters as name-value pairs
|
||||
* <p>The following elements may be specified in the query map:</p>
|
||||
* <ul>
|
||||
* <li>enumNonrefStringQuery - (optional)</li>
|
||||
* <li>enumRefStringQuery - (optional)</li>
|
||||
* </ul>
|
||||
* @return String
|
||||
*/
|
||||
@RequestLine("GET /query/enum_ref_string?enum_ref_string_query={enumRefStringQuery}")
|
||||
@RequestLine("GET /query/enum_ref_string?enum_nonref_string_query={enumNonrefStringQuery}&enum_ref_string_query={enumRefStringQuery}")
|
||||
@Headers({
|
||||
"Accept: text/plain",
|
||||
})
|
||||
@@ -77,11 +80,12 @@ public interface QueryApi extends ApiClient.Api {
|
||||
* @param queryParams Map of query parameters as name-value pairs
|
||||
* <p>The following elements may be specified in the query map:</p>
|
||||
* <ul>
|
||||
* <li>enumNonrefStringQuery - (optional)</li>
|
||||
* <li>enumRefStringQuery - (optional)</li>
|
||||
* </ul>
|
||||
* @return String
|
||||
*/
|
||||
@RequestLine("GET /query/enum_ref_string?enum_ref_string_query={enumRefStringQuery}")
|
||||
@RequestLine("GET /query/enum_ref_string?enum_nonref_string_query={enumNonrefStringQuery}&enum_ref_string_query={enumRefStringQuery}")
|
||||
@Headers({
|
||||
"Accept: text/plain",
|
||||
})
|
||||
@@ -93,6 +97,10 @@ public interface QueryApi extends ApiClient.Api {
|
||||
* <code>testEnumRefString</code> method in a fluent style.
|
||||
*/
|
||||
public static class TestEnumRefStringQueryParams extends HashMap<String, Object> {
|
||||
public TestEnumRefStringQueryParams enumNonrefStringQuery(final String value) {
|
||||
put("enum_nonref_string_query", EncodingUtils.encode(value));
|
||||
return this;
|
||||
}
|
||||
public TestEnumRefStringQueryParams enumRefStringQuery(final StringEnumRef value) {
|
||||
put("enum_ref_string_query", EncodingUtils.encode(value));
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user