diff --git a/lib/openapi_parser.rb b/lib/openapi_parser.rb index 011d46a..b63e04c 100644 --- a/lib/openapi_parser.rb +++ b/lib/openapi_parser.rb @@ -81,14 +81,11 @@ def parse_file(content, ext) end def parse_yaml(content) - # FIXME: when drop ruby 2.5, we should use permitted_classes - (Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.6.0")) ? - Psych.safe_load(content, [Date, Time]) : - Psych.safe_load(content, permitted_classes: [Date, Time]) + Psych.safe_load(content, permitted_classes: [Date, Time]) end def parse_json(content) - raise "json content is nil" unless content + raise "json content is nil" unless content JSON.parse(content) end diff --git a/lib/openapi_parser/schema_validator/string_validator.rb b/lib/openapi_parser/schema_validator/string_validator.rb index e82f218..7d24dee 100644 --- a/lib/openapi_parser/schema_validator/string_validator.rb +++ b/lib/openapi_parser/schema_validator/string_validator.rb @@ -55,10 +55,7 @@ def validate_max_min_length(value, schema) def validate_email_format(value, schema) return [value, nil] unless schema.format == 'email' - # match? method is good performance. - # So when we drop ruby 2.3 support we use match? method because this method add ruby 2.4 - #return [value, nil] if value.match?(URI::MailTo::EMAIL_REGEXP) - return [value, nil] if value.match(URI::MailTo::EMAIL_REGEXP) + return [value, nil] if value.match?(URI::MailTo::EMAIL_REGEXP) return [nil, OpenAPIParser::InvalidEmailFormat.new(value, schema.object_reference)] end diff --git a/spec/openapi_parser/request_operation_spec.rb b/spec/openapi_parser/request_operation_spec.rb index fbdfd21..c4ab24f 100644 --- a/spec/openapi_parser/request_operation_spec.rb +++ b/spec/openapi_parser/request_operation_spec.rb @@ -110,11 +110,7 @@ it do expect { subject }.to raise_error do |e| expect(e).to be_kind_of(OpenAPIParser::ValidateError) - if Gem::Version.create(RUBY_VERSION) <= Gem::Version.create('2.4.0') - expect(e.message).to end_with("expected string, but received Fixnum: 1") - else - expect(e.message).to end_with("expected string, but received Integer: 1") - end + expect(e.message).to end_with("expected string, but received Integer: 1") end end end diff --git a/spec/openapi_parser/schema_validator_spec.rb b/spec/openapi_parser/schema_validator_spec.rb index 72d050c..da1fe4a 100644 --- a/spec/openapi_parser/schema_validator_spec.rb +++ b/spec/openapi_parser/schema_validator_spec.rb @@ -571,12 +571,7 @@ nested_array = params['nested_array'] first_data = nested_array[0] expect(first_data['update_time'].class).to eq DateTime - - if Gem::Version.create(RUBY_VERSION) <= Gem::Version.create('2.4.0') - expect(first_data['per_page'].class).to eq Fixnum # rubocop:disable Lint/UnifiedInteger - else - expect(first_data['per_page'].class).to eq Integer - end + expect(first_data['per_page'].class).to eq Integer end end @@ -774,27 +769,15 @@ nested_array = params['nested_array'] first_data = nested_array[0] expect(first_data['update_time'].class).to eq String - if Gem::Version.create(RUBY_VERSION) <= Gem::Version.create('2.4.0') - expect(first_data['per_page'].class).to eq Fixnum # rubocop:disable Lint/UnifiedInteger - else - expect(first_data['per_page'].class).to eq Integer - end + expect(first_data['per_page'].class).to eq Integer second_data = nested_array[1] expect(second_data['update_time'].class).to eq String - if Gem::Version.create(RUBY_VERSION) <= Gem::Version.create('2.4.0') - expect(first_data['per_page'].class).to eq Fixnum # rubocop:disable Lint/UnifiedInteger - else - expect(first_data['per_page'].class).to eq Integer - end + expect(first_data['per_page'].class).to eq Integer expect(second_data['threshold'].class).to eq Float third_data = nested_array[2] - if Gem::Version.create(RUBY_VERSION) <= Gem::Version.create('2.4.0') - expect(first_data['per_page'].class).to eq Fixnum # rubocop:disable Lint/UnifiedInteger - else - expect(first_data['per_page'].class).to eq Integer - end + expect(first_data['per_page'].class).to eq Integer expect(third_data['threshold'].class).to eq Float expect(first_data['nested_coercer_object']['update_time'].class).to eq String