Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the build green for modern ruby and rack and rubocop-rspec #939

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require:
- rubocop-rails
- rubocop-rspec
- rubocop-rspec_rails
- rubocop-performance

inherit_from: .rubocop_todo.yml
Expand Down
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ RSpec/PredicateMatcher:
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Inferences.
RSpec/Rails/InferredSpecType:
RSpecRails/InferredSpecType:
Exclude:
- 'spec/controllers/pets_controller_spec.rb'

Expand Down
1 change: 1 addition & 0 deletions apipie-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rubocop-rails'
s.add_development_dependency 'rubocop-rspec'
s.add_development_dependency 'rubocop-performance'
s.add_development_dependency 'rubocop-rspec_rails' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7")
s.add_development_dependency "simplecov"
s.add_development_dependency "sqlite3"
end
8 changes: 6 additions & 2 deletions lib/apipie/error_description.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ def initialize(code_or_options, desc = nil, options = {})
@metadata = code_or_options[:meta]
@description = code_or_options[:desc] || code_or_options[:description]
else
@code =
@code =
if code_or_options.is_a? Symbol
Rack::Utils::SYMBOL_TO_STATUS_CODE[code_or_options]
begin
Rack::Utils.status_code(code_or_options)
rescue ArgumentError
nil
end
else
code_or_options
end
Expand Down
4 changes: 2 additions & 2 deletions lib/apipie/extractor/recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def analyse_env(env)
@params = Rack::Utils.parse_nested_query(@query)
@params.merge!(env["action_dispatch.request.request_parameters"] || {})
rack_input = env["rack.input"]
if data = parse_data(rack_input.read)
if data = parse_data(rack_input&.read)
@request_data = data
elsif form_hash = env["rack.request.form_hash"]
@request_data = reformat_multipart_data(form_hash)
end
rack_input.rewind
rack_input&.rewind
end

def analyse_controller(controller)
Expand Down
15 changes: 10 additions & 5 deletions lib/apipie/response_description.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,16 @@ def initialize(method_description, code, options, scope, block, adapter)

@method_description = method_description

if code.is_a? Symbol
@code = Rack::Utils::SYMBOL_TO_STATUS_CODE[code]
else
@code = code
end
@code =
if code.is_a? Symbol
begin
Rack::Utils.status_code(code)
rescue ArgumentError
nil
end
else
code
end

@description = options[:desc]
if @description.nil?
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/swagger/swagger_dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def have_field?(field, expected_name, breadcrumb)
expect(schema).to have_field(:pet_id, 'number', {:description => 'id of pet'})
expect(schema).to have_field(:pet_name, 'string', {:description => 'Name of pet', :required => false})
expect(schema).to have_field(:animal_type, 'string', {:description => 'Type of pet', :enum => %w[dog cat iguana kangaroo]})
expect(schema).not_to have_field(:partial_match_allowed, 'boolean', {:required => false}) # rubocop:disable Capybara/NegationMatcher
expect(schema).not_to have_field(:partial_match_allowed, 'boolean', {:required => false})
end

it "creates a swagger definition with all input parameters" do
Expand Down
Loading