14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/apipie/generator/swagger/param_description/composite.rb', line 14
def to_swagger
return if @param_descriptions.blank?
@param_descriptions.each do |param_description|
validate(param_description)
if param_description.required
@required_params.push(param_description.name.to_sym)
end
param_type = Apipie::Generator::Swagger::TypeExtractor.
new(param_description.validator).
has_nested_params = param_type == 'object' &&
param_description.validator.params_ordered.present?
if has_nested_params
schema = Apipie::Generator::Swagger::ParamDescription::Composite.new(
param_description.validator.params_ordered,
Apipie::Generator::Swagger::Context.new(
allow_null: @context.allow_null?,
http_method: @context.http_method,
controller_method: @context.controller_method
)
).to_swagger
return if schema.blank?
if param_description.additional_properties
schema[:additionalProperties] = true
end
if param_description.is_array?
schema = for_array(schema)
end
if @context.allow_null?
schema = with_null(schema)
end
if schema.present?
@schema[:properties][param_description.name.to_sym] = schema
end
else
param_entry = Apipie::Generator::Swagger::ParamDescription::Builder.
new(
param_description,
in_schema: @context.in_schema?,
controller_method: @context.controller_method
).
with_description(language: @context.language).
with_type(with_null: @context.allow_null?).
with_in(
default_in_value: @context.default_in_value,
http_method: @context.http_method
).
to_swagger
@schema[:properties][param_description.name.to_sym] = param_entry
end
end
if !Apipie.configuration.generator.swagger.allow_additional_properties_in_response
@schema[:additionalProperties] = false
end
if @required_params.length > 0
@schema[:required] = @required_params
end
@schema
end
|