Skip to content

Commit

Permalink
Style/MapIntoArray: Use map instead of each to map elements into an a…
Browse files Browse the repository at this point in the history
…rray. (#214)
  • Loading branch information
exoego authored Apr 17, 2024
1 parent 2efb549 commit 87fc7ea
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/rspec/openapi/schema_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ def example_enabled?
end

def build_parameters(record)
parameters = []

record.path_params.each do |key, value|
parameters << {
path_params = record.path_params.map do |key, value|
{
name: build_parameter_name(key, value),
in: 'path',
required: true,
Expand All @@ -76,8 +74,8 @@ def build_parameters(record)
}.compact
end

record.query_params.each do |key, value|
parameters << {
query_params = record.query_params.map do |key, value|
{
name: build_parameter_name(key, value),
in: 'query',
required: record.required_request_params.include?(key),
Expand All @@ -86,8 +84,8 @@ def build_parameters(record)
}.compact
end

record.request_headers.each do |key, value|
parameters << {
header_params = record.request_headers.map do |key, value|
{
name: build_parameter_name(key, value),
in: 'header',
required: true,
Expand All @@ -96,6 +94,8 @@ def build_parameters(record)
}.compact
end

parameters = path_params + query_params + header_params

return nil if parameters.empty?

parameters
Expand Down

0 comments on commit 87fc7ea

Please sign in to comment.