apipie-rails 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,14 @@
1
1
  class ApplicationController < ActionController::Base
2
+ before_filter :run_validations
2
3
 
3
4
  resource_description do
4
5
  param :oauth, String, :desc => "Authorization", :required => false
5
6
  end
7
+
8
+ def run_validations
9
+ if Apipie.configuration.validate == :explicitly
10
+ apipie_validations
11
+ end
12
+ end
13
+
6
14
  end
@@ -0,0 +1,5 @@
1
+ class FilesController < ApplicationController
2
+ def download
3
+ render :text => "dummy file body for #{params[:file_path]}"
4
+ end
5
+ end
@@ -268,4 +268,14 @@ class UsersController < ApplicationController
268
268
  def desc_from_file
269
269
  render :text => 'document from file action'
270
270
  end
271
+
272
+ api! 'Create user'
273
+ param_group :user
274
+ param :user, Hash do
275
+ param :permalink, String
276
+ end
277
+ param :facts, Hash, :desc => "Additional optional facts about the user", :allow_nil => true
278
+ def create_route
279
+ end
280
+
271
281
  end
@@ -41,7 +41,7 @@ Apipie.configure do |config|
41
41
  # to disable markup, use
42
42
  # config.markup = nil
43
43
 
44
- # config.validate = false
44
+ config.validate = false
45
45
 
46
46
  # set all parameters as required by default
47
47
  # if enabled, use param :name, val, :required => false for optional params
@@ -73,7 +73,6 @@ Apipie.configure do |config|
73
73
  # config.link_extension = ""
74
74
  end
75
75
 
76
-
77
76
  # integer validator
78
77
  class Apipie::Validator::IntegerValidator < Apipie::Validator::BaseValidator
79
78
 
@@ -3,8 +3,15 @@ Dummy::Application.routes.draw do
3
3
  scope ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
4
4
 
5
5
  scope '/api' do
6
- resources :users
6
+ resources :users do
7
+ collection do
8
+ post :create_route
9
+ end
10
+ end
7
11
  resources :concerns, :only => [:index, :show]
12
+ namespace :files do
13
+ get '/*file_path', to: :download, format: false
14
+ end
8
15
  resources :twitter_example do
9
16
  collection do
10
17
  get :lookup
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ describe Apipie::Extractor do
4
+ it 'handles routes without (.:format)' do
5
+ Apipie::Extractor.apis_from_routes.each do |(controller, action), apis|
6
+ apis.each { |api| expect(api[:path]).not_to be_nil }
7
+ end
8
+ end
9
+ end
@@ -18,4 +18,27 @@ describe Apipie::Extractor::Recorder::Middleware do
18
18
  expect(Apipie::Extractor).to receive(:clean_call_recorder)
19
19
  response
20
20
  end
21
+
22
+ describe 'with a multipart post' do
23
+ let(:form_hash) do
24
+ {
25
+ 'stringbody' => 'this is a string body',
26
+ 'filebody' => {:head => 'X-Fake-Header: fake1\r\n'},
27
+ 'files' => {
28
+ '0' => {:head => 'X-Fake-Header: fake2\r\n'}
29
+ }
30
+ }
31
+ end
32
+
33
+ let(:response) do
34
+ request.post('/', 'rack.request.form_hash' => form_hash)
35
+ end
36
+
37
+ it 'reformats form parts' do
38
+ Apipie.configuration.record = true
39
+ # expect reformat_multipart_data to invoke content_disposition
40
+ expect(Apipie::Extractor.call_recorder).to receive(:content_disposition)
41
+ response
42
+ end
43
+ end
21
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apipie-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-08-29 00:00:00.000000000 Z
13
+ date: 2015-01-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -224,6 +224,7 @@ files:
224
224
  - lib/apipie/param_description.rb
225
225
  - lib/apipie/railtie.rb
226
226
  - lib/apipie/resource_description.rb
227
+ - lib/apipie/routes_formatter.rb
227
228
  - lib/apipie/routing.rb
228
229
  - lib/apipie/see_description.rb
229
230
  - lib/apipie/static_dispatcher.rb
@@ -254,6 +255,7 @@ files:
254
255
  - spec/dummy/app/controllers/application_controller.rb
255
256
  - spec/dummy/app/controllers/concerns/sample_controller.rb
256
257
  - spec/dummy/app/controllers/concerns_controller.rb
258
+ - spec/dummy/app/controllers/files_controller.rb
257
259
  - spec/dummy/app/controllers/overridden_concerns_controller.rb
258
260
  - spec/dummy/app/controllers/twitter_example_controller.rb
259
261
  - spec/dummy/app/controllers/users_controller.rb
@@ -290,6 +292,7 @@ files:
290
292
  - spec/dummy/public/stylesheets/.gitkeep
291
293
  - spec/dummy/script/rails
292
294
  - spec/lib/application_spec.rb
295
+ - spec/lib/extractor/extractor_spec.rb
293
296
  - spec/lib/extractor/middleware_spec.rb
294
297
  - spec/lib/extractor/writer_spec.rb
295
298
  - spec/lib/method_description_spec.rb
@@ -343,6 +346,7 @@ test_files:
343
346
  - spec/dummy/app/controllers/application_controller.rb
344
347
  - spec/dummy/app/controllers/concerns/sample_controller.rb
345
348
  - spec/dummy/app/controllers/concerns_controller.rb
349
+ - spec/dummy/app/controllers/files_controller.rb
346
350
  - spec/dummy/app/controllers/overridden_concerns_controller.rb
347
351
  - spec/dummy/app/controllers/twitter_example_controller.rb
348
352
  - spec/dummy/app/controllers/users_controller.rb
@@ -379,6 +383,7 @@ test_files:
379
383
  - spec/dummy/public/stylesheets/.gitkeep
380
384
  - spec/dummy/script/rails
381
385
  - spec/lib/application_spec.rb
386
+ - spec/lib/extractor/extractor_spec.rb
382
387
  - spec/lib/extractor/middleware_spec.rb
383
388
  - spec/lib/extractor/writer_spec.rb
384
389
  - spec/lib/method_description_spec.rb