diff --git a/modules/openapi-generator/src/main/resources/ruby-client/api.mustache b/modules/openapi-generator/src/main/resources/ruby-client/api.mustache index b99c918b9205..4ed87a3f84de 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/api.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/api.mustache @@ -146,7 +146,10 @@ module {{moduleName}} {{/hasProduces}} {{#hasConsumes}} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type([{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}]) + content_type = @api_client.select_header_content_type([{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}]) + if !content_type.nil? + header_params['Content-Type'] = content_type + end {{/hasConsumes}} {{#headerParams}} {{#required}} diff --git a/modules/openapi-generator/src/main/resources/ruby-client/api_client.mustache b/modules/openapi-generator/src/main/resources/ruby-client/api_client.mustache index 2741a73794ed..f9df84ebe0a0 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/api_client.mustache @@ -209,8 +209,8 @@ module {{moduleName}} # @param [Array] content_types array for Content-Type # @return [String] the Content-Type header (e.g. application/json) def select_header_content_type(content_types) - # use application/json by default - return 'application/json' if content_types.nil? || content_types.empty? + # return nil by default + return if content_types.nil? || content_types.empty? # use JSON when present, otherwise use the first one json_content_type = content_types.find { |s| json_mime?(s) } json_content_type || content_types.first diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/api/another_fake_api.rb b/samples/client/petstore/ruby-faraday/lib/petstore/api/another_fake_api.rb index 6145ff7431c0..562ea851aa1b 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/api/another_fake_api.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/api/another_fake_api.rb @@ -53,7 +53,10 @@ def call_123_test_special_tags_with_http_info(client, opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb b/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb index 50a336275d71..8d0d36fdb780 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb @@ -109,7 +109,10 @@ def fake_http_signature_test_with_http_info(pet, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml']) + content_type = @api_client.select_header_content_type(['application/json', 'application/xml']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end header_params[:'header_1'] = opts[:'header_1'] if !opts[:'header_1'].nil? # form parameters @@ -169,7 +172,10 @@ def fake_outer_boolean_serialize_with_http_info(opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -228,7 +234,10 @@ def fake_outer_composite_serialize_with_http_info(opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -287,7 +296,10 @@ def fake_outer_number_serialize_with_http_info(opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -346,7 +358,10 @@ def fake_outer_string_serialize_with_http_info(opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -409,7 +424,10 @@ def fake_property_enum_integer_serialize_with_http_info(outer_object_with_enum_p # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -466,7 +484,10 @@ def test_body_with_binary_with_http_info(body, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['image/png']) + content_type = @api_client.select_header_content_type(['image/png']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -527,7 +548,10 @@ def test_body_with_file_schema_with_http_info(file_schema_test_class, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -593,7 +617,10 @@ def test_body_with_query_params_with_http_info(query, user, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -658,7 +685,10 @@ def test_client_model_with_http_info(client, opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -813,7 +843,10 @@ def test_endpoint_parameters_with_http_info(number, double, pattern_without_deli # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -936,7 +969,10 @@ def test_enum_parameters_with_http_info(opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end header_params[:'enum_header_string_array'] = @api_client.build_collection_param(opts[:'enum_header_string_array'], :csv) if !opts[:'enum_header_string_array'].nil? header_params[:'enum_header_string'] = opts[:'enum_header_string'] if !opts[:'enum_header_string'].nil? @@ -1086,7 +1122,10 @@ def test_inline_additional_properties_with_http_info(request_body, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -1153,7 +1192,10 @@ def test_json_form_data_with_http_info(param, param2, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_classname_tags123_api.rb b/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_classname_tags123_api.rb index fd68ab477734..062c9623242c 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_classname_tags123_api.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_classname_tags123_api.rb @@ -53,7 +53,10 @@ def test_classname_with_http_info(client, opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby-faraday/lib/petstore/api/pet_api.rb index 4754887194d1..c7ac2f5f90d2 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/api/pet_api.rb @@ -49,7 +49,10 @@ def add_pet_with_http_info(pet, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml']) + content_type = @api_client.select_header_content_type(['application/json', 'application/xml']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -363,7 +366,10 @@ def update_pet_with_http_info(pet, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml']) + content_type = @api_client.select_header_content_type(['application/json', 'application/xml']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -428,7 +434,10 @@ def update_pet_with_form_with_http_info(pet_id, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -497,7 +506,10 @@ def upload_file_with_http_info(pet_id, opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) + content_type = @api_client.select_header_content_type(['multipart/form-data']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -570,7 +582,10 @@ def upload_file_with_required_file_with_http_info(pet_id, required_file, opts = # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) + content_type = @api_client.select_header_content_type(['multipart/form-data']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby-faraday/lib/petstore/api/store_api.rb index 3851c7b2ab6f..2348fe5a33f0 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/api/store_api.rb @@ -240,7 +240,10 @@ def place_order_with_http_info(order, opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby-faraday/lib/petstore/api/user_api.rb index 73bca582e269..aa331609f5e3 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/api/user_api.rb @@ -51,7 +51,10 @@ def create_user_with_http_info(user, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -112,7 +115,10 @@ def create_users_with_array_input_with_http_info(user, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -173,7 +179,10 @@ def create_users_with_list_input_with_http_info(user, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -486,7 +495,10 @@ def update_user_with_http_info(username, user, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/api_client.rb b/samples/client/petstore/ruby-faraday/lib/petstore/api_client.rb index c50394c22f26..f93574cd078f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/api_client.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/api_client.rb @@ -340,8 +340,8 @@ def select_header_accept(accepts) # @param [Array] content_types array for Content-Type # @return [String] the Content-Type header (e.g. application/json) def select_header_content_type(content_types) - # use application/json by default - return 'application/json' if content_types.nil? || content_types.empty? + # return nil by default + return if content_types.nil? || content_types.empty? # use JSON when present, otherwise use the first one json_content_type = content_types.find { |s| json_mime?(s) } json_content_type || content_types.first diff --git a/samples/client/petstore/ruby/lib/petstore/api/another_fake_api.rb b/samples/client/petstore/ruby/lib/petstore/api/another_fake_api.rb index 6145ff7431c0..562ea851aa1b 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/another_fake_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/another_fake_api.rb @@ -53,7 +53,10 @@ def call_123_test_special_tags_with_http_info(client, opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb b/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb index 50a336275d71..8d0d36fdb780 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb @@ -109,7 +109,10 @@ def fake_http_signature_test_with_http_info(pet, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml']) + content_type = @api_client.select_header_content_type(['application/json', 'application/xml']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end header_params[:'header_1'] = opts[:'header_1'] if !opts[:'header_1'].nil? # form parameters @@ -169,7 +172,10 @@ def fake_outer_boolean_serialize_with_http_info(opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -228,7 +234,10 @@ def fake_outer_composite_serialize_with_http_info(opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -287,7 +296,10 @@ def fake_outer_number_serialize_with_http_info(opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -346,7 +358,10 @@ def fake_outer_string_serialize_with_http_info(opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -409,7 +424,10 @@ def fake_property_enum_integer_serialize_with_http_info(outer_object_with_enum_p # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -466,7 +484,10 @@ def test_body_with_binary_with_http_info(body, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['image/png']) + content_type = @api_client.select_header_content_type(['image/png']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -527,7 +548,10 @@ def test_body_with_file_schema_with_http_info(file_schema_test_class, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -593,7 +617,10 @@ def test_body_with_query_params_with_http_info(query, user, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -658,7 +685,10 @@ def test_client_model_with_http_info(client, opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -813,7 +843,10 @@ def test_endpoint_parameters_with_http_info(number, double, pattern_without_deli # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -936,7 +969,10 @@ def test_enum_parameters_with_http_info(opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end header_params[:'enum_header_string_array'] = @api_client.build_collection_param(opts[:'enum_header_string_array'], :csv) if !opts[:'enum_header_string_array'].nil? header_params[:'enum_header_string'] = opts[:'enum_header_string'] if !opts[:'enum_header_string'].nil? @@ -1086,7 +1122,10 @@ def test_inline_additional_properties_with_http_info(request_body, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -1153,7 +1192,10 @@ def test_json_form_data_with_http_info(param, param2, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/client/petstore/ruby/lib/petstore/api/fake_classname_tags123_api.rb b/samples/client/petstore/ruby/lib/petstore/api/fake_classname_tags123_api.rb index fd68ab477734..062c9623242c 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/fake_classname_tags123_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/fake_classname_tags123_api.rb @@ -53,7 +53,10 @@ def test_classname_with_http_info(client, opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index 13b4b66578da..8d67c322d7ac 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -49,7 +49,10 @@ def add_pet_with_http_info(pet, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml']) + content_type = @api_client.select_header_content_type(['application/json', 'application/xml']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -363,7 +366,10 @@ def update_pet_with_http_info(pet, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml']) + content_type = @api_client.select_header_content_type(['application/json', 'application/xml']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -428,7 +434,10 @@ def update_pet_with_form_with_http_info(pet_id, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -497,7 +506,10 @@ def upload_file_with_http_info(pet_id, opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) + content_type = @api_client.select_header_content_type(['multipart/form-data']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -570,7 +582,10 @@ def upload_file_with_required_file_with_http_info(pet_id, required_file, opts = # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) + content_type = @api_client.select_header_content_type(['multipart/form-data']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index df456319b41b..4595f89c8a01 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -240,7 +240,10 @@ def place_order_with_http_info(order, opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb index 879e9eb4ad6a..0265e6739ab4 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -51,7 +51,10 @@ def create_user_with_http_info(user, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -112,7 +115,10 @@ def create_users_with_array_input_with_http_info(user, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -173,7 +179,10 @@ def create_users_with_list_input_with_http_info(user, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -486,7 +495,10 @@ def update_user_with_http_info(username, user, opts = {}) # header parameters header_params = opts[:header_params] || {} # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/client/petstore/ruby/lib/petstore/api_client.rb b/samples/client/petstore/ruby/lib/petstore/api_client.rb index 3a1bf4bd35d3..bcc8dac64869 100644 --- a/samples/client/petstore/ruby/lib/petstore/api_client.rb +++ b/samples/client/petstore/ruby/lib/petstore/api_client.rb @@ -335,8 +335,8 @@ def select_header_accept(accepts) # @param [Array] content_types array for Content-Type # @return [String] the Content-Type header (e.g. application/json) def select_header_content_type(content_types) - # use application/json by default - return 'application/json' if content_types.nil? || content_types.empty? + # return nil by default + return if content_types.nil? || content_types.empty? # use JSON when present, otherwise use the first one json_content_type = content_types.find { |s| json_mime?(s) } json_content_type || content_types.first diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/lib/x_auth_id_alias/api_client.rb b/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/lib/x_auth_id_alias/api_client.rb index dceb19bdb223..5eadf765d1bc 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/lib/x_auth_id_alias/api_client.rb +++ b/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/lib/x_auth_id_alias/api_client.rb @@ -335,8 +335,8 @@ def select_header_accept(accepts) # @param [Array] content_types array for Content-Type # @return [String] the Content-Type header (e.g. application/json) def select_header_content_type(content_types) - # use application/json by default - return 'application/json' if content_types.nil? || content_types.empty? + # return nil by default + return if content_types.nil? || content_types.empty? # use JSON when present, otherwise use the first one json_content_type = content_types.find { |s| json_mime?(s) } json_content_type || content_types.first diff --git a/samples/openapi3/client/features/dynamic-servers/ruby/lib/dynamic_servers/api_client.rb b/samples/openapi3/client/features/dynamic-servers/ruby/lib/dynamic_servers/api_client.rb index 5e236ccddd9b..41ed766d75ac 100644 --- a/samples/openapi3/client/features/dynamic-servers/ruby/lib/dynamic_servers/api_client.rb +++ b/samples/openapi3/client/features/dynamic-servers/ruby/lib/dynamic_servers/api_client.rb @@ -334,8 +334,8 @@ def select_header_accept(accepts) # @param [Array] content_types array for Content-Type # @return [String] the Content-Type header (e.g. application/json) def select_header_content_type(content_types) - # use application/json by default - return 'application/json' if content_types.nil? || content_types.empty? + # return nil by default + return if content_types.nil? || content_types.empty? # use JSON when present, otherwise use the first one json_content_type = content_types.find { |s| json_mime?(s) } json_content_type || content_types.first diff --git a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/api/usage_api.rb b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/api/usage_api.rb index 355c78dd797b..e26793ea11ad 100644 --- a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/api/usage_api.rb +++ b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/api/usage_api.rb @@ -49,7 +49,10 @@ def array_with_http_info(opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} @@ -110,7 +113,10 @@ def map_with_http_info(opts = {}) # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end # form parameters form_params = opts[:form_params] || {} diff --git a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/api_client.rb b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/api_client.rb index 02e0f300d109..494f75ddd7cf 100644 --- a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/api_client.rb +++ b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/api_client.rb @@ -334,8 +334,8 @@ def select_header_accept(accepts) # @param [Array] content_types array for Content-Type # @return [String] the Content-Type header (e.g. application/json) def select_header_content_type(content_types) - # use application/json by default - return 'application/json' if content_types.nil? || content_types.empty? + # return nil by default + return if content_types.nil? || content_types.empty? # use JSON when present, otherwise use the first one json_content_type = content_types.find { |s| json_mime?(s) } json_content_type || content_types.first