rswag-specs 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rswag/specs/example_group_helpers.rb +9 -1
- data/lib/rswag/specs/response_validator.rb +11 -1
- data/lib/rswag/specs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49be56b88aea5546d3da61531c070ae2d01a27a6
|
4
|
+
data.tar.gz: 409e21ceb9ce56abd58de22e324da05664742a05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a58b3e8546f2297c08851b440ddec0929433ed00a6830c0ce1e9cd958b7c2722aeedb75ca42eef6cc88b0a8347e0cf5a99bf7a2df269f53e94b236b6b259866
|
7
|
+
data.tar.gz: b86aa2725f38bc3f839cb912fccc9a28a7dc8408b2e175294005ba9ef815cc7fdfc003a5587de5b1161202ad3ee8505c9cc2a6e0fb65a0bcf6f5e87e74cae08b
|
@@ -25,7 +25,7 @@ module Rswag
|
|
25
25
|
# functionality while also setting the appropriate metadata if applicable
|
26
26
|
def description(value=nil)
|
27
27
|
return super() if value.nil?
|
28
|
-
metadata[:operation][:description] = value
|
28
|
+
metadata[:operation][:description] = value
|
29
29
|
end
|
30
30
|
|
31
31
|
# These are array properties - note the splat operator
|
@@ -61,6 +61,14 @@ module Rswag
|
|
61
61
|
metadata[:response][:headers][name] = attributes
|
62
62
|
end
|
63
63
|
|
64
|
+
# NOTE: Similar to 'description', 'examples' need to handle the case when
|
65
|
+
# being invoked with no params to avoid overriding 'examples' method of
|
66
|
+
# rspec-core ExampleGroup
|
67
|
+
def examples(example = nil)
|
68
|
+
return super() if example.nil?
|
69
|
+
metadata[:response][:examples] = example
|
70
|
+
end
|
71
|
+
|
64
72
|
def run_test!
|
65
73
|
# NOTE: rspec 2.x support
|
66
74
|
if RSPEC_VERSION < 3
|
@@ -13,6 +13,7 @@ module Rswag
|
|
13
13
|
|
14
14
|
def validate!(response)
|
15
15
|
validate_code!(response.code)
|
16
|
+
validate_headers!(response.headers)
|
16
17
|
validate_body!(response.body)
|
17
18
|
end
|
18
19
|
|
@@ -24,6 +25,15 @@ module Rswag
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
def validate_headers!(headers)
|
29
|
+
header_schema = @api_metadata[:response][:headers]
|
30
|
+
return if header_schema.nil?
|
31
|
+
|
32
|
+
header_schema.keys.each do |header_name|
|
33
|
+
raise UnexpectedResponse, "Expected response header #{header_name} to be present" if headers[header_name.to_s].nil?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
27
37
|
def validate_body!(body)
|
28
38
|
response_schema = @api_metadata[:response][:schema]
|
29
39
|
return if response_schema.nil?
|
@@ -34,7 +44,7 @@ module Rswag
|
|
34
44
|
.merge(@global_metadata.slice(:definitions))
|
35
45
|
JSON::Validator.validate!(validation_schema, body)
|
36
46
|
rescue JSON::Schema::ValidationError => ex
|
37
|
-
raise UnexpectedResponse, "Expected response body to match schema: #{ex.message}"
|
47
|
+
raise UnexpectedResponse, "Expected response body to match schema: #{ex.message}"
|
38
48
|
end
|
39
49
|
end
|
40
50
|
end
|
data/lib/rswag/specs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rswag-specs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richie Morris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|