jbuilder-schema 2.2.0 → 2.3.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: 220162d597f3e157552d3ca783f9b4aba191f21ce2fb69172f24608d1439e840
4
- data.tar.gz: 5ffd2a9d013ab15ff47d3d98dc4bcad5f79c735892f6733286d29032ee5d08f8
3
+ metadata.gz: f7d989f5d37de77b8e1a0dc0703619f334f3d5605ec3458b6508d2f1712241d9
4
+ data.tar.gz: 11c116736ae75e9c5e6cca37cd244a538ca68feb3d168d8b2c01861b26515cb4
5
5
  SHA512:
6
- metadata.gz: 86cedff5f98aa84fe8399361058ecff9cb29cbfe63f3b2b2d9894b238b87348692b7354effbef595e83e9b86c01ceeac7f0dd2499c3d20b66e6874653cfcec4f
7
- data.tar.gz: a40c484ba860d6f50669c83535deb0047c908f47c82bb59f757752d4ec6e1d30f1872bcfa9cb4636cd8df6de6a5a73d6ac290397c9ca9c28c26df70a17d34725
6
+ metadata.gz: c069b534a6f5f044193c9fb9432b104e66d7d6d158b2969bea0ceb33be4db85dc178b5d971b3efab75bec54c21d5c05050aa2eeebc8546a86a5f27aaf3ddd41e
7
+ data.tar.gz: 8738536e32a3db5a21037b32acf91a6dcc59b2e69745046ab8d68d03ab847979f36f80801f9be6927276eda7fe8ad1f2573838813575d4ac5802a8294b635097
data/Gemfile.lock CHANGED
@@ -1,97 +1,98 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jbuilder-schema (2.2.0)
4
+ jbuilder-schema (2.3.0)
5
5
  jbuilder
