Sha256: e438569f85ce2b9c4140c53b3cfacb92f0aa16db59b1661868a8e11f789440d9

Contents?: true

Size: 848 Bytes

Versions: 7

Compression:

Stored size: 848 Bytes

Contents

module SoberSwag
  module Reporting
    module Input
      ##
      # Node for things with descriptions.
      # This describes the *type*, not the *object key*.
      class Described < Base
        def initialize(input, description)
          @input = input
          @description = description
        end

        ##
        # @return [Interface] base input
        attr_reader :input

        ##
        # @return [String] description of input
        attr_reader :description

        def call(value)
          input.call(value)
        end

        def swagger_schema
          val, other = input.swagger_schema
          merged =
            if val.key?(:$ref)
              { allOf: [val] }
            else
              val
            end.merge(description: description)
          [merged, other]
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sober_swag-0.25.2 lib/sober_swag/reporting/input/described.rb
sober_swag-0.25.1 lib/sober_swag/reporting/input/described.rb
sober_swag-0.25.0 lib/sober_swag/reporting/input/described.rb
sober_swag-0.24.1 lib/sober_swag/reporting/input/described.rb
sober_swag-0.24.0 lib/sober_swag/reporting/input/described.rb
sober_swag-0.23.0 lib/sober_swag/reporting/input/described.rb
sober_swag-0.22.0 lib/sober_swag/reporting/input/described.rb