Sha256: 87049dc2a31dbf5ac9743b2d1c55b51457cdb8ddece26f9b5a967d179672263b

Contents?: true

Size: 563 Bytes

Versions: 3

Compression:

Stored size: 563 Bytes

Contents

module Finitio
  module JsonSchema

    BUILTIN_MAPPING = {
      NilClass => "null",
      String => "string",
      Integer => "integer",
      Fixnum => "integer",
      Bignum => "integer",
      Float => "number",
      Numeric => "number"
    }

  end
  class BuiltinType

    def to_json_schema(*args, &bl)
      mapped = JsonSchema::BUILTIN_MAPPING[ruby_type]
      if mapped
        { type: mapped }
      else
        raise JsonSchema::Error, "Unable to map #{ruby_type} to json-schema"
      end
    end

  end # class BuiltinType
end # module Finitio

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
finitio-0.10.0 lib/finitio/json_schema/builtin_type.rb
finitio-0.9.1 lib/finitio/json_schema/builtin_type.rb
finitio-0.9.0 lib/finitio/json_schema/builtin_type.rb