From 445dabea8fbdf76fa57a1cfd4e0c09604a49c515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Utka=C5=82a?= Date: Mon, 2 Sep 2024 08:34:26 +0200 Subject: [PATCH] Refactor Endpoint#content_types_for to use Grape::ContentTypes::DEFAULTS --- lib/grape-swagger/doc_methods/produces_consumes.rb | 2 +- lib/grape-swagger/endpoint.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/grape-swagger/doc_methods/produces_consumes.rb b/lib/grape-swagger/doc_methods/produces_consumes.rb index 3359e4b6..eafd3f28 100644 --- a/lib/grape-swagger/doc_methods/produces_consumes.rb +++ b/lib/grape-swagger/doc_methods/produces_consumes.rb @@ -7,7 +7,7 @@ class << self def call(*args) return ['application/json'] unless args.flatten.present? - args.flatten.map { |x| Grape::ContentTypes::CONTENT_TYPES[x] || x }.uniq + args.flatten.map { |x| Grape::ContentTypes::DEFAULTS[x] || x }.uniq end end end diff --git a/lib/grape-swagger/endpoint.rb b/lib/grape-swagger/endpoint.rb index dd93f864..c139850d 100644 --- a/lib/grape-swagger/endpoint.rb +++ b/lib/grape-swagger/endpoint.rb @@ -12,7 +12,7 @@ def content_types_for(target_class) if content_types.empty? formats = [target_class.format, target_class.default_format].compact.uniq formats = Grape::Formatter.formatters(**{}).keys if formats.empty? - content_types = Grape::ContentTypes::CONTENT_TYPES.select do |content_type, _mime_type| + content_types = Grape::ContentTypes::DEFAULTS.select do |content_type, _mime_type| formats.include? content_type end.values end