class Swaggable::CheckRequestContentType

Attributes

endpoint[R]
request[R]

Public Class Methods

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

Private Instance Methods

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

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