File tree 3 files changed +21
-3
lines changed
3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,24 @@ def model_parsers
18
18
end
19
19
end
20
20
autoload :Rake , 'grape-swagger/rake/oapi_tasks'
21
+
22
+ # Copied from https://github.com/ruby-grape/grape/blob/v2.2.0/lib/grape/formatter.rb
23
+ FORMATTER_DEFAULTS = {
24
+ json : Grape ::Formatter ::Json ,
25
+ jsonapi : Grape ::Formatter ::Json ,
26
+ serializable_hash : Grape ::Formatter ::SerializableHash ,
27
+ txt : Grape ::Formatter ::Txt ,
28
+ xml : Grape ::Formatter ::Xml
29
+ } . freeze
30
+
31
+ # Copied from https://github.com/ruby-grape/grape/blob/v2.2.0/lib/grape/content_types.rb
32
+ CONTENT_TYPE_DEFAULTS = {
33
+ xml : 'application/xml' ,
34
+ serializable_hash : 'application/json' ,
35
+ json : 'application/json' ,
36
+ binary : 'application/octet-stream' ,
37
+ txt : 'text/plain'
38
+ } . freeze
21
39
end
22
40
23
41
module SwaggerRouting
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ class << self
7
7
def call ( *args )
8
8
return [ 'application/json' ] unless args . flatten . present?
9
9
10
- args . flatten . map { |x | Grape :: ContentTypes :: CONTENT_TYPES [ x ] || x } . uniq
10
+ args . flatten . map { |x | GrapeSwagger :: CONTENT_TYPE_DEFAULTS [ x ] || x } . uniq
11
11
end
12
12
end
13
13
end
Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ def content_types_for(target_class)
11
11
12
12
if content_types . empty?
13
13
formats = [ target_class . format , target_class . default_format ] . compact . uniq
14
- formats = Grape :: Formatter . formatters ( ** { } ) . keys if formats . empty?
15
- content_types = Grape :: ContentTypes :: CONTENT_TYPES . select do |content_type , _mime_type |
14
+ formats = GrapeSwagger :: FORMATTER_DEFAULTS . keys if formats . empty?
15
+ content_types = GrapeSwagger :: CONTENT_TYPE_DEFAULTS . select do |content_type , _mime_type |
16
16
formats . include? content_type
17
17
end . values
18
18
end
You can’t perform that action at this time.
0 commit comments