Class: Apivore::SwaggerChecker
- Inherits:
-
Object
- Object
- Apivore::SwaggerChecker
- Defined in:
- lib/apivore/swagger_checker.rb
Constant Summary collapse
- PATH_TO_CHECKER_MAP =
{}
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
-
#swagger ⇒ Object
readonly
Returns the value of attribute swagger.
-
#swagger_path ⇒ Object
readonly
Returns the value of attribute swagger_path.
-
#untested_mappings ⇒ Object
readonly
Returns the value of attribute untested_mappings.
Class Method Summary collapse
Instance Method Summary collapse
- #base_path ⇒ Object
- #fragment(path, method, code) ⇒ Object
- #has_matching_document_for(path, method, code, body) ⇒ Object
- #has_method_at_path?(path, method) ⇒ Boolean
- #has_path?(path) ⇒ Boolean
- #has_response_code_for_path?(path, method, code) ⇒ Boolean
- #remove_tested_end_point_response(path, method, code) ⇒ Object
- #response_codes_for_path(path, method) ⇒ Object
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
56 57 58 |
# File 'lib/apivore/swagger_checker.rb', line 56 def response @response end |
#swagger ⇒ Object (readonly)
Returns the value of attribute swagger.
56 57 58 |
# File 'lib/apivore/swagger_checker.rb', line 56 def swagger @swagger end |
#swagger_path ⇒ Object (readonly)
Returns the value of attribute swagger_path.
56 57 58 |
# File 'lib/apivore/swagger_checker.rb', line 56 def swagger_path @swagger_path end |
#untested_mappings ⇒ Object (readonly)
Returns the value of attribute untested_mappings.
56 57 58 |
# File 'lib/apivore/swagger_checker.rb', line 56 def untested_mappings @untested_mappings end |
Class Method Details
.instance_for(path) ⇒ Object
5 6 7 |
# File 'lib/apivore/swagger_checker.rb', line 5 def self.instance_for(path) PATH_TO_CHECKER_MAP[path] ||= new(path) end |
Instance Method Details
#base_path ⇒ Object
48 49 50 |
# File 'lib/apivore/swagger_checker.rb', line 48 def base_path @swagger.base_path end |
#fragment(path, method, code) ⇒ Object
31 32 33 34 |
# File 'lib/apivore/swagger_checker.rb', line 31 def fragment(path, method, code) path_fragment = mappings[path][method.to_s][code.to_s] path_fragment.dup unless path_fragment.nil? end |
#has_matching_document_for(path, method, code, body) ⇒ Object
25 26 27 28 29 |
# File 'lib/apivore/swagger_checker.rb', line 25 def has_matching_document_for(path, method, code, body) JSON::Validator.fully_validate( swagger, body, fragment: fragment(path, method, code) ) end |
#has_method_at_path?(path, method) ⇒ Boolean
13 14 15 |
# File 'lib/apivore/swagger_checker.rb', line 13 def has_method_at_path?(path, method) mappings[path].has_key?(method) end |
#has_path?(path) ⇒ Boolean
9 10 11 |
# File 'lib/apivore/swagger_checker.rb', line 9 def has_path?(path) mappings.has_key?(path) end |
#has_response_code_for_path?(path, method, code) ⇒ Boolean
17 18 19 |
# File 'lib/apivore/swagger_checker.rb', line 17 def has_response_code_for_path?(path, method, code) mappings[path][method].has_key?(code.to_s) end |
#remove_tested_end_point_response(path, method, code) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/apivore/swagger_checker.rb', line 36 def remove_tested_end_point_response(path, method, code) return if untested_mappings[path].nil? || untested_mappings[path][method].nil? untested_mappings[path][method].delete(code.to_s) if untested_mappings[path][method].size == 0 untested_mappings[path].delete(method) if untested_mappings[path].size == 0 untested_mappings.delete(path) end end end |
#response_codes_for_path(path, method) ⇒ Object
21 22 23 |
# File 'lib/apivore/swagger_checker.rb', line 21 def response_codes_for_path(path, method) mappings[path][method].keys.join(", ") end |