class PactBroker::Api::Decorators::EmbeddedErrorProblemJsonDecorator
Public Instance Methods
Source
# File lib/pact_broker/api/decorators/embedded_error_problem_json_decorator.rb, line 68 def body_type if represented.text.include?("missing") "problems/missing-body-property" elsif represented.text.include?("format") "problems/invalid-body-property-format" else "problems/invalid-body-property-value" end end
Source
# File lib/pact_broker/api/decorators/embedded_error_problem_json_decorator.rb, line 78 def is_path_error? represented.path.first == :_path end
Source
# File lib/pact_broker/api/decorators/embedded_error_problem_json_decorator.rb, line 33 def parameter if is_path_error? represented.path.last.to_s else nil end end
Source
# File lib/pact_broker/api/decorators/embedded_error_problem_json_decorator.rb, line 58 def path_type if represented.text.include?("missing") "problems/missing-request-parameter" elsif represented.text.include?("format") "problems/invalid-request-parameter-format" else "problems/invalid-request-parameter-value" end end
Source
# File lib/pact_broker/api/decorators/embedded_error_problem_json_decorator.rb, line 22 def pointer if is_path_error? nil # _ops, _path or _body for use when we need to hack the way dry-validation schemas work elsif represented.path.first.to_s.start_with?("_") "/" + represented.path[1..-1].join("/") else "/" + represented.path.join("/") end end
dry-validation doesn’t support validating a top level array, so we wrap the json patch operations array in a hash with the key :_ops to validate it. When we render the error, we have to remove the /_ops prefix from the pointer. For contracts where we validate the path and the body together using _path and _body we also need to remove the first key from the path. It’s possible the pointer should have a # at the start of it as per www.rfc-editor.org/rfc/rfc6901 :shrug:
Source
# File lib/pact_broker/api/decorators/embedded_error_problem_json_decorator.rb, line 41 def title if is_path_error? "Invalid path segment" else "Invalid body parameter" end end
Source
# File lib/pact_broker/api/decorators/embedded_error_problem_json_decorator.rb, line 50 def type(base_url) if is_path_error? "#{base_url}/#{path_type}" else "#{base_url}/#{body_type}" end end
@param [String] base_url