apipie-rails 0.3.6 → 0.5.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +23 -7
- data/CHANGELOG.md +147 -2
- data/Gemfile +1 -0
- data/Gemfile.rails41 +2 -0
- data/Gemfile.rails42 +10 -1
- data/Gemfile.rails50 +9 -0
- data/Gemfile.rails51 +9 -0
- data/Gemfile.rails60 +14 -0
- data/PROPOSAL_FOR_RESPONSE_DESCRIPTIONS.md +244 -0
- data/README.rst +570 -17
- data/apipie-rails.gemspec +3 -3
- data/app/controllers/apipie/apipies_controller.rb +48 -17
- data/app/views/apipie/apipies/_method_detail.erb +21 -0
- data/app/views/apipie/apipies/_params.html.erb +4 -2
- data/app/views/apipie/apipies/index.html.erb +5 -1
- data/app/views/apipie/apipies/resource.html.erb +3 -0
- data/app/views/layouts/apipie/apipie.html.erb +1 -1
- data/config/locales/en.yml +1 -0
- data/config/locales/fr.yml +31 -0
- data/config/locales/it.yml +31 -0
- data/config/locales/ja.yml +31 -0
- data/lib/apipie/apipie_module.rb +22 -4
- data/lib/apipie/application.rb +55 -28
- data/lib/apipie/configuration.rb +19 -3
- data/lib/apipie/core_ext/route.rb +9 -0
- data/lib/apipie/dsl_definition.rb +151 -10
- data/lib/apipie/error_description.rb +9 -2
- data/lib/apipie/errors.rb +34 -0
- data/lib/apipie/extractor/collector.rb +4 -0
- data/lib/apipie/extractor/recorder.rb +13 -12
- data/lib/apipie/extractor/writer.rb +83 -55
- data/lib/apipie/extractor.rb +10 -4
- data/lib/apipie/method_description.rb +51 -4
- data/lib/apipie/param_description.rb +56 -2
- data/lib/apipie/resource_description.rb +10 -3
- data/lib/apipie/response_description.rb +131 -0
- data/lib/apipie/response_description_adapter.rb +200 -0
- data/lib/apipie/routes_formatter.rb +1 -1
- data/lib/apipie/rspec/response_validation_helper.rb +194 -0
- data/lib/apipie/static_dispatcher.rb +3 -2
- data/lib/apipie/swagger_generator.rb +708 -0
- data/lib/apipie/tag_list_description.rb +11 -0
- data/lib/apipie/validator.rb +69 -8
- data/lib/apipie/version.rb +1 -1
- data/lib/apipie-rails.rb +7 -0
- data/lib/tasks/apipie.rake +103 -8
- data/spec/controllers/apipies_controller_spec.rb +52 -12
- data/spec/controllers/concerns_controller_spec.rb +2 -2
- data/spec/controllers/extended_controller_spec.rb +14 -0
- data/spec/controllers/memes_controller_spec.rb +10 -0
- data/spec/controllers/users_controller_spec.rb +115 -75
- data/spec/dummy/app/controllers/application_controller.rb +5 -1
- data/spec/dummy/app/controllers/concerns/extending_concern.rb +12 -0
- data/spec/dummy/app/controllers/concerns/sample_controller.rb +5 -5
- data/spec/dummy/app/controllers/extended_controller.rb +14 -0
- data/spec/dummy/app/controllers/pets_controller.rb +408 -0
- data/spec/dummy/app/controllers/pets_using_auto_views_controller.rb +73 -0
- data/spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb +95 -0
- data/spec/dummy/app/controllers/tagged_cats_controller.rb +32 -0
- data/spec/dummy/app/controllers/tagged_dogs_controller.rb +15 -0
- data/spec/dummy/app/controllers/twitter_example_controller.rb +5 -0
- data/spec/dummy/app/controllers/users_controller.rb +19 -11
- data/spec/dummy/components/test_engine/Gemfile +6 -0
- data/spec/dummy/components/test_engine/app/controllers/test_engine/application_controller.rb +4 -0
- data/spec/dummy/components/test_engine/app/controllers/test_engine/memes_controller.rb +37 -0
- data/spec/dummy/components/test_engine/config/routes.rb +3 -0
- data/spec/dummy/components/test_engine/db/.gitkeep +0 -0
- data/spec/dummy/components/test_engine/lib/test_engine.rb +7 -0
- data/spec/dummy/components/test_engine/test_engine.gemspec +11 -0
- data/spec/dummy/config/application.rb +5 -0
- data/spec/dummy/config/environments/development.rb +3 -0
- data/spec/dummy/config/environments/production.rb +3 -0
- data/spec/dummy/config/environments/test.rb +3 -0
- data/spec/dummy/config/initializers/apipie.rb +3 -1
- data/spec/dummy/config/routes.rb +24 -1
- data/spec/lib/extractor/writer_spec.rb +32 -4
- data/spec/lib/file_handler_spec.rb +18 -0
- data/spec/lib/method_description_spec.rb +34 -0
- data/spec/lib/swagger/openapi_2_0_schema.json +1607 -0
- data/spec/lib/swagger/rake_swagger_spec.rb +139 -0
- data/spec/lib/swagger/response_validation_spec.rb +104 -0
- data/spec/lib/swagger/swagger_dsl_spec.rb +658 -0
- data/spec/lib/validator_spec.rb +58 -0
- data/spec/lib/validators/array_validator_spec.rb +28 -8
- data/spec/spec_helper.rb +68 -0
- metadata +75 -23
- data/Gemfile +0 -7
- data/Gemfile.rails32 +0 -6
- data/Gemfile.rails40 +0 -5
- data/lib/apipie/client/generator.rb +0 -135
@@ -66,12 +66,12 @@ describe UsersController do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should reply to valid request" do
|
69
|
-
get :show, :id => '5', :session => "secret_hash"
|
69
|
+
get :show, :params => { :id => '5', :session => "secret_hash" }
|
70
70
|
assert_response :success
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should pass if required parameter is missing" do
|
74
|
-
expect { get :show, :id => 5 }.not_to raise_error
|
74
|
+
expect { get :show, :params => { :id => 5 } }.not_to raise_error
|
75
75
|
end
|
76
76
|
|
77
77
|
end
|
@@ -92,17 +92,17 @@ describe UsersController do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should reply to valid request" do
|
95
|
-
expect { get :show, :id => 5, :session => "secret_hash" }.not_to raise_error
|
95
|
+
expect { get :show, :params => { :id => 5, :session => "secret_hash" }}.not_to raise_error
|
96
96
|
assert_response :success
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should fail if required parameter is missing" do
|
100
|
-
expect { get :show, :id => 5 }.to raise_error(Apipie::ParamMissing, /session_parameter_is_required/)
|
100
|
+
expect { get :show, :params => { :id => 5 }}.to raise_error(Apipie::ParamMissing, /session_parameter_is_required/)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should pass if required parameter has wrong type" do
|
104
|
-
expect { get :show, :id => 5, :session => "secret_hash" }.not_to raise_error
|
105
|
-
expect { get :show, :id => "ten", :session => "secret_hash" }.not_to raise_error
|
104
|
+
expect { get :show, :params => { :id => 5 , :session => "secret_hash" }}.not_to raise_error
|
105
|
+
expect { get :show, :params => { :id => "ten" , :session => "secret_hash" }}.not_to raise_error
|
106
106
|
end
|
107
107
|
|
108
108
|
end
|
@@ -115,12 +115,12 @@ describe UsersController do
|
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should reply to valid request" do
|
118
|
-
expect { get :show, :id => 5, :session =>
|
118
|
+
expect { get :show, :params => { :id => 5, :session => 'secret_hash' }}.not_to raise_error
|
119
119
|
assert_response :success
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should fail if extra parameter is passed in" do
|
123
|
-
expect { get :show, :
|
123
|
+
expect { get :show, :params => { :id => 5 , :badparam => 'badfoo', :session => "secret_hash" }}.to raise_error(Apipie::UnknownParam, /\bbadparam\b/)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
@@ -132,86 +132,80 @@ describe UsersController do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
it "should reply to valid request" do
|
135
|
-
get :show, :id => '5', :session => "secret_hash"
|
135
|
+
get :show, :params => { :id => '5', :session => "secret_hash" }
|
136
136
|
assert_response :success
|
137
137
|
end
|
138
138
|
|
139
139
|
it "should work with nil value for a required hash param" do
|
140
140
|
expect {
|
141
|
-
get :show, :id => '5', :session => "secret_hash", :hash_param => {:dummy_hash => nil}
|
141
|
+
get :show, :params => { :id => '5', :session => "secret_hash", :hash_param => {:dummy_hash => nil} }
|
142
142
|
}.to raise_error(Apipie::ParamInvalid, /dummy_hash/)
|
143
143
|
assert_response :success
|
144
144
|
end
|
145
145
|
|
146
146
|
it "should fail if required parameter is missing" do
|
147
|
-
expect { get :show, :id => 5 }.to raise_error(Apipie::ParamMissing, /session_parameter_is_required/)
|
147
|
+
expect { get :show, :params => { :id => 5 }}.to raise_error(Apipie::ParamMissing, /session_parameter_is_required/)
|
148
148
|
end
|
149
149
|
|
150
150
|
it "should work with custom Type validator" do
|
151
151
|
expect {
|
152
152
|
get :show,
|
153
|
-
:id => "not a number",
|
154
|
-
:session => "secret_hash"
|
153
|
+
:params => { :id => "not a number", :session => "secret_hash" }
|
155
154
|
}.to raise_error(Apipie::ParamError, /id/) # old-style error rather than ParamInvalid
|
156
155
|
end
|
157
156
|
|
158
157
|
it "should work with Regexp validator" do
|
159
|
-
get :show,
|
160
|
-
:id => 5,
|
161
|
-
:session => "secret_hash",
|
162
|
-
:regexp_param => "24 years"
|
158
|
+
get :show, :params => { :id => 5, :session => "secret_hash", :regexp_param => "24 years" }
|
163
159
|
assert_response :success
|
164
160
|
|
165
161
|
expect {
|
166
|
-
get :show,
|
167
|
-
|
168
|
-
|
169
|
-
:regexp_param => "ten years"
|
162
|
+
get :show, :params => { :id => 5,
|
163
|
+
:session => "secret_hash",
|
164
|
+
:regexp_param => "ten years" }
|
170
165
|
}.to raise_error(Apipie::ParamInvalid, /regexp_param/)
|
171
166
|
end
|
172
167
|
|
173
168
|
it "should work with Array validator" do
|
174
|
-
get :show, :id => 5, :session => "secret_hash", :array_param => "one"
|
169
|
+
get :show, :params => { :id => 5, :session => "secret_hash", :array_param => "one" }
|
175
170
|
assert_response :success
|
176
|
-
get :show, :id => 5, :session => "secret_hash", :array_param => "two"
|
171
|
+
get :show, :params => { :id => 5, :session => "secret_hash", :array_param => "two" }
|
177
172
|
assert_response :success
|
178
|
-
get :show, :id => 5, :session => "secret_hash", :array_param => '1'
|
179
|
-
assert_response :success
|
180
|
-
get :show, :id => 5, :session => "secret_hash", :boolean_param => false
|
173
|
+
get :show, :params => { :id => 5, :session => "secret_hash", :array_param => '1' }
|
181
174
|
assert_response :success
|
182
175
|
|
183
176
|
expect {
|
184
|
-
get :show,
|
185
|
-
|
186
|
-
|
187
|
-
:array_param => "blabla"
|
177
|
+
get :show, :params => { :id => 5,
|
178
|
+
:session => "secret_hash",
|
179
|
+
:array_param => "blabla" }
|
188
180
|
}.to raise_error(Apipie::ParamInvalid, /array_param/)
|
189
181
|
|
190
182
|
expect {
|
191
|
-
get :show,
|
192
|
-
|
193
|
-
|
194
|
-
|
183
|
+
get :show, :params => {
|
184
|
+
:id => 5,
|
185
|
+
:session => "secret_hash",
|
186
|
+
:array_param => 3 }
|
195
187
|
}.to raise_error(Apipie::ParamInvalid, /array_param/)
|
196
188
|
end
|
197
189
|
|
198
190
|
it "should work with Proc validator" do
|
199
191
|
expect {
|
200
192
|
get :show,
|
201
|
-
:
|
202
|
-
|
203
|
-
|
193
|
+
:params => {
|
194
|
+
:id => 5,
|
195
|
+
:session => "secret_hash",
|
196
|
+
:proc_param => "asdgsag" }
|
204
197
|
}.to raise_error(Apipie::ParamInvalid, /proc_param/)
|
205
198
|
|
206
199
|
get :show,
|
207
|
-
:
|
208
|
-
|
209
|
-
|
200
|
+
:params => {
|
201
|
+
:id => 5,
|
202
|
+
:session => "secret_hash",
|
203
|
+
:proc_param => "param value"}
|
210
204
|
assert_response :success
|
211
205
|
end
|
212
206
|
|
213
207
|
it "should work with Hash validator" do
|
214
|
-
post :create, :user => { :name => "root", :pass => "12345", :membership => "standard" }
|
208
|
+
post :create, params: { :user => { :name => "root", :pass => "12345", :membership => "standard" } }
|
215
209
|
assert_response :success
|
216
210
|
|
217
211
|
a = Apipie[UsersController, :create]
|
@@ -225,18 +219,18 @@ describe UsersController do
|
|
225
219
|
hash_params[2].name == :membership
|
226
220
|
|
227
221
|
expect {
|
228
|
-
post :create, :user => { :name => "root", :pass => "12345", :membership => "____" }
|
222
|
+
post :create, :params => { :user => { :name => "root", :pass => "12345", :membership => "____" } }
|
229
223
|
}.to raise_error(Apipie::ParamInvalid, /membership/)
|
230
224
|
|
231
225
|
expect {
|
232
|
-
post :create, :user => { :name => "root" }
|
226
|
+
post :create, :params => { :user => { :name => "root" } }
|
233
227
|
}.to raise_error(Apipie::ParamMissing, /pass/)
|
234
228
|
|
235
229
|
expect {
|
236
|
-
post :create, :user => "a string is not a hash"
|
230
|
+
post :create, :params => { :user => "a string is not a hash" }
|
237
231
|
}.to raise_error(Apipie::ParamInvalid, /user/)
|
238
232
|
|
239
|
-
post :create, :user => { :name => "root", :pass => "pwd" }
|
233
|
+
post :create, :params => { :user => { :name => "root", :pass => "pwd" } }
|
240
234
|
assert_response :success
|
241
235
|
end
|
242
236
|
|
@@ -244,10 +238,11 @@ describe UsersController do
|
|
244
238
|
params = Apipie[UsersController, :create].to_json[:params]
|
245
239
|
expect(params).to include(:name => "facts",
|
246
240
|
:full_name => "facts",
|
247
|
-
:validator => "Must be Hash",
|
241
|
+
:validator => "Must be a Hash",
|
248
242
|
:description => "\n<p>Additional optional facts about the user</p>\n",
|
249
243
|
:required => false,
|
250
244
|
:allow_nil => true,
|
245
|
+
:allow_blank => false,
|
251
246
|
:metadata => nil,
|
252
247
|
:show => true,
|
253
248
|
:expected_type => "hash",
|
@@ -256,12 +251,27 @@ describe UsersController do
|
|
256
251
|
|
257
252
|
it "should allow nil when allow_nil is set to true" do
|
258
253
|
post :create,
|
259
|
-
:
|
260
|
-
:
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
254
|
+
:params => {
|
255
|
+
:user => {
|
256
|
+
:name => "root",
|
257
|
+
:pass => "12345",
|
258
|
+
:membership => "standard",
|
259
|
+
},
|
260
|
+
:facts => { :test => 'test' }
|
261
|
+
}
|
262
|
+
assert_response :success
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should allow blank when allow_blank is set to true" do
|
266
|
+
post :create,
|
267
|
+
:params => {
|
268
|
+
:user => {
|
269
|
+
:name => "root",
|
270
|
+
:pass => "12345",
|
271
|
+
:membership => "standard"
|
272
|
+
},
|
273
|
+
:age => ""
|
274
|
+
}
|
265
275
|
assert_response :success
|
266
276
|
end
|
267
277
|
|
@@ -270,7 +280,7 @@ describe UsersController do
|
|
270
280
|
context "with valid input" do
|
271
281
|
it "should succeed" do
|
272
282
|
put :update,
|
273
|
-
{
|
283
|
+
:params => {
|
274
284
|
:id => 5,
|
275
285
|
:user => {
|
276
286
|
:name => "root",
|
@@ -293,27 +303,27 @@ describe UsersController do
|
|
293
303
|
it "should raise an error" do
|
294
304
|
expect{
|
295
305
|
put :update,
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
},
|
302
|
-
:comments => [
|
303
|
-
{
|
304
|
-
:comment => 'comment1'
|
306
|
+
:params => {
|
307
|
+
:id => 5,
|
308
|
+
:user => {
|
309
|
+
:name => "root",
|
310
|
+
:pass => "12345"
|
305
311
|
},
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
312
|
+
:comments => [
|
313
|
+
{
|
314
|
+
:comment => {:bad_input => 4}
|
315
|
+
},
|
316
|
+
{
|
317
|
+
:comment => {:bad_input => 5}
|
318
|
+
}
|
319
|
+
]
|
320
|
+
}
|
311
321
|
}.to raise_error(Apipie::ParamInvalid)
|
312
322
|
end
|
313
323
|
end
|
314
324
|
it "should work with empty array" do
|
315
325
|
put :update,
|
316
|
-
{
|
326
|
+
:params => {
|
317
327
|
:id => 5,
|
318
328
|
:user => {
|
319
329
|
:name => "root",
|
@@ -441,6 +451,14 @@ describe UsersController do
|
|
441
451
|
expect(a.errors[2].description).to eq("Not Found")
|
442
452
|
end
|
443
453
|
|
454
|
+
it 'should recognize Rack symbols as error codes' do
|
455
|
+
a = Apipie.get_method_description(UsersController, :create)
|
456
|
+
|
457
|
+
error = a.errors.find { |e| e.code == 422 }
|
458
|
+
expect(error).to be
|
459
|
+
expect(error.description).to include("Unprocessable Entity")
|
460
|
+
end
|
461
|
+
|
444
462
|
it "should contain all params description" do
|
445
463
|
a = Apipie.get_method_description(UsersController, :show)
|
446
464
|
expect(a.params.count).to eq(12)
|
@@ -464,7 +482,19 @@ describe UsersController do
|
|
464
482
|
name: :OptionalHeaderName,
|
465
483
|
description: 'Optional header description',
|
466
484
|
options: {
|
467
|
-
required: false
|
485
|
+
required: false,
|
486
|
+
type: "string"
|
487
|
+
}
|
488
|
+
}
|
489
|
+
end
|
490
|
+
|
491
|
+
let(:expected_header_with_default) do
|
492
|
+
{
|
493
|
+
name: :HeaderNameWithDefaultValue,
|
494
|
+
description: 'Header with default value',
|
495
|
+
options: {
|
496
|
+
required: true,
|
497
|
+
default: 'default value'
|
468
498
|
}
|
469
499
|
}
|
470
500
|
end
|
@@ -475,6 +505,7 @@ describe UsersController do
|
|
475
505
|
|
476
506
|
compare_hashes headers[0], expected_required_header
|
477
507
|
compare_hashes headers[1], expected_optional_header
|
508
|
+
compare_hashes headers[2], expected_header_with_default
|
478
509
|
end
|
479
510
|
end
|
480
511
|
|
@@ -525,7 +556,8 @@ describe UsersController do
|
|
525
556
|
:params => [{:full_name=>"oauth",
|
526
557
|
:required=>false,
|
527
558
|
:allow_nil => false,
|
528
|
-
:
|
559
|
+
:allow_blank => false,
|
560
|
+
:validator=>"Must be a String",
|
529
561
|
:description=>"\n<p>Authorization</p>\n",
|
530
562
|
:name=>"oauth",
|
531
563
|
:show=>true,
|
@@ -534,6 +566,7 @@ describe UsersController do
|
|
534
566
|
:description=>"\n<p>Deprecated parameter not documented</p>\n",
|
535
567
|
:expected_type=>"hash",
|
536
568
|
:allow_nil=>false,
|
569
|
+
:allow_blank => false,
|
537
570
|
:name=>"legacy_param",
|
538
571
|
:required=>false,
|
539
572
|
:full_name=>"legacy_param",
|
@@ -543,6 +576,7 @@ describe UsersController do
|
|
543
576
|
:description=>"\n<p>Param description for all methods</p>\n",
|
544
577
|
:expected_type=>"hash",
|
545
578
|
:allow_nil=>false,
|
579
|
+
:allow_blank => false,
|
546
580
|
:name=>"resource_param",
|
547
581
|
:required=>false,
|
548
582
|
:full_name=>"resource_param",
|
@@ -550,14 +584,16 @@ describe UsersController do
|
|
550
584
|
:params=>
|
551
585
|
[{:required=>true,
|
552
586
|
:allow_nil => false,
|
553
|
-
:
|
587
|
+
:allow_blank => false,
|
588
|
+
:validator=>"Must be a String",
|
554
589
|
:description=>"\n<p>Username for login</p>\n",
|
555
590
|
:name=>"ausername", :full_name=>"resource_param[ausername]",
|
556
591
|
:show=>true,
|
557
592
|
:expected_type=>"string"},
|
558
593
|
{:required=>true,
|
559
594
|
:allow_nil => false,
|
560
|
-
:
|
595
|
+
:allow_blank => false,
|
596
|
+
:validator=>"Must be a String",
|
561
597
|
:description=>"\n<p>Password for login</p>\n",
|
562
598
|
:name=>"apassword", :full_name=>"resource_param[apassword]",
|
563
599
|
:show=>true,
|
@@ -567,6 +603,7 @@ describe UsersController do
|
|
567
603
|
},
|
568
604
|
{:required=>false, :validator=>"Parameter has to be Integer.",
|
569
605
|
:allow_nil => false,
|
606
|
+
:allow_blank => false,
|
570
607
|
:description=>"\n<p>Company ID</p>\n",
|
571
608
|
:name=>"id", :full_name=>"id",
|
572
609
|
:show=>true,
|
@@ -690,17 +727,20 @@ EOS2
|
|
690
727
|
|
691
728
|
describe "Parameter processing / extraction" do
|
692
729
|
before do
|
730
|
+
Apipie.configuration.validate = true
|
693
731
|
Apipie.configuration.process_params = true
|
732
|
+
controllers_dirname = File.expand_path('../dummy/app/controllers', File.dirname(__FILE__))
|
733
|
+
Dir.glob("#{controllers_dirname}/**/*") { |file| load(file) if File.file?(file) }
|
694
734
|
end
|
695
735
|
|
696
736
|
it "process correctly the parameters" do
|
697
|
-
post :create, {:user => {:name => 'dummy', :pass => 'dummy', :membership => 'standard'}, :facts =>
|
737
|
+
post :create, :params => {:user => {:name => 'dummy', :pass => 'dummy', :membership => 'standard' }, :facts => {:test => 'test'}}
|
698
738
|
|
699
|
-
expect(assigns(:api_params).with_indifferent_access).to eq({:user => {:name=>"dummy", :pass=>"dummy", :membership=>"standard"}, :facts =>
|
739
|
+
expect(assigns(:api_params).with_indifferent_access).to eq({:user => {:name=>"dummy", :pass=>"dummy", :membership=>"standard"}, :facts => {:test => 'test'}}.with_indifferent_access)
|
700
740
|
end
|
701
741
|
|
702
742
|
it "ignore not described parameters" do
|
703
|
-
post :create, {:user => {:name => 'dummy', :pass => 'dummy', :membership => 'standard', :id => 0}}
|
743
|
+
post :create, :params => {:user => {:name => 'dummy', :pass => 'dummy', :membership => 'standard', :id => 0}}
|
704
744
|
|
705
745
|
expect(assigns(:api_params).with_indifferent_access).to eq({:user => {:name=>"dummy", :pass=>"dummy", :membership=>"standard"}}.with_indifferent_access)
|
706
746
|
end
|
@@ -1,8 +1,12 @@
|
|
1
1
|
class ApplicationController < ActionController::Base
|
2
|
-
|
2
|
+
before_action :run_validations
|
3
3
|
|
4
4
|
resource_description do
|
5
5
|
param :oauth, String, :desc => "Authorization", :required => false
|
6
|
+
|
7
|
+
returns :code => 401 do
|
8
|
+
property :reason, String, "Why authorization was denied"
|
9
|
+
end
|
6
10
|
end
|
7
11
|
|
8
12
|
def run_validations
|
@@ -4,13 +4,13 @@ module Concerns
|
|
4
4
|
|
5
5
|
api!
|
6
6
|
def index
|
7
|
-
render :
|
7
|
+
render :plain => "OK #{params.inspect}"
|
8
8
|
end
|
9
9
|
|
10
10
|
api :GET, '/:resource_id/:id'
|
11
11
|
param :id, String
|
12
12
|
def show
|
13
|
-
render :
|
13
|
+
render :plain => "OK #{params.inspect}"
|
14
14
|
end
|
15
15
|
|
16
16
|
def_param_group :concern do
|
@@ -23,19 +23,19 @@ module Concerns
|
|
23
23
|
api :POST, '/:resource_id', "Create a :concern"
|
24
24
|
param_group :concern
|
25
25
|
def create
|
26
|
-
render :
|
26
|
+
render :plain => "OK #{params.inspect}"
|
27
27
|
end
|
28
28
|
|
29
29
|
api :PUT, '/:resource_id/:id'
|
30
30
|
param :id, String
|
31
31
|
param_group :concern
|
32
32
|
def update
|
33
|
-
render :
|
33
|
+
render :plain => "OK #{params.inspect}"
|
34
34
|
end
|
35
35
|
|
36
36
|
api :GET, '/:resource_id/:custom_subst'
|
37
37
|
def custom
|
38
|
-
render :
|
38
|
+
render :plain => "OK #{params.inspect}"
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|