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: d5ca2d98a65682acdd759d0fdbb8de493cec34b96889fec3cfd18bf4928b50cc
4
- data.tar.gz: f2c50536c4bd4840dae6dc1a3da96c4a85dd2ec25ee69e55c944a90f3a514d00
3
+ metadata.gz: 10ed6ddc2d6c096a049a6275805284208597cfd4ce5914e55e589086c3102e5c
4
+ data.tar.gz: d80857a5a6432b9df9bfb2468121e7cfee9d6e92452cf6ec15e45abc73ad11fe
5
5
  SHA512:
6
- metadata.gz: b3f35d67aab36148b9085b0a129ee315ea41e27ed6fde96c2038830c2046a3d1d5e212feeae849cd3d4571d69b01349911826711a699d326d6e799ca725a9391
7
- data.tar.gz: 411bb7a8a21de88b9c978cb848480a2a40ebd9aab2e9819648d066d301db47420e9ccf9820c292e441c90b546d9c42ff42b0363c852e7db78e7eb902415adf6c
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
- @validators[link.status_success] = JsonSchema::Validator.new(target_schema(link))
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
- raise InvalidResponse, "Invalid response.#{@link.href} status code #{status} definition does not exist" if @validators[status].nil?
57
- if !@validators[status].validate(data)
58
- errors = JsonSchema::SchemaError.aggregate(@validators[status].errors).join("\n")
59
- raise InvalidResponse, "Invalid response.\n\n#{errors}"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Committee
4
- VERSION = '5.5.5'.freeze
4
+ VERSION = '5.6.0'.freeze
5
5
  end
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: committee
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.5
4
+ version: 5.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandur