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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6196620d9b256a8ab9b95a82618671a1b3e12e26b01f1b99238512938fcab25
4
- data.tar.gz: d6a70286ac640e5d6f2e0030316b786ecff6642ea3acb1c5ce70d31f6ece3fde
3
+ metadata.gz: 2d61d749d64eb07dbb6958760895a8b5335a703a88b4e2eff44f987c526dce52
4
+ data.tar.gz: df1710c41a7ac14958f5e6ed0dc623597a51abd4f7a47b6d0188d73c9555b98b
5
5
  SHA512:
6
- metadata.gz: f1e3e62a5a7d3b37c80b5fee37bcaed6a3d8c2cbe5de560b35c14f52e556e87c25eb980d03c7154a1ad809f1b4ef5974faa85d3c7edfd77be03cb8a1bb82c3e1
7
- data.tar.gz: cf8e1745a4f9498062dd26495162c3a4f2ac6244850e0142106f0e27f2b4673393caf05bf1a647e55b3424901a02e32b9ab9cea32f387aaf3eac27e855f33709
6
+ metadata.gz: 8b2cae44f3c07fe735199f767ea507d6f79c98cdf22d500026d5ad58aaec006db33b1d381a42b3b647211c7663778b3fdc110cf44db838354bcba228f7954aba
7
+ data.tar.gz: aa2b145cf56a14f55874dbad7b194b59a0c87e64f8d5b0f046e317e7fbc55ed80f8cc1a5fe9d9a70bedbcb719face6acad778086dbb7be7fcdc2e319d074f4d7
data/CHANGELOG.md CHANGED
@@ -18,6 +18,12 @@ Maintenance, in case of rework, dependencies change
18
18
 
19
19
  ## [Unreleased]
20
20
 
21
+ ## [0.9.0] - 2024-12-26
22
+
23
+ ### Added
24
+
25
+ - Support for entries of any type: use `:any` as type
26
+
21
27
  ## [0.8.3] - 2024-11-22
22
28
 
23
29
  ### Fixed
data/Gemfile CHANGED
@@ -10,6 +10,7 @@ gemspec
10
10
  gem 'activesupport', '~> 7.2'
11
11
  gem 'bundler'
12
12
  gem 'byebug'
13
+ gem 'json-schema'
13
14
  gem 'rack'
14
15
  gem 'rake', '~> 10.0'
15
16
  gem 'rspec', '~> 3.0'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-rails-api (0.8.3)
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, properties: process_entity(field.attributes)[:properties] }
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, items: { '$ref' => "#/components/schemas/#{field.attributes}" } }
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
 
@@ -3,7 +3,7 @@
3
3
  module RSpec
4
4
  module Rails
5
5
  module Api
6
- VERSION = '0.8.3'
6
+ VERSION = '0.9.0'
7
7
  end
8
8
  end
9
9
  end
@@ -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.8.3
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-22 00:00:00.000000000 Z
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.3.7
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