esplanade 1.2.0 → 1.2.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: d56ac3bbfdcd35af5878ab7c38ba6192ef4e5957
4
- data.tar.gz: a17fd30d62e0039c6d70389e8f197e1b46a8bf17
3
+ metadata.gz: 85995e3ffde40ae8fb299e8bdc4ac1173283590c
4
+ data.tar.gz: 0f1242bec48b135345a4b6d1680cd6f4fc98f698
5
5
  SHA512:
6
- metadata.gz: fcbf87e4765ff6ac1b388e490c03dd9c72f57e062fdd9598e247ad4425e51f1723234142af8e0b89ff8611fe7e45834abbbb7c6c49e7237f23729cbe2b07209e
7
- data.tar.gz: 40d6f05bbc3ac4125d0e26f5ff21d0df8fd96fea36eb86efdb99547d3a16d1decb28feb8e93e86ee0cb0382bd21a1453d94cf77b0131e1974fae5ac1487be652
6
+ metadata.gz: d332f111d4860bd09e341c2c8aebfb35157e1582b6506b70d8176ef9ad118b101f14ca6f8aa98898ef95ec0394ae2be2aae9ef9a433bee86411c0367a2f93f82
7
+ data.tar.gz: e8d29d45efa8908f74c2f1046c61840131a816218ebd222c618edadaca5a45dedac020a319c56625dbac9aa75140054cf30b6197d97e8602d21db14f991f05e5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change log
2
2
 
3
+ ### 1.2.1 - 2018-02-20
4
+
5
+ * improvement
6
+ * more information about the invalid request
7
+
3
8
  ### 1.2.0 - 2018-02-15
4
9
 
5
10
  * features
@@ -0,0 +1,31 @@
1
+ module Esplanade
2
+ class Request
3
+ class Error < Esplanade::Error; end
4
+
5
+ class PrefixNotMatch < Error; end
6
+ class NotDocumented < Error; end
7
+ class BodyIsNotJson < Error; end
8
+
9
+ class Invalid < Error
10
+ attr_reader :method, :path, :body, :error
11
+
12
+ def initialize(method:, path:, body:, error:)
13
+ @method = method
14
+ @path = path
15
+ @body = body
16
+ @error = error
17
+
18
+ super(to_hash)
19
+ end
20
+
21
+ def to_hash
22
+ {
23
+ method: @method,
24
+ path: @path,
25
+ body: @body,
26
+ error: @error
27
+ }
28
+ end
29
+ end
30
+ end
31
+ end
@@ -11,7 +11,8 @@ module Esplanade
11
11
 
12
12
  def valid!
13
13
  @error ||= JSON::Validator.fully_validate(@doc.json_schema, @raw.body.to_hash)
14
- raise Invalid, message if @error != []
14
+
15
+ raise Invalid, message unless @error.empty?
15
16
  end
16
17
 
17
18
  private
@@ -19,9 +20,9 @@ module Esplanade
19
20
  def message
20
21
  {
21
22
  method: @raw.method,
22
- path: @raw.path,
23
- body: @raw.body.to_string,
24
- error: @error
23
+ path: @raw.path,
24
+ body: @raw.body.to_hash,
25
+ error: @error
25
26
  }
26
27
  end
27
28
  end
@@ -1,15 +1,10 @@
1
1
  require 'esplanade/request/doc'
2
2
  require 'esplanade/request/raw'
3
3
  require 'esplanade/request/validation'
4
+ require 'esplanade/request/error'
4
5
 
5
6
  module Esplanade
6
7
  class Request
7
- class Error < Esplanade::Error; end
8
- class PrefixNotMatch < Error; end
9
- class NotDocumented < Error; end
10
- class BodyIsNotJson < Error; end
11
- class Invalid < Error; end
12
-
13
8
  def initialize(documentation, env)
14
9
  @documentation = documentation
15
10
  @env = env
@@ -1,3 +1,3 @@
1
1
  module Esplanade
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esplanade
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - d.efimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-15 00:00:00.000000000 Z
11
+ date: 2018-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -207,6 +207,7 @@ files:
207
207
  - lib/esplanade/middlewares/safe_middleware.rb
208
208
  - lib/esplanade/request.rb
209
209
  - lib/esplanade/request/doc.rb
210
+ - lib/esplanade/request/error.rb
210
211
  - lib/esplanade/request/raw.rb
211
212
  - lib/esplanade/request/raw/body.rb
212
213
  - lib/esplanade/request/validation.rb