rspec-openapi 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ce922f425644ad7ab8645bf2dcd7df5f93085e5e15cae1f826feff526fc96f6
4
- data.tar.gz: 19b7d372d3a1324903ec229f96292afdf738f99e492d76c16d281b9323e369f1
3
+ metadata.gz: 04e5d77bb080cac2d0509e9c5fa2220c03523db48a86b79ca43650ea8ce2ed94
4
+ data.tar.gz: 9c3132b8b801bed139325947f769ad13b8decf4ee4bcc5b31e59bbf1c7b8a0f8
5
5
  SHA512:
6
- metadata.gz: fe915320f2594675a5930eb28dd580f99fe4377e3c8dea443656d0de171187dd8cd30f2bbac720ea5c2a19271001e734740d09e472ee0cf7987caf89e11ebad6
7
- data.tar.gz: 2f41de3cafeeeb044748cf71bf6cd8163f4d083d145ea8c9adbf6dfeb57336d2582c1280086c5e008a8f679e7a03f780eca4e4a76b9ef741c3d2e40633d21d48
6
+ metadata.gz: 369b321e275862b7132e296f584e38ee75542e1ba12186384e6d0d63c40ba37596a7d5cae0e4a16354344d666426539bfbb3b65c44f7f4fa4fee6de50ff6ffb1
7
+ data.tar.gz: 132a1de49c02c15046662673ac79beba46d5616f17bba7661c4132a6daaf8bcb338e26f3900c63451fca7cf83bb072ce6fbc330dc62b5a2f900d65b5cc09a994
data/README.md CHANGED
@@ -897,7 +897,7 @@ responses:
897
897
  '400': { ... }
898
898
  ```
899
899
 
900
- Mixing `:single` (some tests) with `:multiple` (others) on the same endpoint also works for `requestBody` -
900
+ Mixing `:single` (some tests) with `:multiple` (others) on the same endpoint also works for `requestBody` -
901
901
  the merger up-converts the singular `example:` into the `examples:` map automatically
902
902
  (see [Merge Behavior with Mixed Modes](#merge-behavior-with-mixed-modes) below).
903
903
 
@@ -997,7 +997,7 @@ Existing RSpec plugins which have OpenAPI integration:
997
997
  ## Acknowledgements
998
998
 
999
999
  * Heavily inspired by [r7kamura/autodoc](https://github.com/r7kamura/autodoc)
1000
- * Orignally created by [k0kubun](https://github.com/k0kubun) and the ownership was transferred
1000
+ * Originally created by [k0kubun](https://github.com/k0kubun) and the ownership was transferred
1001
1001
  to [exoego](https://github.com/exoego) in 2022-11-29.
1002
1002
 
1003
1003
  ## Releasing
@@ -79,8 +79,19 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
79
79
  # because ActionController::ParamsWrapper overwrites request_parameters
80
80
  def raw_request_params(request)
81
81
  original = request.delete_header('action_dispatch.request.request_parameters')
82
- request.request_parameters
82
+ unwrap_json_root(request.request_parameters)
83
83
  ensure
84
84
  request.set_header('action_dispatch.request.request_parameters', original)
85
85
  end
86
+
87
+ # Rails' default JSON parser wraps a body that isn't a Hash - a top-level array,
88
+ # string, number, and so on - as `{ _json: <body> }`, so `request_parameters`
89
+ # stops reflecting what the client actually sent.
90
+ # See ActionDispatch::Http::Parameters::DEFAULT_PARSERS
91
+ def unwrap_json_root(params)
92
+ return params unless params.is_a?(Hash) && params.size == 1
93
+
94
+ key, value = params.first
95
+ key.to_s == '_json' ? value : params
96
+ end
86
97
  end
@@ -292,6 +292,9 @@ class << RSpec::OpenAPI::SchemaBuilder
292
292
 
293
293
  # Convert an always-String param to an appropriate type
294
294
  def try_cast(value)
295
+ return true if value == 'true'
296
+ return false if value == 'false'
297
+
295
298
  Integer(value)
296
299
  rescue TypeError, ArgumentError
297
300
  value
@@ -300,7 +303,7 @@ class << RSpec::OpenAPI::SchemaBuilder
300
303
  def build_example(value)
301
304
  return nil if value.nil?
302
305
 
303
- adjust_params(value.dup)
306
+ adjust_value(value.dup)
304
307
  end
305
308
 
306
309
  def adjust_params(hash)
@@ -101,9 +101,10 @@ class << RSpec::OpenAPI::SchemaCleaner = Object.new
101
101
  end
102
102
 
103
103
  def remove_parameters_conflicting_with_security_scheme!(path_definition, security_scheme, security_scheme_name)
104
- return unless path_definition[:security]
104
+ security = path_definition[:security]
105
+ return if !security || security.empty?
105
106
  return unless path_definition[:parameters]
106
- return unless path_definition.dig(:security, 0).keys.include?(security_scheme_name)
107
+ return unless security[0].keys.include?(security_scheme_name)
107
108
 
108
109
  path_definition[:parameters].reject! do |parameter|
109
110
  parameter[:in] == security_scheme[:in] && # same location (ie. header)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module OpenAPI
5
- VERSION = '0.30.0'
5
+ VERSION = '0.31.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-openapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.0
4
+ version: 0.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
@@ -97,7 +97,7 @@ licenses:
97
97
  metadata:
98
98
  homepage_uri: https://github.com/exoego/rspec-openapi
99
99
  source_code_uri: https://github.com/exoego/rspec-openapi
100
- changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.30.0
100
+ changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.31.0
101
101
  rubygems_mfa_required: 'true'
102
102
  rdoc_options: []
103
103
  require_paths:
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
- rubygems_version: 4.0.10
116
+ rubygems_version: 4.0.16
117
117
  specification_version: 4
118
118
  summary: Generate OpenAPI schema from RSpec request specs
119
119
  test_files: []