@@ -4,10 +4,6 @@ module GrapeSwagger
4
4
module DocMethods
5
5
class BuildModelDefinition
6
6
class << self
7
- OBJECT_ATTRIBUTE_KEYS = %i[
8
- $ref type
9
- ] . freeze
10
-
11
7
def build ( _model , properties , required , other_def_properties = { } )
12
8
definition = { type : 'object' , properties : properties } . merge ( other_def_properties )
13
9
@@ -17,10 +13,6 @@ def build(_model, properties, required, other_def_properties = {})
17
13
end
18
14
19
15
def parse_params_from_model ( parsed_response , model , model_name )
20
- # If the parsed response looks like a complete object (e.g., containing `$ref` or `type`),
21
- # it uses the provided response as-is.
22
- return parsed_response if complete_object? ( parsed_response )
23
-
24
16
if parsed_response . is_a? ( Hash ) && parsed_response . keys . first == :allOf
25
17
refs_or_models = parsed_response [ :allOf ]
26
18
parsed = parse_refs_and_models ( refs_or_models , model )
@@ -62,26 +54,14 @@ def parse_properties(properties)
62
54
63
55
def parse_refs_and_models ( refs_or_models , model )
64
56
refs_or_models . map do |ref_or_models |
65
- if complete_object? ( ref_or_models )
57
+ if ref_or_models . is_a? ( Hash ) && ref_or_models . keys . first == '$ref'
66
58
ref_or_models
67
59
else
68
60
properties , required = ref_or_models
69
61
GrapeSwagger ::DocMethods ::BuildModelDefinition . build ( model , properties , required )
70
62
end
71
63
end
72
64
end
73
-
74
- private
75
-
76
- # Checks if the parsed response is already a complete object.
77
- #
78
- # @param parsed_response [Hash] The parsed response to check.
79
- # @return [Boolean] True if the response has object attributes.
80
- def complete_object? ( parsed_response )
81
- return false unless parsed_response . is_a? ( Hash )
82
-
83
- parsed_response . keys . intersect? ( OBJECT_ATTRIBUTE_KEYS )
84
- end
85
65
end
86
66
end
87
67
end
0 commit comments