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:
@@ -25,9 +25,11 @@ module OpenapiClient
|
||||
# @option opts [Integer] :integer_header
|
||||
# @option opts [Boolean] :boolean_header
|
||||
# @option opts [String] :string_header
|
||||
# @option opts [String] :enum_nonref_string_header
|
||||
# @option opts [StringEnumRef] :enum_ref_string_header
|
||||
# @return [String]
|
||||
def test_header_integer_boolean_string(opts = {})
|
||||
data, _status_code, _headers = test_header_integer_boolean_string_with_http_info(opts)
|
||||
def test_header_integer_boolean_string_enums(opts = {})
|
||||
data, _status_code, _headers = test_header_integer_boolean_string_enums_with_http_info(opts)
|
||||
data
|
||||
end
|
||||
|
||||
@@ -37,13 +39,19 @@ module OpenapiClient
|
||||
# @option opts [Integer] :integer_header
|
||||
# @option opts [Boolean] :boolean_header
|
||||
# @option opts [String] :string_header
|
||||
# @option opts [String] :enum_nonref_string_header
|
||||
# @option opts [StringEnumRef] :enum_ref_string_header
|
||||
# @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
|
||||
def test_header_integer_boolean_string_with_http_info(opts = {})
|
||||
def test_header_integer_boolean_string_enums_with_http_info(opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: HeaderApi.test_header_integer_boolean_string ...'
|
||||
@api_client.config.logger.debug 'Calling API: HeaderApi.test_header_integer_boolean_string_enums ...'
|
||||
end
|
||||
allowable_values = ["success", "failure", "unclassified"]
|
||||
if @api_client.config.client_side_validation && opts[:'enum_nonref_string_header'] && !allowable_values.include?(opts[:'enum_nonref_string_header'])
|
||||
fail ArgumentError, "invalid value for \"enum_nonref_string_header\", must be one of #{allowable_values}"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/header/integer/boolean/string'
|
||||
local_var_path = '/header/integer/boolean/string/enums'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
@@ -55,6 +63,8 @@ module OpenapiClient
|
||||
header_params['integer_header'] = opts[:'integer_header'] if !opts[:'integer_header'].nil?
|
||||
header_params['boolean_header'] = opts[:'boolean_header'] if !opts[:'boolean_header'].nil?
|
||||
header_params['string_header'] = opts[:'string_header'] if !opts[:'string_header'].nil?
|
||||
header_params['enum_nonref_string_header'] = opts[:'enum_nonref_string_header'] if !opts[:'enum_nonref_string_header'].nil?
|
||||
header_params['enum_ref_string_header'] = opts[:'enum_ref_string_header'] if !opts[:'enum_ref_string_header'].nil?
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
@@ -69,7 +79,7 @@ module OpenapiClient
|
||||
auth_names = opts[:debug_auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:operation => :"HeaderApi.test_header_integer_boolean_string",
|
||||
:operation => :"HeaderApi.test_header_integer_boolean_string_enums",
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
@@ -80,7 +90,7 @@ module OpenapiClient
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: HeaderApi#test_header_integer_boolean_string\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
@api_client.config.logger.debug "API called: HeaderApi#test_header_integer_boolean_string_enums\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
@@ -23,10 +23,12 @@ module OpenapiClient
|
||||
# Test path parameter(s)
|
||||
# @param path_string [String]
|
||||
# @param path_integer [Integer]
|
||||
# @param enum_nonref_string_path [String]
|
||||
# @param enum_ref_string_path [StringEnumRef]
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [String]
|
||||
def tests_path_string_path_string_integer_path_integer(path_string, path_integer, opts = {})
|
||||
data, _status_code, _headers = tests_path_string_path_string_integer_path_integer_with_http_info(path_string, path_integer, opts)
|
||||
def tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, opts = {})
|
||||
data, _status_code, _headers = tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path_with_http_info(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, opts)
|
||||
data
|
||||
end
|
||||
|
||||
@@ -34,22 +36,37 @@ module OpenapiClient
|
||||
# Test path parameter(s)
|
||||
# @param path_string [String]
|
||||
# @param path_integer [Integer]
|
||||
# @param enum_nonref_string_path [String]
|
||||
# @param enum_ref_string_path [StringEnumRef]
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
|
||||
def tests_path_string_path_string_integer_path_integer_with_http_info(path_string, path_integer, opts = {})
|
||||
def tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path_with_http_info(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: PathApi.tests_path_string_path_string_integer_path_integer ...'
|
||||
@api_client.config.logger.debug 'Calling API: PathApi.tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path ...'
|
||||
end
|
||||
# verify the required parameter 'path_string' is set
|
||||
if @api_client.config.client_side_validation && path_string.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'path_string' when calling PathApi.tests_path_string_path_string_integer_path_integer"
|
||||
fail ArgumentError, "Missing the required parameter 'path_string' when calling PathApi.tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path"
|
||||
end
|
||||
# verify the required parameter 'path_integer' is set
|
||||
if @api_client.config.client_side_validation && path_integer.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'path_integer' when calling PathApi.tests_path_string_path_string_integer_path_integer"
|
||||
fail ArgumentError, "Missing the required parameter 'path_integer' when calling PathApi.tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path"
|
||||
end
|
||||
# verify the required parameter 'enum_nonref_string_path' is set
|
||||
if @api_client.config.client_side_validation && enum_nonref_string_path.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'enum_nonref_string_path' when calling PathApi.tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path"
|
||||
end
|
||||
# verify enum value
|
||||
allowable_values = ["success", "failure", "unclassified"]
|
||||
if @api_client.config.client_side_validation && !allowable_values.include?(enum_nonref_string_path)
|
||||
fail ArgumentError, "invalid value for \"enum_nonref_string_path\", must be one of #{allowable_values}"
|
||||
end
|
||||
# verify the required parameter 'enum_ref_string_path' is set
|
||||
if @api_client.config.client_side_validation && enum_ref_string_path.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'enum_ref_string_path' when calling PathApi.tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/path/string/{path_string}/integer/{path_integer}'.sub('{' + 'path_string' + '}', CGI.escape(path_string.to_s)).sub('{' + 'path_integer' + '}', CGI.escape(path_integer.to_s))
|
||||
local_var_path = '/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}'.sub('{' + 'path_string' + '}', CGI.escape(path_string.to_s)).sub('{' + 'path_integer' + '}', CGI.escape(path_integer.to_s)).sub('{' + 'enum_nonref_string_path' + '}', CGI.escape(enum_nonref_string_path.to_s)).sub('{' + 'enum_ref_string_path' + '}', CGI.escape(enum_ref_string_path.to_s))
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
@@ -72,7 +89,7 @@ module OpenapiClient
|
||||
auth_names = opts[:debug_auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:operation => :"PathApi.tests_path_string_path_string_integer_path_integer",
|
||||
:operation => :"PathApi.tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path",
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
@@ -83,7 +100,7 @@ module OpenapiClient
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: PathApi#tests_path_string_path_string_integer_path_integer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
@api_client.config.logger.debug "API called: PathApi#tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
@@ -22,6 +22,7 @@ module OpenapiClient
|
||||
# Test query parameter(s)
|
||||
# Test query parameter(s)
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :enum_nonref_string_query
|
||||
# @option opts [StringEnumRef] :enum_ref_string_query
|
||||
# @return [String]
|
||||
def test_enum_ref_string(opts = {})
|
||||
@@ -32,17 +33,23 @@ module OpenapiClient
|
||||
# Test query parameter(s)
|
||||
# Test query parameter(s)
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :enum_nonref_string_query
|
||||
# @option opts [StringEnumRef] :enum_ref_string_query
|
||||
# @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
|
||||
def test_enum_ref_string_with_http_info(opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: QueryApi.test_enum_ref_string ...'
|
||||
end
|
||||
allowable_values = ["success", "failure", "unclassified"]
|
||||
if @api_client.config.client_side_validation && opts[:'enum_nonref_string_query'] && !allowable_values.include?(opts[:'enum_nonref_string_query'])
|
||||
fail ArgumentError, "invalid value for \"enum_nonref_string_query\", must be one of #{allowable_values}"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/query/enum_ref_string'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
query_params[:'enum_nonref_string_query'] = opts[:'enum_nonref_string_query'] if !opts[:'enum_nonref_string_query'].nil?
|
||||
query_params[:'enum_ref_string_query'] = opts[:'enum_ref_string_query'] if !opts[:'enum_ref_string_query'].nil?
|
||||
|
||||
# header parameters
|
||||
|
||||
Reference in New Issue
Block a user