Sha256: 0f40a5789d19c65a78b0985af796b177de0e8cead997658ec845759c717f4c39

Contents?: true

Size: 650 Bytes

Versions: 1

Compression:

Stored size: 650 Bytes

Contents

module Finitio
  module JsonSchema

    BUILTIN_MAPPING = {
      NilClass => "null",
      String => "string",
      Integer => "integer",
      Fixnum => "integer",
      Bignum => "integer",
      Float => "number",
      Numeric => "number",
      TrueClass => "boolean",
      FalseClass => "boolean",
      Object => "object"
    }

  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

1 entries across 1 versions & 1 rubygems

Version Path
finitio-0.11.1 lib/finitio/json_schema/builtin_type.rb