def operation_to_h(operation)
hash = {
tags: operation.tags,
summary: operation.summary,
description: operation.description,
responses: {}
}
hash[:deprecated] = true if operation.deprecated?
hash[:operation_id] = operation.id if operation.id?
hash[:consumes] = operation.consumes if operation.consumes?
hash[:produces] = operation.produces if operation.produces?
operation.responses.each do |status, response|
hash[:responses][status] = response_to_h(response)
end
if operation.parameters?
hash[:parameters] = operation.parameters.map do |parameter|
parameter_to_h(parameter)
end
end
hash
end