Sha256: f2c2784623de757e5186d5bcada271c66406c0461f41e062216d02845a3247e5

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

module SoberSwag
  module Reporting
    module Output
      class Object
        ##
        # Definitions for a specific property of an object.
        class Property
          def initialize(output, description: nil)
            @output = output
            @description = description
          end
          ##
          # @return [Interface]
          attr_reader :output

          ##
          # @return [String,nil]
          attr_reader :description

          def call(item, view: :base)
            output.call(item, view: view)
          end

          def property_schema
            direct, refined = output.swagger_schema

            if description
              [add_description(direct), refined]
            else
              [direct, refined]
            end
          end

          def add_description(dir)
            if dir.key?(:$ref)
              { allOf: [dir] }
            else
              dir
            end.merge(description: description)
          end
        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/object/property.rb
sober_swag-0.25.1 lib/sober_swag/reporting/output/object/property.rb
sober_swag-0.25.0 lib/sober_swag/reporting/output/object/property.rb
sober_swag-0.24.1 lib/sober_swag/reporting/output/object/property.rb
sober_swag-0.24.0 lib/sober_swag/reporting/output/object/property.rb
sober_swag-0.23.0 lib/sober_swag/reporting/output/object/property.rb
sober_swag-0.22.0 lib/sober_swag/reporting/output/object/property.rb