Sha256: 0320804465646db65e7393a826e564d749379107d6629819173bb0e1bffda949

Contents?: true

Size: 805 Bytes

Versions: 7

Compression:

Stored size: 805 Bytes

Contents

module SoberSwag
  module Reporting
    module Input
      ##
      # Specify that something must match a particular format.
      # Note: said format is just a string.
      class Format < Base
        def initialize(input, format)
          @input = input
          @format = format
        end

        ##
        # @return [Interface]
        attr_reader :input

        ##
        # @return [String]
        attr_reader :format

        def call(object)
          input.call(object)
        end

        def swagger_schema
          schema, found = input.swagger_schema

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