6
6
  rails (>= 5.0.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (7.0.4.3)
12
- actionpack (= 7.0.4.3)
13
- activesupport (= 7.0.4.3)
11
+ actioncable (7.0.8)
12
+ actionpack (= 7.0.8)
13
+ activesupport (= 7.0.8)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (7.0.4.3)
17
- actionpack (= 7.0.4.3)
18
- activejob (= 7.0.4.3)
19
- activerecord (= 7.0.4.3)
20
- activestorage (= 7.0.4.3)
21
- activesupport (= 7.0.4.3)
16
+ actionmailbox (7.0.8)
17
+ actionpack (= 7.0.8)
18
+ activejob (= 7.0.8)
19
+ activerecord (= 7.0.8)
20
+ activestorage (= 7.0.8)
21
+ activesupport (= 7.0.8)
22
22
  mail (>= 2.7.1)
23
23
  net-imap
24
24
  net-pop
25
25
  net-smtp
26
- actionmailer (7.0.4.3)
27
- actionpack (= 7.0.4.3)
28
- actionview (= 7.0.4.3)
29
- activejob (= 7.0.4.3)
30
- activesupport (= 7.0.4.3)
26
+ actionmailer (7.0.8)
27
+ actionpack (= 7.0.8)
28
+ actionview (= 7.0.8)
29
+ activejob (= 7.0.8)
30
+ activesupport (= 7.0.8)
31
31
  mail (~> 2.5, >= 2.5.4)
32
32
  net-imap
33
33
  net-pop
34
34
  net-smtp
35
35
  rails-dom-testing (~> 2.0)
36
- actionpack (7.0.4.3)
37
- actionview (= 7.0.4.3)
38
- activesupport (= 7.0.4.3)
39
- rack (~> 2.0, >= 2.2.0)
36
+ actionpack (7.0.8)
37
+ actionview (= 7.0.8)
38
+ activesupport (= 7.0.8)
39
+ rack (~> 2.0, >= 2.2.4)
40
40
  rack-test (>= 0.6.3)
41
41
  rails-dom-testing (~> 2.0)
42
42
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
43
- actiontext (7.0.4.3)
44
- actionpack (= 7.0.4.3)
45
- activerecord (= 7.0.4.3)
46
- activestorage (= 7.0.4.3)
47
- activesupport (= 7.0.4.3)
43
+ actiontext (7.0.8)
44
+ actionpack (= 7.0.8)
45
+ activerecord (= 7.0.8)
46
+ activestorage (= 7.0.8)
47
+ activesupport (= 7.0.8)
48
48
  globalid (>= 0.6.0)
49
49
  nokogiri (>= 1.8.5)
50
- actionview (7.0.4.3)
51
- activesupport (= 7.0.4.3)
50
+ actionview (7.0.8)
51
+ activesupport (= 7.0.8)
52
52
  builder (~> 3.1)
53
53
  erubi (~> 1.4)
54
54
  rails-dom-testing (~> 2.0)
55
55
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
56
- activejob (7.0.4.3)
57
- activesupport (= 7.0.4.3)
56
+ activejob (7.0.8)
57
+ activesupport (= 7.0.8)
58
58
  globalid (>= 0.3.6)
59
- activemodel (7.0.4.3)
60
- activesupport (= 7.0.4.3)
61
- activerecord (7.0.4.3)
62
- activemodel (= 7.0.4.3)
63
- activesupport (= 7.0.4.3)
64
- activestorage (7.0.4.3)
65
- actionpack (= 7.0.4.3)
66
- activejob (= 7.0.4.3)
67
- activerecord (= 7.0.4.3)
68
- activesupport (= 7.0.4.3)
59
+ activemodel (7.0.8)
60
+ activesupport (= 7.0.8)
61
+ activerecord (7.0.8)
62
+ activemodel (= 7.0.8)
63
+ activesupport (= 7.0.8)
64
+ activestorage (7.0.8)
65
+ actionpack (= 7.0.8)
66
+ activejob (= 7.0.8)
67
+ activerecord (= 7.0.8)
68
+ activesupport (= 7.0.8)
69
69
  marcel (~> 1.0)
70
70
  mini_mime (>= 1.1.0)
71
- activesupport (7.0.4.3)
71
+ activesupport (7.0.8)
72
72
  concurrent-ruby (~> 1.0, >= 1.0.2)
73
73
  i18n (>= 1.6, < 2)
74
74
  minitest (>= 5.1)
75
75
  tzinfo (~> 2.0)
76
76
  ast (2.4.2)
77
+ base64 (0.1.1)
77
78
  builder (3.2.4)
78
79
  concurrent-ruby (1.2.2)
79
80
  crass (1.0.6)
80
81
  date (3.3.3)
81
82
  erubi (1.12.0)
82
- globalid (1.1.0)
83
- activesupport (>= 5.0)
84
- i18n (1.13.0)
83
+ globalid (1.2.1)
84
+ activesupport (>= 6.1)
85
+ i18n (1.14.1)
85
86
  concurrent-ruby (~> 1.0)
86
87
  jbuilder (2.11.5)
87
88
  actionview (>= 5.0.0)
88
89
  activesupport (>= 5.0.0)
89
90
  json (2.6.3)
90
91
  language_server-protocol (3.17.0.3)
91
- lint_roller (1.0.0)
92
- loofah (2.20.0)
92
+ lint_roller (1.1.0)
93
+ loofah (2.21.3)
93
94
  crass (~> 1.0.2)
94
- nokogiri (>= 1.5.9)
95
+ nokogiri (>= 1.12.0)
95
96
  mail (2.8.1)
96
97
  mini_mime (>= 0.1.1)
97
98
  net-imap
@@ -99,100 +100,106 @@ GEM
99
100
  net-smtp
100
101
  marcel (1.0.2)
101
102
  method_source (1.0.0)
102
- mini_mime (1.1.2)
103
- mini_portile2 (2.8.2)
104
- minitest (5.18.0)
105
- mocha (2.0.2)
103
+ mini_mime (1.1.5)
104
+ mini_portile2 (2.8.4)
105
+ minitest (5.20.0)
106
+ mocha (2.1.0)
106
107
  ruby2_keywords (>= 0.0.5)
107
- net-imap (0.3.4)
108
+ net-imap (0.3.7)
108
109
  date
109
110
  net-protocol
110
111
  net-pop (0.1.2)
111
112
  net-protocol
112
113
  net-protocol (0.2.1)
113
114
  timeout
114
- net-smtp (0.3.3)
115
+ net-smtp (0.4.0)
115
116
  net-protocol
116
117
  nio4r (2.5.9)
117
- nokogiri (1.14.3)
118
- mini_portile2 (~> 2.8.0)
118
+ nokogiri (1.15.4)
119
+ mini_portile2 (~> 2.8.2)
119
120
  racc (~> 1.4)
120
121
  parallel (1.23.0)
121
- parser (3.2.2.1)
122
+ parser (3.2.2.3)
122
123
  ast (~> 2.4.1)
123
- racc (1.6.2)
124
- rack (2.2.7)
124
+ racc
125
+ racc (1.7.1)
126
+ rack (2.2.8)
125
127
  rack-test (2.1.0)
126
128
  rack (>= 1.3)
127
- rails (7.0.4.3)
128
- actioncable (= 7.0.4.3)
129
- actionmailbox (= 7.0.4.3)
130
- actionmailer (= 7.0.4.3)
131
- actionpack (= 7.0.4.3)
132
- actiontext (= 7.0.4.3)
133
- actionview (= 7.0.4.3)
134
- activejob (= 7.0.4.3)
135
- activemodel (= 7.0.4.3)
136
- activerecord (= 7.0.4.3)
137
- activestorage (= 7.0.4.3)
138
- activesupport (= 7.0.4.3)
129
+ rails (7.0.8)
130
+ actioncable (= 7.0.8)
131
+ actionmailbox (= 7.0.8)
132
+ actionmailer (= 7.0.8)
133
+ actionpack (= 7.0.8)
134
+ actiontext (= 7.0.8)
135
+ actionview (= 7.0.8)
136
+ activejob (= 7.0.8)
137
+ activemodel (= 7.0.8)
138
+ activerecord (= 7.0.8)
139
+ activestorage (= 7.0.8)
140
+ activesupport (= 7.0.8)
139
141
  bundler (>= 1.15.0)
140
- railties (= 7.0.4.3)
141
- rails-dom-testing (2.0.3)
142
- activesupport (>= 4.2.0)
142
+ railties (= 7.0.8)
143
+ rails-dom-testing (2.2.0)
144
+ activesupport (>= 5.0.0)
145
+ minitest
143
146
  nokogiri (>= 1.6)
144
- rails-html-sanitizer (1.5.0)
145
- loofah (~> 2.19, >= 2.19.1)
146
- railties (7.0.4.3)
147
- actionpack (= 7.0.4.3)
148
- activesupport (= 7.0.4.3)
147
+ rails-html-sanitizer (1.6.0)
148
+ loofah (~> 2.21)
149
+ nokogiri (~> 1.14)
150
+ railties (7.0.8)
151
+ actionpack (= 7.0.8)
152
+ activesupport (= 7.0.8)
149
153
  method_source
150
154
  rake (>= 12.2)
151
155
  thor (~> 1.0)
152
156
  zeitwerk (~> 2.5)
153
157
  rainbow (3.1.1)
154
158
  rake (13.0.6)
155
- regexp_parser (2.8.0)
156
- rexml (3.2.5)
157
- rubocop (1.50.2)
159
+ regexp_parser (2.8.1)
160
+ rexml (3.2.6)
161
+ rubocop (1.56.3)
162
+ base64 (~> 0.1.1)
158
163
  json (~> 2.3)
164
+ language_server-protocol (>= 3.17.0)
159
165
  parallel (~> 1.10)
160
- parser (>= 3.2.0.0)
166
+ parser (>= 3.2.2.3)
161
167
  rainbow (>= 2.2.2, < 4.0)
162
168
  regexp_parser (>= 1.8, < 3.0)
163
169
  rexml (>= 3.2.5, < 4.0)
164
- rubocop-ast (>= 1.28.0, < 2.0)
170
+ rubocop-ast (>= 1.28.1, < 2.0)
165
171
  ruby-progressbar (~> 1.7)
166
172
  unicode-display_width (>= 2.4.0, < 3.0)
167
- rubocop-ast (1.28.1)
173
+ rubocop-ast (1.29.0)
168
174
  parser (>= 3.2.1.0)
169
- rubocop-performance (1.16.0)
175
+ rubocop-performance (1.19.1)
170
176
  rubocop (>= 1.7.0, < 2.0)
171
177
  rubocop-ast (>= 0.4.0)
172
178
  ruby-progressbar (1.13.0)
173
179
  ruby2_keywords (0.0.5)
174
- sqlite3 (1.6.2)
180
+ sqlite3 (1.6.6)
175
181
  mini_portile2 (~> 2.8.0)
176
- standard (1.28.2)
182
+ standard (1.31.1)
177
183
  language_server-protocol (~> 3.17.0.2)
178
184
  lint_roller (~> 1.0)
179
- rubocop (~> 1.50.2)
185
+ rubocop (~> 1.56.2)
180
186
  standard-custom (~> 1.0.0)
181
- standard-performance (~> 1.0.1)
182
- standard-custom (1.0.0)
183
- lint_roller (~> 1.0)
184
- standard-performance (1.0.1)
187
+ standard-performance (~> 1.2)
188
+ standard-custom (1.0.2)
185
189
  lint_roller (~> 1.0)
186
- rubocop-performance (~> 1.16.0)
187
- thor (1.2.1)
188
- timeout (0.3.2)
190
+ rubocop (~> 1.50)
191
+ standard-performance (1.2.0)
192
+ lint_roller (~> 1.1)
193
+ rubocop-performance (~> 1.19.0)
194
+ thor (1.2.2)
195
+ timeout (0.4.0)
189
196
  tzinfo (2.0.6)
190
197
  concurrent-ruby (~> 1.0)
191
198
  unicode-display_width (2.4.2)
192
- websocket-driver (0.7.5)
199
+ websocket-driver (0.7.6)
193
200
  websocket-extensions (>= 0.1.0)
194
201
  websocket-extensions (0.1.5)
195
- zeitwerk (2.6.8)
202
+ zeitwerk (2.6.11)
196
203
 
197
204
  PLATFORMS
198
205
  ruby
@@ -59,7 +59,12 @@ class Jbuilder::Schema
59
59
  end
60
60
 
61
61
  def schema!
62
- if ([@attributes] + @attributes.each_value.grep(::Hash)).any? { _1[:type] == :array && _1.key?(:items) }
62
+ # TODO: Not sure why it was like that, when it was meant to be used,
63
+ # but that seems to fix the problem with disappearance of root properties
64
+ # https://github.com/bullet-train-co/jbuilder-schema/issues/46
65
+ # if ([@attributes] + @attributes.each_value.grep(::Hash)).any? { _1[:type] == :array && _1.key?(:items) }
66
+
67
+ if [@attributes, *@attributes.first].select { |a| a.is_a?(::Hash) && a[:type] == :array && a.key?(:items) }.any?
63
68
  @attributes
64
69
  else
65
70
  _object(@attributes, _required!(@attributes.keys))
@@ -75,6 +80,8 @@ class Jbuilder::Schema
75
80
  # Detect `json.articles user.articles` to override Jbuilder's logic, which wouldn't hit `array!` and set a `type: :array, items: {"$ref": "#/components/schemas/article"}` ref.
76
81
  if block.nil? && keys.blank? && _is_collection?(value) && (value.empty? || value.all? { _is_active_model?(_1) })
77
82
  _set_value(key, _scope { _set_ref(key.to_s.singularize, array: true) })
83
+ elsif _partial_options?(options)
84
+ _set_value(key, _scope { _set_ref(options[:as].to_s, array: _is_collection?(value)) })
78
85
  else
79
86
  super(key, value, *keys, **options, &block)
80
87
  end
@@ -82,6 +89,7 @@ class Jbuilder::Schema
82
89
  ensure
83
90
  @configuration = old_configuration if old_configuration
84
91
  end
92
+
85
93
  alias_method :method_missing, :set! # TODO: Remove once Jbuilder passes keyword arguments along to `set!` in its `method_missing`.
86
94
 
87
95
  def array!(collection = [], *args, schema: nil, **options, &block)
@@ -140,7 +148,10 @@ class Jbuilder::Schema
140
148
  end
141
149
 
142
150
  def _nullify_non_required_types(attributes, required)
143
- attributes.transform_values! { _1[:type] = [_1[:type], "null"] unless required.include?(attributes.key(_1)); _1 }
151
+ attributes.transform_values! {
152
+ _1[:type] = [_1[:type], "null"] unless required.include?(attributes.key(_1))
153
+ _1
154
+ }
144
155
  end
145
156
 
146
157
  def _set_description(key, value)
@@ -1,4 +1,4 @@
1
1
  # We can't use the standard `Jbuilder::Schema::VERSION =` because
2
2
  # `Jbuilder` isn't a regular module namespace, but a class …which also loads Active Support.
3
3
  # So we use trickery, and assign the proper version once `jbuilder/schema.rb` is loaded.
4
- JBUILDER_SCHEMA_VERSION = "2.2.0"
4
+ JBUILDER_SCHEMA_VERSION = "2.3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbuilder-schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Sidorov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-05 00:00:00.000000000 Z
11
+ date: 2023-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jbuilder