rspec-rails-api 0.8.3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +8 -1
- data/README.md +1 -0
- data/lib/rspec/rails/api/open_api_renderer.rb +5 -3
- data/lib/rspec/rails/api/validator.rb +7 -1
- data/lib/rspec/rails/api/version.rb +1 -1
- data/lib/rspec_rails_api.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d61d749d64eb07dbb6958760895a8b5335a703a88b4e2eff44f987c526dce52
|
4
|
+
data.tar.gz: df1710c41a7ac14958f5e6ed0dc623597a51abd4f7a47b6d0188d73c9555b98b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b2cae44f3c07fe735199f767ea507d6f79c98cdf22d500026d5ad58aaec006db33b1d381a42b3b647211c7663778b3fdc110cf44db838354bcba228f7954aba
|
7
|
+
data.tar.gz: aa2b145cf56a14f55874dbad7b194b59a0c87e64f8d5b0f046e317e7fbc55ed80f8cc1a5fe9d9a70bedbcb719face6acad778086dbb7be7fcdc2e319d074f4d7
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-rails-api (0.
|
4
|
+
rspec-rails-api (0.9.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -17,6 +17,8 @@ GEM
|
|
17
17
|
minitest (>= 5.1)
|
18
18
|
securerandom (>= 0.3)
|
19
19
|
tzinfo (~> 2.0, >= 2.0.5)
|
20
|
+
addressable (2.8.7)
|
21
|
+
public_suffix (>= 2.0.2, < 7.0)
|
20
22
|
ast (2.4.2)
|
21
23
|
base64 (0.2.0)
|
22
24
|
bigdecimal (3.1.8)
|
@@ -29,6 +31,9 @@ GEM
|
|
29
31
|
i18n (1.14.6)
|
30
32
|
concurrent-ruby (~> 1.0)
|
31
33
|
json (2.7.2)
|
34
|
+
json-schema (5.1.1)
|
35
|
+
addressable (~> 2.8)
|
36
|
+
bigdecimal (~> 3.1)
|
32
37
|
language_server-protocol (3.17.0.3)
|
33
38
|
logger (1.6.1)
|
34
39
|
minitest (5.25.1)
|
@@ -36,6 +41,7 @@ GEM
|
|
36
41
|
parser (3.3.5.0)
|
37
42
|
ast (~> 2.4.1)
|
38
43
|
racc
|
44
|
+
public_suffix (6.0.1)
|
39
45
|
racc (1.8.1)
|
40
46
|
rack (3.1.7)
|
41
47
|
rainbow (3.1.1)
|
@@ -94,6 +100,7 @@ DEPENDENCIES
|
|
94
100
|
activesupport (~> 7.2)
|
95
101
|
bundler
|
96
102
|
byebug
|
103
|
+
json-schema
|
97
104
|
rack
|
98
105
|
rake (~> 10.0)
|
99
106
|
rspec (~> 3.0)
|
data/README.md
CHANGED
@@ -384,6 +384,7 @@ An attribute should have the following form:
|
|
384
384
|
- `:date`, `:datetime`
|
385
385
|
- `:password`
|
386
386
|
- `:object`, `:array`
|
387
|
+
- `:any` for an attribute of any type (except `null`; use `required: false` to allow null values)
|
387
388
|
|
388
389
|
- `description` should be some valid
|
389
390
|
[CommonMark](https://commonmark.org/)
|
@@ -226,8 +226,8 @@ module RSpec
|
|
226
226
|
entity.fields.each do |name, field|
|
227
227
|
property = {
|
228
228
|
description: field.description.presence&.strip || '',
|
229
|
-
type: PARAM_TYPES[field.type][:type],
|
230
229
|
}
|
230
|
+
property[:type] = PARAM_TYPES[field.type][:type] unless field.type == :any
|
231
231
|
property[:format] = PARAM_TYPES[field.type][:format] if PARAM_TYPES[field.type][:format]
|
232
232
|
|
233
233
|
if PRIMITIVES.include? field.attributes
|
@@ -235,9 +235,11 @@ module RSpec
|
|
235
235
|
elsif field.type == :object && field.attributes.is_a?(Symbol)
|
236
236
|
property = { '$ref' => "#/components/schemas/#{field.attributes}" }
|
237
237
|
elsif field.type == :object && field.attributes
|
238
|
-
property = { type: :object, description: field.description,
|
238
|
+
property = { type: :object, description: field.description,
|
239
|
+
properties: process_entity(field.attributes)[:properties] }
|
239
240
|
elsif field.type == :array && field.attributes.is_a?(Symbol)
|
240
|
-
property = { type: :array, description: field.description,
|
241
|
+
property = { type: :array, description: field.description,
|
242
|
+
items: { '$ref' => "#/components/schemas/#{field.attributes}" } }
|
241
243
|
elsif field.type == :array && field.attributes
|
242
244
|
property = { type: :array, description: field.description, items: process_entity(field.attributes) }
|
243
245
|
end
|
@@ -97,7 +97,13 @@ module RSpec
|
|
97
97
|
# @param type [Symbol] Type to compare to
|
98
98
|
#
|
99
99
|
# @return [String,NilClass] True when the value corresponds to the given type
|
100
|
-
def validate_type(value, type)
|
100
|
+
def validate_type(value, type) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
101
|
+
if type == :any
|
102
|
+
return 'is null' if value.nil?
|
103
|
+
|
104
|
+
return
|
105
|
+
end
|
106
|
+
|
101
107
|
if type == :boolean
|
102
108
|
return nil if value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
103
109
|
|
data/lib/rspec_rails_api.rb
CHANGED
@@ -34,6 +34,8 @@ module RSpec
|
|
34
34
|
array: { type: 'array', format: nil, class: Array },
|
35
35
|
object: { type: 'object', format: nil, class: Hash },
|
36
36
|
file: { type: 'string', format: 'binary' },
|
37
|
+
# Not a real type, but we want this
|
38
|
+
any: {},
|
37
39
|
}.freeze
|
38
40
|
|
39
41
|
PRIMITIVES = PARAM_TYPES.keys
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-rails-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Tancoigne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Create acceptance tests to check the Rails API responses and generate
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
|
-
rubygems_version: 3.
|
72
|
+
rubygems_version: 3.5.23
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: Tests standard Rails API responses and generate doc
|