class Swaggable::CheckResponseContentType

Attributes

endpoint[R]
response[R]

Public Class Methods

call(*args) click to toggle source
# File lib/swaggable/check_response_content_type.rb, line 10
def self.call(*args)
  new(*args).send :errors
end
new(args) click to toggle source
# File lib/swaggable/check_response_content_type.rb, line 5
def initialize args
  @endpoint = args.fetch(:endpoint)
  @response = args.fetch(:response)
end

Private Instance Methods

errors() click to toggle source
# File lib/swaggable/check_response_content_type.rb, line 16
def errors
  Errors::ValidationsCollection.new.tap do |errors|
    type = response.content_type

    unless type.nil? || endpoint.produces.include?(type)
      errors << Errors::UnsupportedContentType.new("Content-Type #{type} not supported")
    end
  end
end