Skip to content

Commit f1c7577

Browse files
committed
Document known types
1 parent f4bf2a4 commit f1c7577

1 file changed

Lines changed: 28 additions & 9 deletions

File tree

README.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
Schemecto provides schemaless Ecto changesets with support for nested schemaless changesets and JSON Schema generation.
44

5+
## Installation
6+
7+
Add `schemecto` to your dependencies in `mix.exs`:
8+
9+
```elixir
10+
def deps do
11+
[
12+
{:schemecto, github: "josevalim/schemecto"}
13+
]
14+
end
15+
```
16+
517
## Usage
618

719
Define fields and validation functions for your data structures:
@@ -84,17 +96,24 @@ The generated schema includes field metadata, required fields, format patterns,
8496
}
8597
```
8698

87-
## Installation
99+
## Supported types
88100

89-
Add `schemecto` to your dependencies in `mix.exs`:
101+
Ecto type | JSON type
102+
:---------------------- | :--------------------
103+
`:integer` | `integer`
104+
`:float` | `number`
105+
`:boolean` | `boolean`
106+
`:string` | `string`
107+
`:map` | `object`
108+
`{:array, type}` | `array` of `type`
109+
`{:array, :any}` | `array` of `object`
110+
`Ecto.Enum` of `type | `enum` of `type`
90111

91-
```elixir
92-
def deps do
93-
[
94-
{:schemecto, github: "josevalim/schemecto"}
95-
]
96-
end
97-
```
112+
Custom Ecto types and parameterized types are also supported as long as
113+
they emit one of the types above. More types can be added in the future too.
114+
115+
`Schemecto.one/2` and `Schemecto.many/2` should be preferred instead of
116+
`:map` when the fields are known upfront.
98117

99118
## License
100119

0 commit comments

Comments
 (0)