openapi_validator 0.3.1 → 0.3.2
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: 03d06da470bc735d01636c06b916e5247d961cb6c1ba45927bed48b052ea8063
|
4
|
+
data.tar.gz: a1eb96abfb80219e9bf1019b6210a9b92a47a56be8db4887c6d6fdc59e97af6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8136a756581e5409821f4ca8d3ea10f9e1334b47dd1027af66415ab850f5db96bd69ed996d9e647ac41712bd22c7e6f0408c0fffef6c8a0edfef7a5f01d70f6
|
7
|
+
data.tar.gz: 607e50ebd480b4e0b2cdb6f91494ead6c33e781ca290b901f457fc3731e118a17366fac841811ae5f6755856726c4d96bfbf9bc62ad4082da4b53ad193798cd9
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
[gem]: https://rubygems.org/gems/openapi_validator
|
2
|
-
[travis]: https://travis-ci.org/
|
3
|
-
[codeclimate]: https://codeclimate.com/github/
|
2
|
+
[travis]: https://travis-ci.org/medsolutions/openapi_validator
|
3
|
+
[codeclimate]: https://codeclimate.com/github/medsolutions/openapi_validator
|
4
4
|
|
5
5
|
# openapi_validator
|
6
6
|
[][gem]
|
7
|
-
[][travis]
|
8
|
+
[][codeclimate]
|
9
|
+
[][codeclimate]
|
10
10
|
|
11
|
-
Validator used for [openapi_rspec](https://github.com/
|
11
|
+
Validator used for [openapi_rspec](https://github.com/medsolutions/openapi_rspec)
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
@@ -38,7 +38,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
38
38
|
|
39
39
|
## Contributing
|
40
40
|
|
41
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/medsolutions/openapi_validator.
|
42
42
|
|
43
43
|
## License
|
44
44
|
|
@@ -6,6 +6,10 @@ module OpenapiValidator
|
|
6
6
|
|
7
7
|
extend Forwardable
|
8
8
|
|
9
|
+
def empty_schema?
|
10
|
+
@empty_schema || false
|
11
|
+
end
|
12
|
+
|
9
13
|
def path
|
10
14
|
[path_key, method, @schema_code]
|
11
15
|
end
|
@@ -39,6 +43,10 @@ module OpenapiValidator
|
|
39
43
|
end
|
40
44
|
|
41
45
|
def validate_path_exists
|
46
|
+
if code_schema.nil?
|
47
|
+
@empty_schema = true
|
48
|
+
return
|
49
|
+
end
|
42
50
|
code_schema.dig(media_type) ||
|
43
51
|
raise(Error, "OpenAPI documentation does not have a documented response"\
|
44
52
|
" for #{media_type} media-type at path #{method.upcase} #{path_key}")
|
@@ -86,11 +94,16 @@ module OpenapiValidator
|
|
86
94
|
end
|
87
95
|
|
88
96
|
def build_fragment
|
89
|
-
|
90
|
-
@fragment_path
|
91
|
-
|
92
|
-
|
93
|
-
|
97
|
+
fragment =
|
98
|
+
if @fragment_path
|
99
|
+
@fragment_path.split("/")
|
100
|
+
else
|
101
|
+
["#", "paths", path_key, method, "responses", @schema_code]
|
102
|
+
end
|
103
|
+
|
104
|
+
fragment += ["content", media_type, "schema"] unless @empty_schema
|
105
|
+
|
106
|
+
fragment
|
94
107
|
end
|
95
108
|
end
|
96
109
|
end
|
@@ -22,7 +22,13 @@ module OpenapiValidator
|
|
22
22
|
if request.code != code.to_s
|
23
23
|
@errors << "Path #{request.path} did not respond with expected status code. Expected #{request.code} got #{code}"
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
|
+
if path_validator.empty_schema?
|
27
|
+
@errors << "Path #{request.path} should return empty response." unless body.empty?
|
28
|
+
else
|
29
|
+
@errors += JSON::Validator.fully_validate(validator.api_doc, body, fragment: path_validator.fragment)
|
30
|
+
end
|
31
|
+
|
26
32
|
validator.remove_validated_path(path_validator.path) if @errors.empty?
|
27
33
|
self
|
28
34
|
end
|
@@ -39,9 +39,12 @@ module OpenapiValidator
|
|
39
39
|
|
40
40
|
# @return [Array]
|
41
41
|
def build_unvalidated_requests
|
42
|
+
http_methods = %w[get put post delete options head patch trace]
|
42
43
|
requests = []
|
43
44
|
api_doc["paths"] && api_doc["paths"].each do |path, methods|
|
44
45
|
methods.each do |method, values|
|
46
|
+
next unless http_methods.include?(method)
|
47
|
+
|
45
48
|
values["responses"] && values["responses"].each_key do |code|
|
46
49
|
requests << [path, method, code]
|
47
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Svyatoslav Kryukov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -86,7 +86,7 @@ files:
|
|
86
86
|
- lib/openapi_validator/request_validator.rb
|
87
87
|
- lib/openapi_validator/validator.rb
|
88
88
|
- lib/openapi_validator/version.rb
|
89
|
-
homepage: https://github.com/
|
89
|
+
homepage: https://github.com/medsolutions/openapi_validator
|
90
90
|
licenses:
|
91
91
|
- MIT
|
92
92
|
metadata: {}
|