rspec-rails-api 0.8.2 → 0.9.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: 331b6d7af2333dde18fea74c45a4e07b01fae9d276540298eed0e7505423ae51
4
- data.tar.gz: 1691d15f501cd1d9fd56059b3fea6c9c5b40e2fa21e29c5912ca30c34713b4ce
3
+ metadata.gz: 2d61d749d64eb07dbb6958760895a8b5335a703a88b4e2eff44f987c526dce52
4
+ data.tar.gz: df1710c41a7ac14958f5e6ed0dc623597a51abd4f7a47b6d0188d73c9555b98b
5
5
  SHA512:
6
- metadata.gz: ef79c2fba59a70e1dbd9406360aa321bd59d289da466963cb54c74078dd1b60ad632e711491dfd4e869ce0fe912e8b4d0f30cdf125333ea49bb20691f3f354a9
7
- data.tar.gz: bdc2ec91fcea8cd0b3a27bef42f9d83e7a6527c7ad3b4f096066f78eec50fccec35c2db23dbd067f5353dc4d1fed1ee5baf3a70118194a053538cca6f9f951ce
6
+ metadata.gz: 8b2cae44f3c07fe735199f767ea507d6f79c98cdf22d500026d5ad58aaec006db33b1d381a42b3b647211c7663778b3fdc110cf44db838354bcba228f7954aba
7
+ data.tar.gz: aa2b145cf56a14f55874dbad7b194b59a0c87e64f8d5b0f046e317e7fbc55ed80f8cc1a5fe9d9a70bedbcb719face6acad778086dbb7be7fcdc2e319d074f4d7
data/CHANGELOG.md CHANGED
@@ -18,6 +18,18 @@ 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
+
27
+ ## [0.8.3] - 2024-11-22
28
+
29
+ ### Fixed
30
+
31
+ - Fixed documentation generation of the description on objects and arrays
32
+
21
33
  ## [0.8.2] - 2024-11-22
22
34
 
23
35
  ### 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.2)
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,11 +235,13 @@ 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, 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, 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
- property = { type: :array, items: process_entity(field.attributes) }
244
+ property = { type: :array, description: field.description, items: process_entity(field.attributes) }
243
245
  end
244
246
 
245
247
  required.push name unless field.required == false
@@ -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.2'
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.2
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