rest-api-generator 0.2.0 → 0.4.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 +4 -4
- data/Gemfile.lock +222 -178
- data/README.md +10 -335
- data/app/controllers/rest_api_generator/child_resource_controller.rb +14 -3
- data/app/controllers/rest_api_generator/resource_controller.rb +11 -2
- data/lib/generators/rest_api_generator/resource_generator.rb +2 -4
- data/lib/rest_api_generator/controller_callbacks.rb +37 -0
- data/lib/rest_api_generator/filterable.rb +1 -1
- data/lib/rest_api_generator/version.rb +1 -1
- data/lib/rest_api_generator.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bb2c1297296ab8fb5b53e9eaa49a1569c56a564e60058f206118d9baa2423935
|
|
4
|
+
data.tar.gz: d6b146e4fdca8a433c2244a2baf73ef66b3f4e4c579fe497a0eef04766b4e194
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c4cdc211df26b7d4aad4e6cc1aa61d9d3cec342b3482d0bb088ffb78a006eb1b7a262b7b2ef51afb3812cbef41b6b04e335dd103ce9be511773fcf603c729fe
|
|
7
|
+
data.tar.gz: b1e5c67523466113cfb88f99c842c4b26b0e9700016b8d683e53f27ce0f8f4ad24b811f3b0c1b0b2e52fc211c4c5d7f7aff85a7612640efcc2446b52ea0e1658
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rest-api-generator (0.
|
|
4
|
+
rest-api-generator (0.3.0)
|
|
5
5
|
anyway_config (>= 2.0.0)
|
|
6
6
|
pagy
|
|
7
7
|
rails (>= 5.0)
|
|
@@ -9,108 +9,123 @@ PATH
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
actioncable (7.0
|
|
13
|
-
actionpack (= 7.0
|
|
14
|
-
activesupport (= 7.0
|
|
12
|
+
actioncable (7.2.0)
|
|
13
|
+
actionpack (= 7.2.0)
|
|
14
|
+
activesupport (= 7.2.0)
|
|
15
15
|
nio4r (~> 2.0)
|
|
16
16
|
websocket-driver (>= 0.6.1)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
activesupport (= 7.0.4.3)
|
|
40
|
-
rack (~> 2.0, >= 2.2.0)
|
|
17
|
+
zeitwerk (~> 2.6)
|
|
18
|
+
actionmailbox (7.2.0)
|
|
19
|
+
actionpack (= 7.2.0)
|
|
20
|
+
activejob (= 7.2.0)
|
|
21
|
+
activerecord (= 7.2.0)
|
|
22
|
+
activestorage (= 7.2.0)
|
|
23
|
+
activesupport (= 7.2.0)
|
|
24
|
+
mail (>= 2.8.0)
|
|
25
|
+
actionmailer (7.2.0)
|
|
26
|
+
actionpack (= 7.2.0)
|
|
27
|
+
actionview (= 7.2.0)
|
|
28
|
+
activejob (= 7.2.0)
|
|
29
|
+
activesupport (= 7.2.0)
|
|
30
|
+
mail (>= 2.8.0)
|
|
31
|
+
rails-dom-testing (~> 2.2)
|
|
32
|
+
actionpack (7.2.0)
|
|
33
|
+
actionview (= 7.2.0)
|
|
34
|
+
activesupport (= 7.2.0)
|
|
35
|
+
nokogiri (>= 1.8.5)
|
|
36
|
+
racc
|
|
37
|
+
rack (>= 2.2.4, < 3.2)
|
|
38
|
+
rack-session (>= 1.0.1)
|
|
41
39
|
rack-test (>= 0.6.3)
|
|
42
|
-
rails-dom-testing (~> 2.
|
|
43
|
-
rails-html-sanitizer (~> 1.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
rails-dom-testing (~> 2.2)
|
|
41
|
+
rails-html-sanitizer (~> 1.6)
|
|
42
|
+
useragent (~> 0.16)
|
|
43
|
+
actiontext (7.2.0)
|
|
44
|
+
actionpack (= 7.2.0)
|
|
45
|
+
activerecord (= 7.2.0)
|
|
46
|
+
activestorage (= 7.2.0)
|
|
47
|
+
activesupport (= 7.2.0)
|
|
49
48
|
globalid (>= 0.6.0)
|
|
50
49
|
nokogiri (>= 1.8.5)
|
|
51
|
-
actionview (7.0
|
|
52
|
-
activesupport (= 7.0
|
|
50
|
+
actionview (7.2.0)
|
|
51
|
+
activesupport (= 7.2.0)
|
|
53
52
|
builder (~> 3.1)
|
|
54
|
-
erubi (~> 1.
|
|
55
|
-
rails-dom-testing (~> 2.
|
|
56
|
-
rails-html-sanitizer (~> 1.
|
|
57
|
-
active_model_serializers (0.10.
|
|
58
|
-
actionpack (>= 4.1
|
|
59
|
-
activemodel (>= 4.1
|
|
53
|
+
erubi (~> 1.11)
|
|
54
|
+
rails-dom-testing (~> 2.2)
|
|
55
|
+
rails-html-sanitizer (~> 1.6)
|
|
56
|
+
active_model_serializers (0.10.14)
|
|
57
|
+
actionpack (>= 4.1)
|
|
58
|
+
activemodel (>= 4.1)
|
|
60
59
|
case_transform (>= 0.2)
|
|
61
60
|
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
|
62
|
-
activejob (7.0
|
|
63
|
-
activesupport (= 7.0
|
|
61
|
+
activejob (7.2.0)
|
|
62
|
+
activesupport (= 7.2.0)
|
|
64
63
|
globalid (>= 0.3.6)
|
|
65
|
-
activemodel (7.0
|
|
66
|
-
activesupport (= 7.0
|
|
67
|
-
activerecord (7.0
|
|
68
|
-
activemodel (= 7.0
|
|
69
|
-
activesupport (= 7.0
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
activemodel (7.2.0)
|
|
65
|
+
activesupport (= 7.2.0)
|
|
66
|
+
activerecord (7.2.0)
|
|
67
|
+
activemodel (= 7.2.0)
|
|
68
|
+
activesupport (= 7.2.0)
|
|
69
|
+
timeout (>= 0.4.0)
|
|
70
|
+
activestorage (7.2.0)
|
|
71
|
+
actionpack (= 7.2.0)
|
|
72
|
+
activejob (= 7.2.0)
|
|
73
|
+
activerecord (= 7.2.0)
|
|
74
|
+
activesupport (= 7.2.0)
|
|
75
75
|
marcel (~> 1.0)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
activesupport (7.2.0)
|
|
77
|
+
base64
|
|
78
|
+
bigdecimal
|
|
79
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
80
|
+
connection_pool (>= 2.2.5)
|
|
81
|
+
drb
|
|
79
82
|
i18n (>= 1.6, < 2)
|
|
83
|
+
logger (>= 1.4.2)
|
|
80
84
|
minitest (>= 5.1)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
securerandom (>= 0.3)
|
|
86
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
87
|
+
addressable (2.8.7)
|
|
88
|
+
public_suffix (>= 2.0.2, < 7.0)
|
|
89
|
+
ammeter (1.1.7)
|
|
85
90
|
activesupport (>= 3.0)
|
|
86
91
|
railties (>= 3.0)
|
|
87
92
|
rspec-rails (>= 2.2)
|
|
88
|
-
anyway_config (2.4
|
|
89
|
-
ruby-next-core (
|
|
93
|
+
anyway_config (2.6.4)
|
|
94
|
+
ruby-next-core (~> 1.0)
|
|
90
95
|
ast (2.4.2)
|
|
91
|
-
|
|
96
|
+
base64 (0.2.0)
|
|
97
|
+
bigdecimal (3.1.8)
|
|
98
|
+
builder (3.3.0)
|
|
92
99
|
case_transform (0.2)
|
|
93
100
|
activesupport
|
|
94
|
-
concurrent-ruby (1.
|
|
101
|
+
concurrent-ruby (1.3.4)
|
|
102
|
+
connection_pool (2.4.1)
|
|
95
103
|
crass (1.0.6)
|
|
96
104
|
database_cleaner (2.0.2)
|
|
97
105
|
database_cleaner-active_record (>= 2, < 3)
|
|
98
|
-
database_cleaner-active_record (2.
|
|
106
|
+
database_cleaner-active_record (2.2.0)
|
|
99
107
|
activerecord (>= 5.a)
|
|
100
108
|
database_cleaner-core (~> 2.0.0)
|
|
101
109
|
database_cleaner-core (2.0.1)
|
|
102
|
-
date (3.3.
|
|
103
|
-
diff-lcs (1.5.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
date (3.3.4)
|
|
111
|
+
diff-lcs (1.5.1)
|
|
112
|
+
drb (2.2.1)
|
|
113
|
+
erubi (1.13.0)
|
|
114
|
+
globalid (1.2.1)
|
|
115
|
+
activesupport (>= 6.1)
|
|
116
|
+
i18n (1.14.5)
|
|
108
117
|
concurrent-ruby (~> 1.0)
|
|
109
|
-
|
|
110
|
-
|
|
118
|
+
io-console (0.7.2)
|
|
119
|
+
irb (1.14.0)
|
|
120
|
+
rdoc (>= 4.0.0)
|
|
121
|
+
reline (>= 0.4.2)
|
|
122
|
+
json (2.7.2)
|
|
123
|
+
json-schema (4.3.1)
|
|
111
124
|
addressable (>= 2.8)
|
|
112
125
|
jsonapi-renderer (0.2.2)
|
|
113
|
-
|
|
126
|
+
language_server-protocol (3.17.0.3)
|
|
127
|
+
logger (1.6.0)
|
|
128
|
+
loofah (2.22.0)
|
|
114
129
|
crass (~> 1.0.2)
|
|
115
130
|
nokogiri (>= 1.12.0)
|
|
116
131
|
mail (2.8.1)
|
|
@@ -118,82 +133,100 @@ GEM
|
|
|
118
133
|
net-imap
|
|
119
134
|
net-pop
|
|
120
135
|
net-smtp
|
|
121
|
-
marcel (1.0.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
net-imap (0.3.4)
|
|
136
|
+
marcel (1.0.4)
|
|
137
|
+
mini_mime (1.1.5)
|
|
138
|
+
mini_portile2 (2.8.7)
|
|
139
|
+
minitest (5.25.0)
|
|
140
|
+
net-imap (0.4.14)
|
|
127
141
|
date
|
|
128
142
|
net-protocol
|
|
129
143
|
net-pop (0.1.2)
|
|
130
144
|
net-protocol
|
|
131
|
-
net-protocol (0.2.
|
|
145
|
+
net-protocol (0.2.2)
|
|
132
146
|
timeout
|
|
133
|
-
net-smtp (0.
|
|
147
|
+
net-smtp (0.5.0)
|
|
134
148
|
net-protocol
|
|
135
|
-
nio4r (2.
|
|
136
|
-
nokogiri (1.
|
|
137
|
-
mini_portile2 (~> 2.8.
|
|
149
|
+
nio4r (2.7.3)
|
|
150
|
+
nokogiri (1.16.7)
|
|
151
|
+
mini_portile2 (~> 2.8.2)
|
|
138
152
|
racc (~> 1.4)
|
|
139
|
-
nokogiri (1.
|
|
153
|
+
nokogiri (1.16.7-x86_64-linux)
|
|
140
154
|
racc (~> 1.4)
|
|
141
|
-
oj (3.
|
|
142
|
-
|
|
143
|
-
|
|
155
|
+
oj (3.16.5)
|
|
156
|
+
bigdecimal (>= 3.0)
|
|
157
|
+
ostruct (>= 0.2)
|
|
158
|
+
ostruct (0.6.0)
|
|
159
|
+
pagy (9.0.5)
|
|
160
|
+
panko_serializer (0.8.2)
|
|
144
161
|
activesupport
|
|
145
162
|
oj (> 3.11.0, < 4.0.0)
|
|
146
|
-
parallel (1.
|
|
147
|
-
parser (3.
|
|
163
|
+
parallel (1.26.2)
|
|
164
|
+
parser (3.3.4.2)
|
|
148
165
|
ast (~> 2.4.1)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
166
|
+
racc
|
|
167
|
+
psych (5.1.2)
|
|
168
|
+
stringio
|
|
169
|
+
public_suffix (6.0.1)
|
|
170
|
+
racc (1.8.1)
|
|
171
|
+
rack (3.1.7)
|
|
172
|
+
rack-session (2.0.0)
|
|
173
|
+
rack (>= 3.0.0)
|
|
152
174
|
rack-test (2.1.0)
|
|
153
175
|
rack (>= 1.3)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
176
|
+
rackup (2.1.0)
|
|
177
|
+
rack (>= 3)
|
|
178
|
+
webrick (~> 1.8)
|
|
179
|
+
rails (7.2.0)
|
|
180
|
+
actioncable (= 7.2.0)
|
|
181
|
+
actionmailbox (= 7.2.0)
|
|
182
|
+
actionmailer (= 7.2.0)
|
|
183
|
+
actionpack (= 7.2.0)
|
|
184
|
+
actiontext (= 7.2.0)
|
|
185
|
+
actionview (= 7.2.0)
|
|
186
|
+
activejob (= 7.2.0)
|
|
187
|
+
activemodel (= 7.2.0)
|
|
188
|
+
activerecord (= 7.2.0)
|
|
189
|
+
activestorage (= 7.2.0)
|
|
190
|
+
activesupport (= 7.2.0)
|
|
166
191
|
bundler (>= 1.15.0)
|
|
167
|
-
railties (= 7.0
|
|
168
|
-
rails-dom-testing (2.0
|
|
169
|
-
activesupport (>=
|
|
192
|
+
railties (= 7.2.0)
|
|
193
|
+
rails-dom-testing (2.2.0)
|
|
194
|
+
activesupport (>= 5.0.0)
|
|
195
|
+
minitest
|
|
170
196
|
nokogiri (>= 1.6)
|
|
171
|
-
rails-html-sanitizer (1.
|
|
172
|
-
loofah (~> 2.
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
197
|
+
rails-html-sanitizer (1.6.0)
|
|
198
|
+
loofah (~> 2.21)
|
|
199
|
+
nokogiri (~> 1.14)
|
|
200
|
+
railties (7.2.0)
|
|
201
|
+
actionpack (= 7.2.0)
|
|
202
|
+
activesupport (= 7.2.0)
|
|
203
|
+
irb (~> 1.13)
|
|
204
|
+
rackup (>= 1.0.0)
|
|
177
205
|
rake (>= 12.2)
|
|
178
|
-
thor (~> 1.0)
|
|
179
|
-
zeitwerk (~> 2.
|
|
206
|
+
thor (~> 1.0, >= 1.2.2)
|
|
207
|
+
zeitwerk (~> 2.6)
|
|
180
208
|
rainbow (3.1.1)
|
|
181
|
-
rake (13.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
209
|
+
rake (13.2.1)
|
|
210
|
+
rdoc (6.7.0)
|
|
211
|
+
psych (>= 4.0.0)
|
|
212
|
+
regexp_parser (2.9.2)
|
|
213
|
+
reline (0.5.9)
|
|
214
|
+
io-console (~> 0.5)
|
|
215
|
+
rexml (3.3.5)
|
|
216
|
+
strscan
|
|
217
|
+
rspec (3.13.0)
|
|
218
|
+
rspec-core (~> 3.13.0)
|
|
219
|
+
rspec-expectations (~> 3.13.0)
|
|
220
|
+
rspec-mocks (~> 3.13.0)
|
|
221
|
+
rspec-core (3.13.0)
|
|
222
|
+
rspec-support (~> 3.13.0)
|
|
223
|
+
rspec-expectations (3.13.1)
|
|
191
224
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
192
|
-
rspec-support (~> 3.
|
|
193
|
-
rspec-mocks (3.
|
|
225
|
+
rspec-support (~> 3.13.0)
|
|
226
|
+
rspec-mocks (3.13.1)
|
|
194
227
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
195
|
-
rspec-support (~> 3.
|
|
196
|
-
rspec-rails (6.0.
|
|
228
|
+
rspec-support (~> 3.13.0)
|
|
229
|
+
rspec-rails (6.0.4)
|
|
197
230
|
actionpack (>= 6.1)
|
|
198
231
|
activesupport (>= 6.1)
|
|
199
232
|
railties (>= 6.1)
|
|
@@ -201,70 +234,81 @@ GEM
|
|
|
201
234
|
rspec-expectations (~> 3.12)
|
|
202
235
|
rspec-mocks (~> 3.12)
|
|
203
236
|
rspec-support (~> 3.12)
|
|
204
|
-
rspec-support (3.
|
|
205
|
-
rswag (2.
|
|
206
|
-
rswag-api (= 2.
|
|
207
|
-
rswag-specs (= 2.
|
|
208
|
-
rswag-ui (= 2.
|
|
209
|
-
rswag-api (2.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
237
|
+
rspec-support (3.13.1)
|
|
238
|
+
rswag (2.14.0)
|
|
239
|
+
rswag-api (= 2.14.0)
|
|
240
|
+
rswag-specs (= 2.14.0)
|
|
241
|
+
rswag-ui (= 2.14.0)
|
|
242
|
+
rswag-api (2.14.0)
|
|
243
|
+
activesupport (>= 5.2, < 8.0)
|
|
244
|
+
railties (>= 5.2, < 8.0)
|
|
245
|
+
rswag-specs (2.14.0)
|
|
246
|
+
activesupport (>= 5.2, < 8.0)
|
|
247
|
+
json-schema (>= 2.2, < 5.0)
|
|
248
|
+
railties (>= 5.2, < 8.0)
|
|
215
249
|
rspec-core (>= 2.14)
|
|
216
|
-
rswag-ui (2.
|
|
217
|
-
actionpack (>=
|
|
218
|
-
railties (>=
|
|
219
|
-
rubocop (1.
|
|
250
|
+
rswag-ui (2.14.0)
|
|
251
|
+
actionpack (>= 5.2, < 8.0)
|
|
252
|
+
railties (>= 5.2, < 8.0)
|
|
253
|
+
rubocop (1.64.1)
|
|
220
254
|
json (~> 2.3)
|
|
255
|
+
language_server-protocol (>= 3.17.0)
|
|
221
256
|
parallel (~> 1.10)
|
|
222
|
-
parser (>= 3.
|
|
257
|
+
parser (>= 3.3.0.2)
|
|
223
258
|
rainbow (>= 2.2.2, < 4.0)
|
|
224
259
|
regexp_parser (>= 1.8, < 3.0)
|
|
225
260
|
rexml (>= 3.2.5, < 4.0)
|
|
226
|
-
rubocop-ast (>= 1.
|
|
261
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
227
262
|
ruby-progressbar (~> 1.7)
|
|
228
263
|
unicode-display_width (>= 2.4.0, < 3.0)
|
|
229
|
-
rubocop-ast (1.
|
|
230
|
-
parser (>= 3.
|
|
231
|
-
rubocop-capybara (2.
|
|
264
|
+
rubocop-ast (1.32.0)
|
|
265
|
+
parser (>= 3.3.1.0)
|
|
266
|
+
rubocop-capybara (2.21.0)
|
|
232
267
|
rubocop (~> 1.41)
|
|
233
|
-
rubocop-factory_bot (2.
|
|
234
|
-
rubocop (~> 1.
|
|
235
|
-
rubocop-performance (1.
|
|
236
|
-
rubocop (>= 1.
|
|
237
|
-
rubocop-ast (>=
|
|
238
|
-
rubocop-rails (2.
|
|
268
|
+
rubocop-factory_bot (2.26.1)
|
|
269
|
+
rubocop (~> 1.61)
|
|
270
|
+
rubocop-performance (1.21.0)
|
|
271
|
+
rubocop (>= 1.48.1, < 2.0)
|
|
272
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
273
|
+
rubocop-rails (2.25.0)
|
|
239
274
|
activesupport (>= 4.2.0)
|
|
240
275
|
rack (>= 1.1)
|
|
241
276
|
rubocop (>= 1.33.0, < 2.0)
|
|
242
|
-
|
|
243
|
-
|
|
277
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
278
|
+
rubocop-rspec (2.29.2)
|
|
279
|
+
rubocop (~> 1.40)
|
|
244
280
|
rubocop-capybara (~> 2.17)
|
|
245
281
|
rubocop-factory_bot (~> 2.22)
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
282
|
+
rubocop-rspec_rails (~> 2.28)
|
|
283
|
+
rubocop-rspec_rails (2.29.1)
|
|
284
|
+
rubocop (~> 1.61)
|
|
285
|
+
rubocop-shopify (2.15.1)
|
|
286
|
+
rubocop (~> 1.51)
|
|
287
|
+
ruby-next-core (1.0.3)
|
|
249
288
|
ruby-progressbar (1.13.0)
|
|
250
|
-
|
|
289
|
+
securerandom (0.3.1)
|
|
290
|
+
sqlite3 (2.0.4)
|
|
251
291
|
mini_portile2 (~> 2.8.0)
|
|
252
|
-
sqlite3 (
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
rubocop
|
|
257
|
-
rubocop-
|
|
258
|
-
rubocop-
|
|
259
|
-
|
|
260
|
-
|
|
292
|
+
sqlite3 (2.0.4-x86_64-linux-gnu)
|
|
293
|
+
stringio (3.1.1)
|
|
294
|
+
strscan (3.1.0)
|
|
295
|
+
switchcop (0.1.7)
|
|
296
|
+
rubocop (= 1.64.1)
|
|
297
|
+
rubocop-performance (= 1.21.0)
|
|
298
|
+
rubocop-rails (= 2.25.0)
|
|
299
|
+
rubocop-rspec (= 2.29.2)
|
|
300
|
+
rubocop-shopify (= 2.15.1)
|
|
301
|
+
thor (1.3.1)
|
|
302
|
+
timeout (0.4.1)
|
|
261
303
|
tzinfo (2.0.6)
|
|
262
304
|
concurrent-ruby (~> 1.0)
|
|
263
|
-
unicode-display_width (2.
|
|
264
|
-
|
|
305
|
+
unicode-display_width (2.5.0)
|
|
306
|
+
useragent (0.16.10)
|
|
307
|
+
webrick (1.8.1)
|
|
308
|
+
websocket-driver (0.7.6)
|
|
265
309
|
websocket-extensions (>= 0.1.0)
|
|
266
310
|
websocket-extensions (0.1.5)
|
|
267
|
-
zeitwerk (2.6.
|
|
311
|
+
zeitwerk (2.6.17)
|
|
268
312
|
|
|
269
313
|
PLATFORMS
|
|
270
314
|
ruby
|
|
@@ -285,4 +329,4 @@ DEPENDENCIES
|
|
|
285
329
|
switchcop
|
|
286
330
|
|
|
287
331
|
BUNDLED WITH
|
|
288
|
-
2.
|
|
332
|
+
2.4.19
|
data/README.md
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
This gem helps you to build a Ruby on Rails REST API faster, using a scaffold-like generator that follows the best
|
|
4
4
|
practices.
|
|
5
5
|
|
|
6
|
+
## Get started
|
|
7
|
+
|
|
8
|
+
:zap: **Quick Start**: [docs](https://rest-api-generator.switchdreams.com.br/quick-start)\
|
|
9
|
+
:books: **Documentation**: [docs](https://rest-api-generator.switchdreams.com.br/)
|
|
10
|
+
|
|
6
11
|
## How it works?
|
|
7
12
|
|
|
8
13
|
The gems use vanilla Rails generators in combination with our templates to create all the resources needed to build a
|
|
@@ -27,6 +32,7 @@ Following [Switch Dreams's](https://www.switchdreams.com.br/]) coding practices,
|
|
|
27
32
|
- [Resource pagination](#pagination)
|
|
28
33
|
- [Resource serialization](#serialization)
|
|
29
34
|
- [Configurable](#configuration)
|
|
35
|
+
- [Callbacks](#callbacks)
|
|
30
36
|
|
|
31
37
|
## Next Features
|
|
32
38
|
|
|
@@ -34,343 +40,12 @@ Following [Switch Dreams's](https://www.switchdreams.com.br/]) coding practices,
|
|
|
34
40
|
- Select fields
|
|
35
41
|
- User auth module
|
|
36
42
|
|
|
37
|
-
##
|
|
38
|
-
|
|
39
|
-
Add this line to your application's Gemfile:
|
|
40
|
-
|
|
41
|
-
```ruby
|
|
42
|
-
# Build a Ruby on Rails REST API faster
|
|
43
|
-
gem 'rest-api-generator'
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
And then execute:
|
|
47
|
-
|
|
48
|
-
$ bundle install
|
|
49
|
-
|
|
50
|
-
Or install it yourself as:
|
|
51
|
-
|
|
52
|
-
$ gem install rest-api-generator
|
|
53
|
-
|
|
54
|
-
## Requirements
|
|
55
|
-
|
|
56
|
-
1. You need to have installed RSpec and FactoryBot in your application.
|
|
57
|
-
|
|
58
|
-
<ul>
|
|
59
|
-
<li>RSpec: https://github.com/rspec/rspec-rails</li>
|
|
60
|
-
<li>Factory bot: https://github.com/thoughtbot/factory_bot_rails</li>
|
|
61
|
-
</ul>
|
|
62
|
-
|
|
63
|
-
2. Include in ApplicationController the error handler module:
|
|
64
|
-
|
|
65
|
-
```ruby
|
|
66
|
-
|
|
67
|
-
class ApplicationController < ActionController::API
|
|
68
|
-
include RestApiGenerator::ErrorHandler
|
|
69
|
-
end
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
This error handler will rescue from: `ActiveRecord::RecordNotFound`
|
|
73
|
-
, `ActiveRecord::ActiveRecordError`, `ActiveRecord::RecordInvalid`, `ActiveModel::ValidationError`
|
|
74
|
-
, `RestApiGenerator::CustomError`.
|
|
75
|
-
|
|
76
|
-
## Usage
|
|
77
|
-
|
|
78
|
-
### Generate Resource
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
$ rails g rest_api_generator:resource table_name attributes
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
This command will create:
|
|
85
|
-
|
|
86
|
-
- **Model and Migration**: Using rails default model generator
|
|
87
|
-
- **Controller**: A controller that implementes CRUD by inheritance of `RestApiGenerator::ResourceController`, or you
|
|
88
|
-
can use eject option for create a controller
|
|
89
|
-
that implements index, show, create, update and destroy methods.
|
|
90
|
-
- **Specs for the created controller**
|
|
91
|
-
- **Factory bot factory for created model**
|
|
92
|
-
- **Routes**: with rails resources
|
|
93
|
-
|
|
94
|
-
### Example
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
$ rails g rest_api_generator:resource car name:string color:string
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Will generate following controller and the other files:
|
|
101
|
-
|
|
102
|
-
```ruby
|
|
103
|
-
# app/controllers/cars_controller.rb
|
|
104
|
-
class CarsController < RestApiGenerator::ResourceController
|
|
105
|
-
end
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
For a better experience you can override some methods from the
|
|
109
|
-
[default controller](https://github.com/SwitchDreams/rest-api-generator/blob/main/lib/rest_api_generator/resource_controller.rb)
|
|
110
|
-
|
|
111
|
-
### Options
|
|
112
|
-
|
|
113
|
-
| Option | Goal | Default | Usage Example |
|
|
114
|
-
|--------|--------------------------------------------------------------|---------|-----------------|
|
|
115
|
-
| father | Generate nested resource | nil | --father Users |
|
|
116
|
-
| scope | Scope the resource for other route or namespace organization | nil | --scope Api::V1 |
|
|
117
|
-
| eject | Eject the controller to high customization | false | true |
|
|
118
|
-
| spec | Choose the spec format. Current options: "rspec" or "rswag" | rspec | --spec rswag |
|
|
119
|
-
|
|
120
|
-
#### Scope
|
|
121
|
-
|
|
122
|
-
In REST api one of the best practices is versioning the end-points, and you can achieve this using scope options,
|
|
123
|
-
example:
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
# Command
|
|
127
|
-
rails g rest_api_generator:resource car name:string color:string --scope Api::V1
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
```ruby
|
|
131
|
-
# GET api/v1/cars
|
|
132
|
-
module Api::V1
|
|
133
|
-
class CarsController < RestApiGenerator::ResourceController
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
For this option you need to manually setup routes, for this example:
|
|
139
|
-
|
|
140
|
-
```ruby
|
|
141
|
-
# routes.rb
|
|
142
|
-
namespace :api do
|
|
143
|
-
namespace :v1 do
|
|
144
|
-
resources :cars
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
#### Nested resource
|
|
150
|
-
|
|
151
|
-
In REST api sometimes we need to build a nested resource, for example when we need to get all devices from a user, for
|
|
152
|
-
this we have nested resource option:
|
|
153
|
-
|
|
154
|
-
```bash
|
|
155
|
-
# Command
|
|
156
|
-
rails g rest_api_generator:resource Devices name:string color:string users:references --scope Users
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
```ruby
|
|
160
|
-
# GET users/:user_id/devices
|
|
161
|
-
module Users
|
|
162
|
-
class DevicesController < RestApiGenerator::ChildResourceController
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
For this option you need to manually setup routes, for this example:
|
|
168
|
-
|
|
169
|
-
```ruby
|
|
170
|
-
# routes.rb
|
|
171
|
-
resources :users do
|
|
172
|
-
resources :devices, controller: 'users/devices'
|
|
173
|
-
end
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
Considerations:
|
|
177
|
-
|
|
178
|
-
- The children model needs to belongs_to parent model and parent model needs to have has_many children model
|
|
179
|
-
|
|
180
|
-
#### Eject
|
|
181
|
-
|
|
182
|
-
Or you can use the `eject` option for create the controller with the implemented methods:
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
rails g rest_api_generator:resource car name:string color:string --eject true
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
```ruby
|
|
189
|
-
|
|
190
|
-
class CarsController < ApplicationController
|
|
191
|
-
before_action :set_car, only: %i[show update destroy]
|
|
192
|
-
|
|
193
|
-
def index
|
|
194
|
-
@car = Car.all
|
|
195
|
-
render json: @car, status: :ok
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
def show
|
|
199
|
-
render json: @car, status: :ok
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
def create
|
|
203
|
-
@car = Car.create!(car_params)
|
|
204
|
-
render json: @car, status: :created
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
def update
|
|
208
|
-
@car = Car.update!(car_params)
|
|
209
|
-
render json: @car, status: :ok
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
def destroy
|
|
213
|
-
@car.destroy!
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
private
|
|
217
|
-
|
|
218
|
-
def set_car
|
|
219
|
-
@car = Car.find(params[:id])
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
def car_params
|
|
223
|
-
params.require(:car).permit(:name, :color)
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
#### Specs/Docs
|
|
229
|
-
|
|
230
|
-
The default generated spec for this gem is using plain rspec, but you can choose rswag, for scaffold you specs and docs
|
|
231
|
-
at the same time:
|
|
232
|
-
|
|
233
|
-
For this you need to setup https://github.com/rswag/rswag and you the following flag when generating resources.
|
|
234
|
-
|
|
235
|
-
```shell
|
|
236
|
-
rails g rest_api_generator:resource Car name:string color:string --spec rswag
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
This spec options work as generators too, so you can call them individually:
|
|
240
|
-
|
|
241
|
-
```shell
|
|
242
|
-
# rest_api_generator:spec:rswag or rest_api_generator:spec:rspec
|
|
243
|
-
rails g rest_api_generator:spec:rswag Car name:string color:string
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
#### Configuration for specs
|
|
247
|
-
|
|
248
|
-
By default, the plain rspec and rswag specs are going to be generated in the _spec/requests_ and _spec/docs_
|
|
249
|
-
directories, respectively. You can override using the (config options)[#configuration]]. :
|
|
250
|
-
|
|
251
|
-
### Resource Features
|
|
252
|
-
|
|
253
|
-
#### Modular Error Handler
|
|
254
|
-
|
|
255
|
-
The error module will return a json in this following format when any active record or custom error raises.
|
|
256
|
-
|
|
257
|
-
```json
|
|
258
|
-
{
|
|
259
|
-
"status": 422,
|
|
260
|
-
"error": "",
|
|
261
|
-
"message": ""
|
|
262
|
-
}
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
This is good to padronize the error handler in front-end too.
|
|
266
|
-
|
|
267
|
-
#### Ordering
|
|
268
|
-
|
|
269
|
-
For ordering use this format:
|
|
270
|
-
|
|
271
|
-
- Ordering asc: `GET /cars?sort=+name or GET /cars?sort=name`
|
|
272
|
-
- Ordering desc: `GET /card?sort=-name`
|
|
273
|
-
|
|
274
|
-
By default, every resource column can be the key for ordering.
|
|
275
|
-
|
|
276
|
-
#### Filtering
|
|
277
|
-
|
|
278
|
-
For filter is needed to add some scopes in Model file, example:
|
|
279
|
-
|
|
280
|
-
```ruby
|
|
281
|
-
# app/models/car.rb
|
|
282
|
-
|
|
283
|
-
class Car < ApplicationRecord
|
|
284
|
-
include RestApiGenerator::Filterable
|
|
285
|
-
|
|
286
|
-
filter_scope :filter_by_color, ->(color) { where(color: color) }
|
|
287
|
-
filter_scope :filter_by_name, ->(name) { where("name LIKE ?", "%#{name}%") }
|
|
288
|
-
end
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
And It's done, you can filter your index end-point:
|
|
292
|
-
|
|
293
|
-
- `GET /cars?color=blue or GET /cars?color=red&name=Ferrari`
|
|
294
|
-
|
|
295
|
-
### Pagination
|
|
296
|
-
|
|
297
|
-
For pagination, you need to create pagy initialializer file (pagy.rb) in the config directory of your project.
|
|
298
|
-
Follow [pagy's example](https://ddnexus.github.io/pagy/quick-start/) for more information.
|
|
299
|
-
|
|
300
|
-
Next, you should add some lines on top of the previously created pagy file:
|
|
301
|
-
|
|
302
|
-
```ruby
|
|
303
|
-
# config/initializers/pagy.rb
|
|
304
|
-
require "pagy"
|
|
305
|
-
require "pagy/extras/headers"
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
At last, change the pagination variable on RestApiGenerator initializer to true;
|
|
309
|
-
|
|
310
|
-
```rb
|
|
311
|
-
# config/initializers/rest_api_generator.rb
|
|
312
|
-
config.pagination = true # default: false
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
Note, if the parent controller is changed, it is necessary to include Pagy::Backend in the new parent.
|
|
316
|
-
|
|
317
|
-
```rb
|
|
318
|
-
# new_parent_controller.rb
|
|
319
|
-
class NewParentController < ActionController::Base
|
|
320
|
-
include Pagy::Backend
|
|
321
|
-
end
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
### Serialization
|
|
325
|
-
|
|
326
|
-
If you are working with [ams](https://github.com/rails-api/active_model_serializers), the serializer will work without
|
|
327
|
-
any extra configuration.
|
|
328
|
-
But if you need to customize you can override the serializer method in the controller:
|
|
329
|
-
|
|
330
|
-
```ruby
|
|
331
|
-
# Example with panko serializer: https://github.com/panko-serializer/panko_serializer
|
|
332
|
-
class CarsController < RestApiGenerator::ResourceController
|
|
333
|
-
|
|
334
|
-
# serializer used in show, create, update.
|
|
335
|
-
def serializer(resource)
|
|
336
|
-
Panko::CarSerializer.new.serialize_to_json(resource)
|
|
337
|
-
end
|
|
338
|
-
|
|
339
|
-
# serializer used in index.
|
|
340
|
-
def index_serializer(resources)
|
|
341
|
-
Panko::ArraySerializer.new(resources, each_serializer: Panko::CarSerializer).to_json
|
|
342
|
-
end
|
|
343
|
-
end
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
```ruby
|
|
347
|
-
# Example with ams
|
|
348
|
-
class CarsController < RestApiGenerator::ResourceController
|
|
349
|
-
def serializer(resource)
|
|
350
|
-
ActiveModelSerializers::SerializableResource.new(resource, each_serializer: Ams::CarSerializer).to_json
|
|
351
|
-
end
|
|
352
|
-
end
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
The gem is tested with [panko serializer](https://github.com/panko-serializer/panko_serializer)
|
|
356
|
-
and [ams](https://github.com/rails-api/active_model_serializers). But should works with any serializer, feel free to add
|
|
357
|
-
tests for your favorite serializer.
|
|
358
|
-
|
|
359
|
-
## Configuration
|
|
360
|
-
|
|
361
|
-
You can override this gem configuration using the initializer or any other method
|
|
362
|
-
from [anyway_config](https://github.com/palkan/anyway_config):
|
|
43
|
+
## Other alternatives
|
|
363
44
|
|
|
364
|
-
|
|
365
|
-
# config/initializers/rest_api_generator.rb
|
|
45
|
+
This gem resolves a very common problem so the are a lot of alternative in the market.
|
|
366
46
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
config.docs_path = "custom_docs_dir/rswag" # default: spec/docs
|
|
370
|
-
config.parent_class = "ApplicationController" # default: RestApiGenerator::ResourceController
|
|
371
|
-
config.pagination = true # default: false
|
|
372
|
-
end
|
|
373
|
-
```
|
|
47
|
+
- [decent_exposure](https://github.com/hashrocket/decent_exposure)
|
|
48
|
+
- [resourcerer](https://github.com/ElMassimo/resourcerer)
|
|
374
49
|
|
|
375
50
|
## Development
|
|
376
51
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module RestApiGenerator
|
|
4
4
|
class ChildResourceController < RestApiGenerator.configuration.parent_controller.constantize
|
|
5
|
+
include ControllerCallbacks
|
|
5
6
|
include Orderable
|
|
6
7
|
include Serializable
|
|
7
8
|
|
|
@@ -9,7 +10,7 @@ module RestApiGenerator
|
|
|
9
10
|
before_action :set_resource, only: [:show, :update, :destroy]
|
|
10
11
|
|
|
11
12
|
def index
|
|
12
|
-
|
|
13
|
+
set_all_resources
|
|
13
14
|
@resources = @resources.filter_resource(params_for_filter) if resource_class.include?(Filterable)
|
|
14
15
|
@resources = @resources.order(ordering_params(params[:sort])) if params[:sort]
|
|
15
16
|
if pagination
|
|
@@ -39,6 +40,12 @@ module RestApiGenerator
|
|
|
39
40
|
|
|
40
41
|
private
|
|
41
42
|
|
|
43
|
+
def set_all_resources
|
|
44
|
+
run_callbacks :set_all_resources do
|
|
45
|
+
@resources = resources
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
42
49
|
def resources
|
|
43
50
|
@parent_resource.send(resource_class.to_s.downcase.pluralize)
|
|
44
51
|
end
|
|
@@ -74,11 +81,15 @@ module RestApiGenerator
|
|
|
74
81
|
|
|
75
82
|
# Before actions
|
|
76
83
|
def set_parent_resource
|
|
77
|
-
|
|
84
|
+
run_callbacks :set_parent_resource do
|
|
85
|
+
@parent_resource = parent_resource_class.find(parent_record_id)
|
|
86
|
+
end
|
|
78
87
|
end
|
|
79
88
|
|
|
80
89
|
def set_resource
|
|
81
|
-
|
|
90
|
+
run_callbacks :set_resource do
|
|
91
|
+
@resource = resources.find(record_id)
|
|
92
|
+
end
|
|
82
93
|
end
|
|
83
94
|
|
|
84
95
|
# UsersController => User
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
module RestApiGenerator
|
|
4
4
|
class ResourceController < RestApiGenerator.configuration.parent_controller.constantize
|
|
5
|
+
include ControllerCallbacks
|
|
5
6
|
include Orderable
|
|
6
7
|
include Serializable
|
|
7
8
|
|
|
8
9
|
before_action :set_resource, only: [:show, :update, :destroy]
|
|
9
10
|
|
|
10
11
|
def index
|
|
11
|
-
|
|
12
|
+
set_all_resources
|
|
12
13
|
@resources = @resources.filter_resource(params_for_filter) if resource_class.include?(Filterable)
|
|
13
14
|
@resources = @resources.order(ordering_params(params[:sort])) if params[:sort]
|
|
14
15
|
if pagination
|
|
@@ -63,7 +64,15 @@ module RestApiGenerator
|
|
|
63
64
|
end
|
|
64
65
|
|
|
65
66
|
def set_resource
|
|
66
|
-
|
|
67
|
+
run_callbacks :set_resource do
|
|
68
|
+
@resource = resource_class.find(record_id)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def set_all_resources
|
|
73
|
+
run_callbacks :set_all_resources do
|
|
74
|
+
@resources = resource_class.all
|
|
75
|
+
end
|
|
67
76
|
end
|
|
68
77
|
|
|
69
78
|
# UsersController => User
|
|
@@ -51,11 +51,9 @@ module RestApiGenerator
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def build_model_attributes
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
model_attributes << "#{attribute.name}:#{attribute.type}"
|
|
54
|
+
attributes.map do |attribute|
|
|
55
|
+
"#{attribute.name}:#{attribute.type}"
|
|
57
56
|
end
|
|
58
|
-
model_attributes
|
|
59
57
|
end
|
|
60
58
|
end
|
|
61
59
|
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RestApiGenerator
|
|
4
|
+
module ControllerCallbacks
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
include ActiveSupport::Callbacks
|
|
7
|
+
|
|
8
|
+
included do
|
|
9
|
+
define_callbacks :set_resource
|
|
10
|
+
define_callbacks :set_parent_resource
|
|
11
|
+
define_callbacks :set_all_resources
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module ClassMethods
|
|
15
|
+
# Code from rails source code
|
|
16
|
+
[:before, :after, :around].each do |callback|
|
|
17
|
+
define_method :"#{callback}_set_resource" do |*names, &blk|
|
|
18
|
+
_insert_callbacks(names, blk) do |name, options|
|
|
19
|
+
set_callback(:set_resource, callback, name, options)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
define_method :"#{callback}_set_parent_resource" do |*names, &blk|
|
|
24
|
+
_insert_callbacks(names, blk) do |name, options|
|
|
25
|
+
set_callback(:set_parent_resource, callback, name, options)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
define_method :"#{callback}_set_all_resources" do |*names, &blk|
|
|
30
|
+
_insert_callbacks(names, blk) do |name, options|
|
|
31
|
+
set_callback(:set_all_resources, callback, name, options)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -21,7 +21,7 @@ module RestApiGenerator
|
|
|
21
21
|
def filter_resource(params)
|
|
22
22
|
results = where(nil)
|
|
23
23
|
params.each do |key, value|
|
|
24
|
-
results = results.public_send("filter_by_#{key}", value) if value.present?
|
|
24
|
+
results = results.public_send(:"filter_by_#{key}", value) if value.present?
|
|
25
25
|
end
|
|
26
26
|
results
|
|
27
27
|
end
|
data/lib/rest_api_generator.rb
CHANGED
|
@@ -9,6 +9,7 @@ require_relative "rest_api_generator/helpers/render"
|
|
|
9
9
|
require_relative "rest_api_generator/filterable"
|
|
10
10
|
require_relative "rest_api_generator/orderable"
|
|
11
11
|
require_relative "rest_api_generator/serializable"
|
|
12
|
+
require_relative "rest_api_generator/controller_callbacks"
|
|
12
13
|
|
|
13
14
|
module RestApiGenerator
|
|
14
15
|
class Error < StandardError; end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rest-api-generator
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- PedroAugustoRamalhoDuarte
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-10-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: anyway_config
|
|
@@ -155,6 +155,7 @@ files:
|
|
|
155
155
|
- lib/rest-api-generator.rb
|
|
156
156
|
- lib/rest_api_generator.rb
|
|
157
157
|
- lib/rest_api_generator/config.rb
|
|
158
|
+
- lib/rest_api_generator/controller_callbacks.rb
|
|
158
159
|
- lib/rest_api_generator/custom_error.rb
|
|
159
160
|
- lib/rest_api_generator/error_handler.rb
|
|
160
161
|
- lib/rest_api_generator/filterable.rb
|
|
@@ -190,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
190
191
|
- !ruby/object:Gem::Version
|
|
191
192
|
version: '0'
|
|
192
193
|
requirements: []
|
|
193
|
-
rubygems_version: 3.
|
|
194
|
+
rubygems_version: 3.5.16
|
|
194
195
|
signing_key:
|
|
195
196
|
specification_version: 4
|
|
196
197
|
summary: Build a Ruby on Rails REST API faster
|