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

Rename parameter_overwite_by_rails_rule to parameter_overwrite_by_rails_rule #396

Merged
merged 3 commits into from
May 16, 2024
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Rename `parameter_overwite_by_rails_rule` to `parameter_overwrite_by_rails_rule` #396

## [5.2.0] - 2024-05-04
- Error explicitly that OpenAPI 3.1+ isn't supported #418
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ Important changes are also described below.
Committee 5.* has few breaking changes so we recommend upgrading to the latest release on 4.* and fixing any deprecation errors you see before upgrading.

- set `parse_response_by_content_type=true` by default (old versions set `false`)
- set `parameter_overwite_by_rails_rule=true` by default (old version set `false`)
- set `parameter_overwrite_by_rails_rule=true` by default (old version set `false`)

#### Future Updates (5.*~)
OpenAPI3 Schema Users: Newly-added `strict_reference_validation` option defaults to `false` if not set.
Expand Down
2 changes: 1 addition & 1 deletion lib/committee/schema_validator/open_api_3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def request_unpack(request)
end

def copy_coerced_data_to_params(request)
order = if validator_option.parameter_overwite_by_rails_rule
order = if validator_option.parameter_overwrite_by_rails_rule
# (high priority) path_hash_key -> query_param -> request_body_hash
[validator_option.request_body_hash_key, validator_option.query_hash_key, validator_option.path_hash_key]
else
Expand Down
11 changes: 9 additions & 2 deletions lib/committee/schema_validator/option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Option
:optimistic_json,
:validate_success_only,
:parse_response_by_content_type,
:parameter_overwite_by_rails_rule
:parameter_overwrite_by_rails_rule

# Non-boolean options:
attr_reader :headers_key,
Expand Down Expand Up @@ -45,7 +45,14 @@ def initialize(options, schema, schema_type)
@coerce_recursive = options.fetch(:coerce_recursive, true)
@optimistic_json = options.fetch(:optimistic_json, false)
@parse_response_by_content_type = options.fetch(:parse_response_by_content_type, true)
@parameter_overwite_by_rails_rule = options.fetch(:parameter_overwite_by_rails_rule, true)

@parameter_overwrite_by_rails_rule =
if options.key?(:parameter_overwite_by_rails_rule)
Committee.warn_deprecated_until_6(true, "The option `parameter_overwite_by_rails_rule` is deprecated. Use `parameter_overwrite_by_rails_rule` instead.")
options[:parameter_overwite_by_rails_rule]
else
options.fetch(:parameter_overwrite_by_rails_rule, true)
end

# Boolean options and have a different value by default
@allow_get_body = options.fetch(:allow_get_body, schema.driver.default_allow_get_body)
Expand Down
6 changes: 3 additions & 3 deletions test/middleware/request_validation_open_api_3_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def app
assert_equal env['committee.query_hash']['integer'], 42
#assert_equal env['rack.request.query_hash'][:integer], 42 # this isn't hash indifferent hash because we use rack.request.query_hash
[204, {}, []]
end, schema: open_api_3_schema, parameter_overwite_by_rails_rule: false)
end, schema: open_api_3_schema, parameter_overwrite_by_rails_rule: false)

header "Content-Type", "application/json"
post '/overwrite_same_parameter?integer=42'
Expand All @@ -434,7 +434,7 @@ def app
assert_equal env['committee.request_body_hash'][:integer], 21
assert_equal env['committee.query_hash']['integer'], 42
[204, {}, []]
end, schema: open_api_3_schema, parameter_overwite_by_rails_rule: false)
end, schema: open_api_3_schema, parameter_overwrite_by_rails_rule: false)

params = {integer: 21}

Expand All @@ -454,7 +454,7 @@ def app
assert_equal env['committee.query_hash']['integer'], 84 # we can't use query_parameter :(
#assert_equal env['rack.request.query_hash'][:integer], 21 # this isn't hash indifferent hash because we use rack.request.query_hash
[204, {}, []]
end, schema: open_api_3_schema, parameter_overwite_by_rails_rule: false)
end, schema: open_api_3_schema, parameter_overwrite_by_rails_rule: false)

params = {integer: 21}

Expand Down