[Ruby] Can only use content-type application/json with ruby-client #4867 (#4893)

* Fix ruby-client work with modern content types, like application/api.vnd+json

* Add specs.

* Fix regexp.

* Regenerate petstore client.
This commit is contained in:
Viktor Chukhantsev 2017-03-05 23:44:15 +07:00 committed by wing328
parent a91cbbe387
commit 35d3fb82ce
5 changed files with 15 additions and 14 deletions

View File

@ -129,7 +129,7 @@ module {{moduleName}}
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == "*/*") || !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil?
(mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
end
# Deserialize the response to the given return type.

View File

@ -179,6 +179,7 @@ describe Petstore::ApiClient do
expect(api_client.json_mime?('')).to eq false
expect(api_client.json_mime?('application/json')).to eq true
expect(api_client.json_mime?('application/api.vnd+json')).to eq true
expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
expect(api_client.json_mime?('APPLICATION/JSON')).to eq true

View File

@ -145,20 +145,20 @@ module Petstore
# verify the required parameter 'byte' is set
fail ArgumentError, "Missing the required parameter 'byte' when calling FakeApi.test_endpoint_parameters" if byte.nil?
if !opts[:'integer'].nil? && opts[:'integer'] > 100.0
fail ArgumentError, 'invalid value for "opts[:"integer"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 100.0.'
if !opts[:'integer'].nil? && opts[:'integer'] > 100
fail ArgumentError, 'invalid value for "opts[:"integer"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 100.'
end
if !opts[:'integer'].nil? && opts[:'integer'] < 10.0
fail ArgumentError, 'invalid value for "opts[:"integer"]" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 10.0.'
if !opts[:'integer'].nil? && opts[:'integer'] < 10
fail ArgumentError, 'invalid value for "opts[:"integer"]" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 10.'
end
if !opts[:'int32'].nil? && opts[:'int32'] > 200.0
fail ArgumentError, 'invalid value for "opts[:"int32"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 200.0.'
if !opts[:'int32'].nil? && opts[:'int32'] > 200
fail ArgumentError, 'invalid value for "opts[:"int32"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 200.'
end
if !opts[:'int32'].nil? && opts[:'int32'] < 20.0
fail ArgumentError, 'invalid value for "opts[:"int32"]" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 20.0.'
if !opts[:'int32'].nil? && opts[:'int32'] < 20
fail ArgumentError, 'invalid value for "opts[:"int32"]" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 20.'
end
if !opts[:'float'].nil? && opts[:'float'] > 987.6

View File

@ -137,12 +137,12 @@ module Petstore
end
# verify the required parameter 'order_id' is set
fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.get_order_by_id" if order_id.nil?
if order_id > 5.0
fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.get_order_by_id, must be smaller than or equal to 5.0.'
if order_id > 5
fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.get_order_by_id, must be smaller than or equal to 5.'
end
if order_id < 1.0
fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.get_order_by_id, must be greater than or equal to 1.0.'
if order_id < 1
fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.get_order_by_id, must be greater than or equal to 1.'
end
# resource path

View File

@ -134,7 +134,7 @@ module Petstore
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == "*/*") || !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil?
(mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
end
# Deserialize the response to the given return type.