class OpenAPIParser::Schemas::Response
Public Instance Methods
select_media_type(content_type)
click to toggle source
select media type by content_type (consider wild card definition) @param [String] content_type @return [OpenAPIParser::Schemas::MediaType, nil]
# File lib/openapi_parser/schemas/response.rb, line 36 def select_media_type(content_type) select_media_type_from_content(content_type, content) end
validate(response_body, response_validate_options)
click to toggle source
@param [OpenAPIParser::RequestOperation::ValidatableResponseBody] response_body @param [OpenAPIParser::SchemaValidator::ResponseValidateOptions] response_validate_options
# File lib/openapi_parser/schemas/response.rb, line 19 def validate(response_body, response_validate_options) validate_header(response_body.headers) if response_validate_options.validate_header media_type = select_media_type(response_body.content_type) unless media_type raise ::OpenAPIParser::NotExistContentTypeDefinition, object_reference if response_validate_options.strict return nil end options = ::OpenAPIParser::SchemaValidator::Options.new # response validator not support any options media_type.validate_parameter(response_body.response_data, options) end
Private Instance Methods
validate_header(response_headers)
click to toggle source
@param [Hash] response_headers
# File lib/openapi_parser/schemas/response.rb, line 43 def validate_header(response_headers) return unless headers headers.each do |name, schema| next unless response_headers.key?(name) value = response_headers[name] schema.validate(value) end end