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:
@@ -93,8 +93,8 @@ Class | Method | HTTP request | Description
|
||||
*OpenapiClient::BodyApi* | [**test_echo_body_tag_response_string**](docs/BodyApi.md#test_echo_body_tag_response_string) | **POST** /echo/body/Tag/response_string | Test empty json (request body)
|
||||
*OpenapiClient::FormApi* | [**test_form_integer_boolean_string**](docs/FormApi.md#test_form_integer_boolean_string) | **POST** /form/integer/boolean/string | Test form parameter(s)
|
||||
*OpenapiClient::FormApi* | [**test_form_oneof**](docs/FormApi.md#test_form_oneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema
|
||||
*OpenapiClient::HeaderApi* | [**test_header_integer_boolean_string**](docs/HeaderApi.md#test_header_integer_boolean_string) | **GET** /header/integer/boolean/string | Test header parameter(s)
|
||||
*OpenapiClient::PathApi* | [**tests_path_string_path_string_integer_path_integer**](docs/PathApi.md#tests_path_string_path_string_integer_path_integer) | **GET** /path/string/{path_string}/integer/{path_integer} | Test path parameter(s)
|
||||
*OpenapiClient::HeaderApi* | [**test_header_integer_boolean_string_enums**](docs/HeaderApi.md#test_header_integer_boolean_string_enums) | **GET** /header/integer/boolean/string/enums | Test header parameter(s)
|
||||
*OpenapiClient::PathApi* | [**tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path**](docs/PathApi.md#tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path) | **GET** /path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path} | Test path parameter(s)
|
||||
*OpenapiClient::QueryApi* | [**test_enum_ref_string**](docs/QueryApi.md#test_enum_ref_string) | **GET** /query/enum_ref_string | Test query parameter(s)
|
||||
*OpenapiClient::QueryApi* | [**test_query_datetime_date_string**](docs/QueryApi.md#test_query_datetime_date_string) | **GET** /query/datetime/date/string | Test query parameter(s)
|
||||
*OpenapiClient::QueryApi* | [**test_query_integer_boolean_string**](docs/QueryApi.md#test_query_integer_boolean_string) | **GET** /query/integer/boolean/string | Test query parameter(s)
|
||||
|
||||
@@ -4,12 +4,12 @@ All URIs are relative to *http://localhost:3000*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
| ------ | ------------ | ----------- |
|
||||
| [**test_header_integer_boolean_string**](HeaderApi.md#test_header_integer_boolean_string) | **GET** /header/integer/boolean/string | Test header parameter(s) |
|
||||
| [**test_header_integer_boolean_string_enums**](HeaderApi.md#test_header_integer_boolean_string_enums) | **GET** /header/integer/boolean/string/enums | Test header parameter(s) |
|
||||
|
||||
|
||||
## test_header_integer_boolean_string
|
||||
## test_header_integer_boolean_string_enums
|
||||
|
||||
> String test_header_integer_boolean_string(opts)
|
||||
> String test_header_integer_boolean_string_enums(opts)
|
||||
|
||||
Test header parameter(s)
|
||||
|
||||
@@ -25,33 +25,35 @@ api_instance = OpenapiClient::HeaderApi.new
|
||||
opts = {
|
||||
integer_header: 56, # Integer |
|
||||
boolean_header: true, # Boolean |
|
||||
string_header: 'string_header_example' # String |
|
||||
string_header: 'string_header_example', # String |
|
||||
enum_nonref_string_header: 'success', # String |
|
||||
enum_ref_string_header: OpenapiClient::StringEnumRef::SUCCESS # StringEnumRef |
|
||||
}
|
||||
|
||||
begin
|
||||
# Test header parameter(s)
|
||||
result = api_instance.test_header_integer_boolean_string(opts)
|
||||
result = api_instance.test_header_integer_boolean_string_enums(opts)
|
||||
p result
|
||||
rescue OpenapiClient::ApiError => e
|
||||
puts "Error when calling HeaderApi->test_header_integer_boolean_string: #{e}"
|
||||
puts "Error when calling HeaderApi->test_header_integer_boolean_string_enums: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
#### Using the test_header_integer_boolean_string_with_http_info variant
|
||||
#### Using the test_header_integer_boolean_string_enums_with_http_info variant
|
||||
|
||||
This returns an Array which contains the response data, status code and headers.
|
||||
|
||||
> <Array(String, Integer, Hash)> test_header_integer_boolean_string_with_http_info(opts)
|
||||
> <Array(String, Integer, Hash)> test_header_integer_boolean_string_enums_with_http_info(opts)
|
||||
|
||||
```ruby
|
||||
begin
|
||||
# Test header parameter(s)
|
||||
data, status_code, headers = api_instance.test_header_integer_boolean_string_with_http_info(opts)
|
||||
data, status_code, headers = api_instance.test_header_integer_boolean_string_enums_with_http_info(opts)
|
||||
p status_code # => 2xx
|
||||
p headers # => { ... }
|
||||
p data # => String
|
||||
rescue OpenapiClient::ApiError => e
|
||||
puts "Error when calling HeaderApi->test_header_integer_boolean_string_with_http_info: #{e}"
|
||||
puts "Error when calling HeaderApi->test_header_integer_boolean_string_enums_with_http_info: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
@@ -62,6 +64,8 @@ end
|
||||
| **integer_header** | **Integer** | | [optional] |
|
||||
| **boolean_header** | **Boolean** | | [optional] |
|
||||
| **string_header** | **String** | | [optional] |
|
||||
| **enum_nonref_string_header** | **String** | | [optional] |
|
||||
| **enum_ref_string_header** | [**StringEnumRef**](.md) | | [optional] |
|
||||
|
||||
### Return type
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ All URIs are relative to *http://localhost:3000*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
| ------ | ------------ | ----------- |
|
||||
| [**tests_path_string_path_string_integer_path_integer**](PathApi.md#tests_path_string_path_string_integer_path_integer) | **GET** /path/string/{path_string}/integer/{path_integer} | Test path parameter(s) |
|
||||
| [**tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path**](PathApi.md#tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path) | **GET** /path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path} | Test path parameter(s) |
|
||||
|
||||
|
||||
## tests_path_string_path_string_integer_path_integer
|
||||
## tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path
|
||||
|
||||
> String tests_path_string_path_string_integer_path_integer(path_string, path_integer)
|
||||
> String 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)
|
||||
|
||||
Test path parameter(s)
|
||||
|
||||
@@ -24,31 +24,33 @@ require 'openapi_client'
|
||||
api_instance = OpenapiClient::PathApi.new
|
||||
path_string = 'path_string_example' # String |
|
||||
path_integer = 56 # Integer |
|
||||
enum_nonref_string_path = 'success' # String |
|
||||
enum_ref_string_path = OpenapiClient::StringEnumRef::SUCCESS # StringEnumRef |
|
||||
|
||||
begin
|
||||
# Test path parameter(s)
|
||||
result = api_instance.tests_path_string_path_string_integer_path_integer(path_string, path_integer)
|
||||
result = api_instance.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)
|
||||
p result
|
||||
rescue OpenapiClient::ApiError => e
|
||||
puts "Error when calling PathApi->tests_path_string_path_string_integer_path_integer: #{e}"
|
||||
puts "Error when calling PathApi->tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
#### Using the tests_path_string_path_string_integer_path_integer_with_http_info variant
|
||||
#### Using the tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path_with_http_info variant
|
||||
|
||||
This returns an Array which contains the response data, status code and headers.
|
||||
|
||||
> <Array(String, Integer, Hash)> tests_path_string_path_string_integer_path_integer_with_http_info(path_string, path_integer)
|
||||
> <Array(String, Integer, Hash)> 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)
|
||||
|
||||
```ruby
|
||||
begin
|
||||
# Test path parameter(s)
|
||||
data, status_code, headers = api_instance.tests_path_string_path_string_integer_path_integer_with_http_info(path_string, path_integer)
|
||||
data, status_code, headers = api_instance.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)
|
||||
p status_code # => 2xx
|
||||
p headers # => { ... }
|
||||
p data # => String
|
||||
rescue OpenapiClient::ApiError => e
|
||||
puts "Error when calling PathApi->tests_path_string_path_string_integer_path_integer_with_http_info: #{e}"
|
||||
puts "Error when calling PathApi->tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path_with_http_info: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
@@ -58,6 +60,8 @@ end
|
||||
| ---- | ---- | ----------- | ----- |
|
||||
| **path_string** | **String** | | |
|
||||
| **path_integer** | **Integer** | | |
|
||||
| **enum_nonref_string_path** | **String** | | |
|
||||
| **enum_ref_string_path** | [**StringEnumRef**](.md) | | |
|
||||
|
||||
### Return type
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ require 'openapi_client'
|
||||
|
||||
api_instance = OpenapiClient::QueryApi.new
|
||||
opts = {
|
||||
enum_nonref_string_query: 'success', # String |
|
||||
enum_ref_string_query: OpenapiClient::StringEnumRef::SUCCESS # StringEnumRef |
|
||||
}
|
||||
|
||||
@@ -64,6 +65,7 @@ end
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
| ---- | ---- | ----------- | ----- |
|
||||
| **enum_nonref_string_query** | **String** | | [optional] |
|
||||
| **enum_ref_string_query** | [**StringEnumRef**](.md) | | [optional] |
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -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