rspec-openapi 0.4.7 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +13 -5
- data/CHANGELOG.md +15 -0
- data/Gemfile +1 -1
- data/README.md +2 -0
- data/lib/rspec/openapi/hooks.rb +2 -2
- data/lib/rspec/openapi/schema_builder.rb +6 -0
- data/lib/rspec/openapi/schema_merger.rb +11 -10
- data/lib/rspec/openapi/version.rb +1 -1
- data/rspec-openapi.gemspec +1 -1
- metadata +4 -5
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a696c48f7c8321f2b6807cd7b87ce31238c8cf5670fc9159fd4683cbb3c0698b
|
4
|
+
data.tar.gz: 4ac66642cb916439782d6a28aaf393da4e240f7579e1a8c072f679267b697869
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1f84f9475e56012381b1cc37dc4efcfe8eef0b09bdd6e94641c4961ef58b090312493501dfafc8a0ae6a48987da9f8db1f7fea0781b8ec35d4f3dcccf0d17b0
|
7
|
+
data.tar.gz: f49341e3bb0886b26670c0be59a1a878291e65761f727ccf15d7076bcdada19bc5745cc7c78428c1e8b2338cc2b4665697569e3588630910ecf21338a19645f1
|
data/.github/workflows/test.yml
CHANGED
@@ -15,11 +15,19 @@ jobs:
|
|
15
15
|
strategy:
|
16
16
|
fail-fast: false
|
17
17
|
matrix:
|
18
|
-
|
19
|
-
- ruby:2.5
|
20
|
-
- ruby:2.6
|
21
|
-
- ruby:2.7
|
22
|
-
- ruby:3.0
|
18
|
+
include:
|
19
|
+
- ruby: ruby:2.5
|
20
|
+
- ruby: ruby:2.6
|
21
|
+
- ruby: ruby:2.7
|
22
|
+
- ruby: ruby:3.0
|
23
|
+
- ruby: ruby:3.1
|
24
|
+
rails: 6.0.5
|
25
|
+
- ruby: ruby:3.1
|
26
|
+
rails: 6.1.6
|
27
|
+
- ruby: ruby:3.1
|
28
|
+
rails: 7.0.3
|
29
|
+
env:
|
30
|
+
RAILS_VERSION: ${{ matrix.rails == '' && '6.1.6' || matrix.rails }}
|
23
31
|
steps:
|
24
32
|
- uses: actions/checkout@v2
|
25
33
|
- name: bundle install
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## v0.5.1
|
2
|
+
|
3
|
+
* Clarify the version requirement for actionpack
|
4
|
+
[#62](https://github.com/k0kubun/rspec-openapi/pull/62)
|
5
|
+
|
6
|
+
## v0.5.0
|
7
|
+
|
8
|
+
* Overwrite fields in an existing schema file instead of leaving all existing fields as is
|
9
|
+
[#55](https://github.com/k0kubun/rspec-openapi/pull/55)
|
10
|
+
|
11
|
+
## v0.4.8
|
12
|
+
|
13
|
+
* Fix a bug in nested parameters handling
|
14
|
+
[#46](https://github.com/k0kubun/rspec-openapi/pull/46)
|
15
|
+
|
1
16
|
## v0.4.7
|
2
17
|
|
3
18
|
* Add `info` config hash
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -105,6 +105,8 @@ and the schema file can be used as an input of [Swagger UI](https://github.com/s
|
|
105
105
|
The following configurations are optional.
|
106
106
|
|
107
107
|
```rb
|
108
|
+
require 'rspec/openapi'
|
109
|
+
|
108
110
|
# Change the path to generate schema from `doc/openapi.yaml`
|
109
111
|
RSpec::OpenAPI.path = 'doc/schema.yaml'
|
110
112
|
|
data/lib/rspec/openapi/hooks.rb
CHANGED
@@ -22,10 +22,10 @@ RSpec.configuration.after(:suite) do
|
|
22
22
|
RSpec::OpenAPI::SchemaFile.new(path).edit do |spec|
|
23
23
|
schema = RSpec::OpenAPI::DefaultSchema.build(title)
|
24
24
|
schema[:info].merge!(RSpec::OpenAPI.info)
|
25
|
-
RSpec::OpenAPI::SchemaMerger.
|
25
|
+
RSpec::OpenAPI::SchemaMerger.merge!(spec, schema)
|
26
26
|
records.each do |record|
|
27
27
|
begin
|
28
|
-
RSpec::OpenAPI::SchemaMerger.
|
28
|
+
RSpec::OpenAPI::SchemaMerger.merge!(spec, RSpec::OpenAPI::SchemaBuilder.build(record))
|
29
29
|
rescue StandardError, NotImplementedError => e # e.g. SchemaBuilder raises a NotImplementedError
|
30
30
|
error_records[e] = record # Avoid failing the build
|
31
31
|
end
|
@@ -158,9 +158,15 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
158
158
|
def build_example(value)
|
159
159
|
return nil if value.nil?
|
160
160
|
value = value.dup
|
161
|
+
adjust_params(value)
|
162
|
+
end
|
163
|
+
|
164
|
+
def adjust_params(value)
|
161
165
|
value.each do |key, v|
|
162
166
|
if v.is_a?(ActionDispatch::Http::UploadedFile)
|
163
167
|
value[key] = v.original_filename
|
168
|
+
elsif v.is_a?(Hash)
|
169
|
+
adjust_params(v)
|
164
170
|
end
|
165
171
|
end
|
166
172
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class << RSpec::OpenAPI::SchemaMerger = Object.new
|
2
2
|
# @param [Hash] base
|
3
3
|
# @param [Hash] spec
|
4
|
-
def
|
4
|
+
def merge!(base, spec)
|
5
5
|
spec = normalize_keys(spec)
|
6
|
-
|
6
|
+
merge_schema!(base, spec)
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
@@ -22,25 +22,26 @@ class << RSpec::OpenAPI::SchemaMerger = Object.new
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# Not doing `base.replace(deep_merge(base, spec))` to preserve key orders.
|
25
|
-
# Also this needs to be aware of OpenAPI details
|
26
|
-
#
|
25
|
+
# Also this needs to be aware of OpenAPI details because a Hash-like structure
|
26
|
+
# may be an array whose Hash elements have a key name.
|
27
27
|
#
|
28
|
-
# TODO: Perform more intelligent merges like rerouting edits / merging types
|
29
28
|
# TODO: Should we probably force-merge `summary` regardless of manual modifications?
|
30
|
-
def
|
29
|
+
def merge_schema!(base, spec)
|
31
30
|
spec.each do |key, value|
|
32
31
|
if base[key].is_a?(Hash) && value.is_a?(Hash)
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
if !base[key].key?("$ref")
|
33
|
+
merge_schema!(base[key], value)
|
34
|
+
end
|
36
35
|
elsif base[key].is_a?(Array) && value.is_a?(Array)
|
37
36
|
# parameters need to be merged as if `name` and `in` were the Hash keys.
|
38
37
|
if key == 'parameters'
|
39
38
|
base[key] |= value
|
40
39
|
base[key].uniq! { |param| param.slice('name', 'in') }
|
40
|
+
else
|
41
|
+
base[key] = value
|
41
42
|
end
|
42
43
|
else
|
43
|
-
|
44
|
+
base[key] = value
|
44
45
|
end
|
45
46
|
end
|
46
47
|
base
|
data/rspec-openapi.gemspec
CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
|
-
spec.add_dependency 'actionpack'
|
26
|
+
spec.add_dependency 'actionpack', '>= 5.2.0'
|
27
27
|
spec.add_dependency 'rspec'
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-openapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 5.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,6 @@ files:
|
|
49
49
|
- ".github/workflows/test.yml"
|
50
50
|
- ".gitignore"
|
51
51
|
- ".rspec"
|
52
|
-
- ".travis.yml"
|
53
52
|
- CHANGELOG.md
|
54
53
|
- Gemfile
|
55
54
|
- LICENSE.txt
|