Sha256: 4304c6787668c9a3bc3dfc0d28cb9fce2f8efdaa647e0c95d80a55485f9ba8b8

Contents?: true

Size: 909 Bytes

Versions: 7

Compression:

Stored size: 909 Bytes

Contents

module SoberSwag
  module Reporting
    module Output
      ##
      # Add a description onto an object.
      class Described < Base
        def initialize(output, description)
          @output = output
          @description = description
        end

        ##
        # @return [Interface] output to describe
        attr_reader :output

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

        def call(value)
          output.call(value)
        end

        def serialize_report(value)
          output.serialize_report(value)
        end

        def swagger_schema
          schema, found = output.swagger_schema

          merged =
            if schema.key?(:$ref)
              { allOf: [schema] }
            else
              schema
            end.merge(description: description)
          [merged, found]
        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/output/described.rb
sober_swag-0.25.1 lib/sober_swag/reporting/output/described.rb
sober_swag-0.25.0 lib/sober_swag/reporting/output/described.rb
sober_swag-0.24.1 lib/sober_swag/reporting/output/described.rb
sober_swag-0.24.0 lib/sober_swag/reporting/output/described.rb
sober_swag-0.23.0 lib/sober_swag/reporting/output/described.rb
sober_swag-0.22.0 lib/sober_swag/reporting/output/described.rb