Sha256: 535000250d20477a6dd4b550c63016a558ce3316d9a89d253c1baf7c90bc63f3

Contents?: true

Size: 923 Bytes

Versions: 7

Compression:

Stored size: 923 Bytes

Contents

module SoberSwag
  module Reporting
    module Output
      ##
      # Referenced: An input that will be referred to via reference in the
      # final schema.
      class Referenced < Base
        def initialize(output, reference)
          @output = output
          @reference = reference
        end

        ##
        # @return [Interface] the actual output type to use
        attr_reader :output

        ##
        # @return [String] key in the components hash
        attr_reader :reference

        def call(input)
          output.call(input)
        end

        def serialize_report(input)
          output.serialize_report(input)
        end

        def ref_path
          "#/components/schemas/#{reference}"
        end

        def swagger_schema
          [
            { "$ref": ref_path },
            { reference => proc { output.swagger_schema } }
          ]
        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/referenced.rb
sober_swag-0.25.1 lib/sober_swag/reporting/output/referenced.rb
sober_swag-0.25.0 lib/sober_swag/reporting/output/referenced.rb
sober_swag-0.24.1 lib/sober_swag/reporting/output/referenced.rb
sober_swag-0.24.0 lib/sober_swag/reporting/output/referenced.rb
sober_swag-0.23.0 lib/sober_swag/reporting/output/referenced.rb
sober_swag-0.22.0 lib/sober_swag/reporting/output/referenced.rb