committee 5.5.5 → 5.6.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10ed6ddc2d6c096a049a6275805284208597cfd4ce5914e55e589086c3102e5c
|
4
|
+
data.tar.gz: d80857a5a6432b9df9bfb2468121e7cfee9d6e92452cf6ec15e45abc73ad11fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed48641dd4ad2db6df1e833f1dea1a761a53f2d7225c828ccf7b1ba9960d2f4ddc48cd1244c82ad77248b846a0744c026a755d5cab051afba91139e7e26a1ae8
|
7
|
+
data.tar.gz: dbf05393911aa659514e8f90cb899cb5fbf30df3f6709ff95ab2ce5f9137dcdc4ce791667b937201a1a2daf5fe6e43325e1c05d8726118136be8adff9321afa2
|
@@ -11,13 +11,14 @@ module Committee
|
|
11
11
|
@validate_success_only = options[:validate_success_only]
|
12
12
|
@allow_blank_structures = options[:allow_blank_structures]
|
13
13
|
|
14
|
+
@validator = nil
|
14
15
|
@validators = {}
|
15
16
|
if link.is_a? Drivers::OpenAPI2::Link
|
16
17
|
link.target_schemas.each do |status, schema|
|
17
18
|
@validators[status] = JsonSchema::Validator.new(target_schema(link))
|
18
19
|
end
|
19
20
|
else
|
20
|
-
@
|
21
|
+
@validator = JsonSchema::Validator.new(target_schema(link))
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
@@ -53,10 +54,17 @@ module Committee
|
|
53
54
|
|
54
55
|
begin
|
55
56
|
if Committee::Middleware::ResponseValidation.validate?(status, validate_success_only)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
if @link.is_a?(Drivers::OpenAPI2::Link)
|
58
|
+
raise InvalidResponse, "Invalid response.#{@link.href} status code #{status} definition does not exist" if @validators[status].nil?
|
59
|
+
if !@validators[status].validate(data)
|
60
|
+
errors = JsonSchema::SchemaError.aggregate(@validators[status].errors).join("\n")
|
61
|
+
raise InvalidResponse, "Invalid response.\n\n#{errors}"
|
62
|
+
end
|
63
|
+
else
|
64
|
+
if !@validator.validate(data)
|
65
|
+
errors = JsonSchema::SchemaError.aggregate(@validator.errors).join("\n")
|
66
|
+
raise InvalidResponse, "Invalid response.\n\n#{errors}"
|
67
|
+
end
|
60
68
|
end
|
61
69
|
end
|
62
70
|
rescue => e
|
data/lib/committee/version.rb
CHANGED
@@ -9,6 +9,8 @@ describe Committee::SchemaValidator::HyperSchema::ResponseValidator do
|
|
9
9
|
@data = ValidApp.dup
|
10
10
|
@schema = JsonSchema.parse!(hyper_schema_data)
|
11
11
|
@schema.expand_references!
|
12
|
+
# POST /apps
|
13
|
+
@create_link = @schema.properties["app"].links[0]
|
12
14
|
# GET /apps/:id
|
13
15
|
@get_link = @link = @schema.properties["app"].links[2]
|
14
16
|
# GET /apps
|
@@ -41,6 +43,12 @@ describe Committee::SchemaValidator::HyperSchema::ResponseValidator do
|
|
41
43
|
call
|
42
44
|
end
|
43
45
|
|
46
|
+
it "allows non-201 on create" do
|
47
|
+
@link = @create_link
|
48
|
+
@status = 200
|
49
|
+
call
|
50
|
+
end
|
51
|
+
|
44
52
|
it "passes through a valid list response for for rel instances links" do
|
45
53
|
@link = @list_link
|
46
54
|
|