fitting 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/fitting/matchers/response_matcher.rb +6 -1
- data/lib/fitting/request.rb +4 -3
- data/lib/fitting/response.rb +4 -0
- data/lib/fitting/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adba51bf994a83f976b645f80537581c51da7fd2
|
4
|
+
data.tar.gz: 56df90a70b7dc86516d58706b945f35556e0c771
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4beb00e43f17d6cd07a9eb0e14a62e7c384773f9285e12f44cd5dfa6c7342cfbfe2fcba1af8deab170b33d2837c6356710fe233b22ec5cb42d665537878d8f45
|
7
|
+
data.tar.gz: 2be9f6e2ffb542e0b0391266ad8281ed435dd805027358b443ea875dfd807f1fc971fe28550fb4607740f9d9b887d282516ced737dd4735b64dbec2d61613d55
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -127,7 +127,7 @@ Default `false`. If `true` then all properties are condisidered to have `"requir
|
|
127
127
|
|
128
128
|
### prefix
|
129
129
|
|
130
|
-
Prefix of API requests. Example: `'/api'`.
|
130
|
+
Prefix of API requests. Example: `'/api'`. Validation will not be performed if the request path does not start with a prefix.
|
131
131
|
|
132
132
|
### white_list
|
133
133
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fitting/response'
|
2
2
|
require 'fitting/storage/documentation'
|
3
|
+
require 'fitting/configuration'
|
3
4
|
|
4
5
|
module Fitting
|
5
6
|
module Matchers
|
@@ -9,7 +10,11 @@ module Fitting
|
|
9
10
|
response,
|
10
11
|
Fitting::Storage::Documentation.tomogram
|
11
12
|
)
|
12
|
-
@response.
|
13
|
+
if @response.within_prefix?(Fitting.configuration.prefix)
|
14
|
+
@response.fully_validates.valid?
|
15
|
+
else
|
16
|
+
true
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
def ===(other)
|
data/lib/fitting/request.rb
CHANGED
@@ -7,9 +7,6 @@ module Fitting
|
|
7
7
|
@path = env_request.env['PATH_INFO'] || env_request.fullpath
|
8
8
|
@body = env_request.env['action_dispatch.request.request_parameters']
|
9
9
|
@schema = tomogram.find_request(method: @method, path: @path)
|
10
|
-
@fully_validate = JSON::Validator.fully_validate(@schema.request, @body) if @schema
|
11
|
-
@valid = false
|
12
|
-
@valid = true if @fully_validate == []
|
13
10
|
self
|
14
11
|
end
|
15
12
|
|
@@ -28,5 +25,9 @@ module Fitting
|
|
28
25
|
end
|
29
26
|
end
|
30
27
|
end
|
28
|
+
|
29
|
+
def within_prefix?(prefix)
|
30
|
+
@path.start_with?(prefix)
|
31
|
+
end
|
31
32
|
end
|
32
33
|
end
|
data/lib/fitting/response.rb
CHANGED
@@ -12,6 +12,10 @@ module Fitting
|
|
12
12
|
@schemas = @request.schemas_of_possible_responses(status: @status)
|
13
13
|
end
|
14
14
|
|
15
|
+
def within_prefix?(prefix)
|
16
|
+
@request.within_prefix?(prefix)
|
17
|
+
end
|
18
|
+
|
15
19
|
def fully_validates
|
16
20
|
@fully_validates ||= Fitting::Response::FullyValidates.craft(@schemas, @body, false)
|
17
21
|
end
|
data/lib/fitting/version.rb
CHANGED