class Apipie::Generator::Swagger::MethodDescription::ResponseSchemaService
Public Class Methods
new(response_description, allow_null:, http_method:, controller_method:)
click to toggle source
@param [Apipie::ResponseDescription, Apipie::ResponseDescriptionAdapter] response_description
# File lib/apipie/generator/swagger/method_description/response_schema_service.rb, line 3 def initialize(response_description, allow_null:, http_method:, controller_method:) @response_description = response_description @allow_null = allow_null @http_method = http_method @controller_method = controller_method end
Public Instance Methods
to_swagger()
click to toggle source
# File lib/apipie/generator/swagger/method_description/response_schema_service.rb, line 10 def to_swagger composite = Apipie::Generator::Swagger::ParamDescription::Composite.new( @response_description.params_ordered, Apipie::Generator::Swagger::Context.new( allow_null: @allow_null, http_method: @http_method, controller_method: @controller_method ) ) if Apipie.configuration.generator.swagger.responses_use_refs? && @response_description.typename.present? composite = composite.referenced(@response_description.typename) end schema = composite.to_swagger if @response_description.is_array? && schema schema = { type: type_for_array, items: schema } end if @response_description.allow_additional_properties schema[:additionalProperties] = true end schema end
Private Instance Methods
type_for_array()
click to toggle source
# File lib/apipie/generator/swagger/method_description/response_schema_service.rb, line 39 def type_for_array if @allow_null == true %w[array null] else 'array' end end