-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I noticed, that there are many attributes defined in the openapi specification file which are not accessible through the ruby models. As a user of this gem I would like to be able to access all attributes from the API response though.
The match_open_api_definition matcher can be used to show the difference like this:
RSpec::Matchers.define :match_open_api_definition do |scope, model, options = {}|
# [...]
match do |actual_model|
return false if model_node.nil?
model_attributes = defined_attributes(actual_model)
(model_attributes - specified_attributes | specified_attributes - model_attributes).empty?
end
failure_message do |actual_model|
if model_node.nil?
<<~MESSAGE
Specification not found for #{actual_model}. I was looking for: #{schema_path}. Available specifications:
#{schemas.keys}
MESSAGE
else
<<~MESSAGE
expected that the model #{actual_model} would only define attributes defined in the open_api definition, but there are attributes in the model that are not in the specification.
The attributes which are used in the model but which are not in the specification are:
#{(defined_attributes(actual_model) - specified_attributes).sort}
The attributes which are not used in the model but which are in the specification are:
#{(specified_attributes - defined_attributes(actual_model)).sort}
The attributes defined in the model are:
#{defined_attributes(actual_model).sort}
The attributes defined in the specification are:
#{specified_attributes.sort}
MESSAGE
end
end
endMetadata
Metadata
Assignees
Labels
No labels