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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/esplanade/request/error.rb +31 -0
- data/lib/esplanade/request/validation.rb +5 -4
- data/lib/esplanade/request.rb +1 -6
- data/lib/esplanade/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85995e3ffde40ae8fb299e8bdc4ac1173283590c
|
4
|
+
data.tar.gz: 0f1242bec48b135345a4b6d1680cd6f4fc98f698
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d332f111d4860bd09e341c2c8aebfb35157e1582b6506b70d8176ef9ad118b101f14ca6f8aa98898ef95ec0394ae2be2aae9ef9a433bee86411c0367a2f93f82
|
7
|
+
data.tar.gz: e8d29d45efa8908f74c2f1046c61840131a816218ebd222c618edadaca5a45dedac020a319c56625dbac9aa75140054cf30b6197d97e8602d21db14f991f05e5
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
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:
|
23
|
-
body:
|
24
|
-
error:
|
23
|
+
path: @raw.path,
|
24
|
+
body: @raw.body.to_hash,
|
25
|
+
error: @error
|
25
26
|
}
|
26
27
|
end
|
27
28
|
end
|
data/lib/esplanade/request.rb
CHANGED
@@ -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
|
data/lib/esplanade/version.rb
CHANGED
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.
|
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-
|
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
|