Skip to content

Commit 59995c2

Browse files
committed
Support Decimal
1 parent f1c7577 commit 59995c2

3 files changed

Lines changed: 4 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Ecto type | JSON type
102102
:---------------------- | :--------------------
103103
`:integer` | `integer`
104104
`:float` | `number`
105+
`:decimal` | `number`
105106
`:boolean` | `boolean`
106107
`:string` | `string`
107108
`:map` | `object`

lib/schemecto.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ defmodule Schemecto do
280280
defp do_type_to_json_schema(:string), do: %{"type" => "string"}
281281
defp do_type_to_json_schema(:integer), do: %{"type" => "integer"}
282282
defp do_type_to_json_schema(:float), do: %{"type" => "number"}
283+
defp do_type_to_json_schema(:decimal), do: %{"type" => "number"}
283284
defp do_type_to_json_schema(:boolean), do: %{"type" => "boolean"}
284285
defp do_type_to_json_schema(:map), do: %{"type" => "object"}
285286

test/schemecto_test.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ defmodule SchemectoTest do
426426
%{name: :name, type: :string},
427427
%{name: :age, type: :integer},
428428
%{name: :score, type: :float},
429+
%{name: :price, type: :decimal},
429430
%{name: :active, type: :boolean},
430431
%{name: :metadata, type: :map},
431432
%{name: :tags, type: {:array, :string}},
@@ -442,6 +443,7 @@ defmodule SchemectoTest do
442443
"name" => %{"type" => "string"},
443444
"age" => %{"type" => "integer"},
444445
"score" => %{"type" => "number"},
446+
"price" => %{"type" => "number"},
445447
"active" => %{"type" => "boolean"},
446448
"metadata" => %{"type" => "object"},
447449
"tags" => %{"type" => "array", "items" => %{"type" => "string"}},

0 commit comments

Comments
 (0)