Validating response body not working on nested object properties
jasonsof opened this issue · comments
Jason commented
Hi! I encountered this issue while using the Committee gem but I am experiencing it directly using openapi_parser too
I'm attempting to validate a response conforms to an openapi schema like so:
it "conforms to response schema with 200 response code" do
root = OpenAPIParser.parse(YAML.load_file('schemas/posts.json'))
request_operation = root.request_operation(:get, '/posts')
actual_response = [
{
idd: 1,
title: 'Post 1'
}
]
request_operation.validate_response_body(OpenAPIParser::RequestOperation::ValidatableResponseBody.new(200, actual_response, {}), OpenAPIParser::SchemaValidator::ResponseValidateOptions.new(strict: false, validate_header: false))
end
As you can see there is typo in the actual_response
I would expect validate_response_body
to raise an exception but it simply returns nil
, full schema.json is here
Am I using incorrectly or is this a bug?
Working example here here
Jason commented
Was missing a required specification for the response properties 🤦
"Post": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"title": {
"type": "string"
}
},
"required": [
"id",
"title"
]
}