Class: Skooma::Objects::OpenAPI::Keywords::Paths
- Inherits:
-
JSONSkooma::Keywords::Base
- Object
- JSONSkooma::Keywords::Base
- Skooma::Objects::OpenAPI::Keywords::Paths
- Defined in:
- lib/skooma/objects/openapi/keywords/paths.rb
Constant Summary collapse
- ROUTE_REGEXP =
/\{([^}]+)}/.freeze
Instance Method Summary collapse
- #evaluate(instance, result) ⇒ Object
-
#initialize(parent_schema, value) ⇒ Paths
constructor
A new instance of Paths.
Constructor Details
#initialize(parent_schema, value) ⇒ Paths
Returns a new instance of Paths.
14 15 16 |
# File 'lib/skooma/objects/openapi/keywords/paths.rb', line 14 def initialize(parent_schema, value) super end |
Instance Method Details
#evaluate(instance, result) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/skooma/objects/openapi/keywords/paths.rb', line 18 def evaluate(instance, result) path, attributes, path_schema = find_route(instance["path"]) return result.failure("Path #{instance["path"]} not found in schema") unless path result.annotate({"current_path" => path}) result.call(instance, path) do |subresult| subresult.annotate({"path_attributes" => attributes}) path_schema.evaluate(instance, subresult) if subresult.passed? && subresult.children.any? result.success else result.failure("Path #{instance["path"]} is invalid") end end end |