apipie-rails 0.5.0 → 0.5.1

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
  SHA1:
3
- metadata.gz: 8f1836e9d470aab5a5fd2592c5bd020670d7644f
4
- data.tar.gz: 915e53c2aed478f60375817066e059dc0b955e66
3
+ metadata.gz: 21e987c452e1e522365932db32bb06b9d4dabf51
4
+ data.tar.gz: 92d447975ab9539f24b52c19e0fa22875b0fe039
5
5
  SHA512:
6
- metadata.gz: dc7d88e8c09ada1e11c86ce87e2535876c9c553532eb4ef07b66b862583308352e80ca47c2e656a43e85a9764725cea834c46bc20e5eae6321364509b5f9e21f
7
- data.tar.gz: c6580080b5dc965477997baba13787948d2c749657156a02ab771a2890adab3195f04791fa736f832cdc4c1c20b6f4157edddace1441e7e453a87fe23c2126d2
6
+ metadata.gz: 097757c953763f1a70eb1005dda15fb0734e6e9670e235a6b534a0ef3a109ab087e7e7e01459edb822cc4f887009d57ad17a733c081c14eac72deae2d384bb6f
7
+ data.tar.gz: 2ef85b2507dc949756c8816c31c340efdc4f59f259c92fe0342972f4f799240c1443f637ca2f4e91114fbfbd283ed3a30a3afdbd553a95307444e32531cd5fed
data/CHANGELOG.md CHANGED
@@ -1,7 +1,12 @@
1
- ===========
2
1
  Changelog
3
2
  ===========
4
3
 
4
+ v0.5.1
5
+ ------
6
+
7
+ - Use AD::Reloader on Rails 4, app.reloader only on Rails 5+ [\#541](https://github.com/Apipie/apipie-rails/pull/541) ([domcleal](https://github.com/domcleal))
8
+ - Recognize Rack Symbols as Status Codes [\#468](https://github.com/Apipie/apipie-rails/pull/468)([alex-tan](https://github.com/alex-tan))
9
+
5
10
  v0.5.0
6
11
  ------
7
12
 
data/README.rst CHANGED
@@ -152,6 +152,7 @@ Example:
152
152
  api_version "development"
153
153
  error 404, "Missing"
154
154
  error 500, "Server crashed for some <%= reason %>", :meta => {:anything => "you can think of"}
155
+ error :unprocessable_entity, "Could not save the entity."
155
156
  meta :author => {:name => 'John', :surname => 'Doe'}
156
157
  description <<-EOS
157
158
  == Long description
@@ -424,10 +424,10 @@ module Apipie
424
424
  # as this would break loading of the controllers.
425
425
  def rails_mark_classes_for_reload
426
426
  unless Rails.application.config.cache_classes
427
- Rails.application.reloader.reload!
427
+ Rails::VERSION::MAJOR == 4 ? ActionDispatch::Reloader.cleanup! : Rails.application.reloader.reload!
428
428
  init_env
429
429
  reload_examples
430
- Rails.application.reloader.prepare!
430
+ Rails::VERSION::MAJOR == 4 ? ActionDispatch::Reloader.prepare! : Rails.application.reloader.prepare!
431
431
  end
432
432
  end
433
433
 
@@ -1,7 +1,6 @@
1
1
  module Apipie
2
2
 
3
3
  class ErrorDescription
4
-
5
4
  attr_reader :code, :description, :metadata
6
5
 
7
6
  def self.from_dsl_data(args)
@@ -18,7 +17,15 @@ module Apipie
18
17
  @metadata = code_or_options[:meta]
19
18
  @description = code_or_options[:desc] || code_or_options[:description]
20
19
  else
21
- @code = code_or_options
20
+ @code =
21
+ if code_or_options.is_a? Symbol
22
+ Rack::Utils::SYMBOL_TO_STATUS_CODE[code_or_options]
23
+ else
24
+ code_or_options
25
+ end
26
+
27
+ raise UnknownCode, code_or_options unless @code
28
+
22
29
  @metadata = options[:meta]
23
30
  @description = desc
24
31
  end
data/lib/apipie/errors.rb CHANGED
@@ -6,6 +6,9 @@ module Apipie
6
6
  class ParamError < Error
7
7
  end
8
8
 
9
+ class UnknownCode < Error
10
+ end
11
+
9
12
  # abstract
10
13
  class DefinedParamError < ParamError
11
14
  attr_accessor :param
@@ -1,3 +1,3 @@
1
1
  module Apipie
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
@@ -451,6 +451,14 @@ describe UsersController do
451
451
  expect(a.errors[2].description).to eq("Not Found")
452
452
  end
453
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
+
454
462
  it "should contain all params description" do
455
463
  a = Apipie.get_method_description(UsersController, :show)
456
464
  expect(a.params.count).to eq(12)
@@ -222,6 +222,7 @@ class UsersController < ApplicationController
222
222
  end
223
223
  param :facts, Hash, :desc => "Additional optional facts about the user", :allow_nil => true
224
224
  param :age, :number, :desc => "Age is just a number", :allow_blank => true
225
+ error :unprocessable_entity, 'Unprocessable Entity'
225
226
  def create
226
227
  render :plain => "OK #{params.inspect}"
227
228
  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.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pokorny
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-19 00:00:00.000000000 Z
12
+ date: 2017-04-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails