Sha256: 3e326dd528c8cdf6c941cdc5c79f0105883da56f119cc0c8c722e810e6a77a57

Contents?: true

Size: 874 Bytes

Versions: 2

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

module WeakSwaggerParameters
  module Definitions
    class Body
      include WeakSwaggerParameters::Definitions::PropertyContainer

      def initialize(&block)
        instance_eval(&block) if block.present?
      end

      def apply_validations(parent_node)
        child_definitions.each { |definition| definition.apply_validations(parent_node) }
      end

      def apply_docs(parent_node)
        param_definitions = child_definitions
        schema_options = {}
        schema_options[:required] = required_fields unless required_fields.empty?

        parent_node.instance_eval do
          parameter name: :body, in: :body, required: true do
            schema schema_options do
              param_definitions.each { |definition| definition.apply_docs(self) }
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
weak_swagger_parameters-0.6.0 lib/weak_swagger_parameters/definitions/body.rb
weak_swagger_parameters-0.5.0 lib/weak_swagger_parameters/definitions/body.rb