8000 GitHub - gridpoint-com/ostara: 🐇 Transforms Ecto schemas into JSON Schemas.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

gridpoint-com/ostara

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ostara

Contributor Covenant

Transforms Ecto schema modules into JSON Schema structures.

Ostara by Johannes Gehrts

Ostara (1901) by Johannes Gehrts

Note: Ostara is under active development and does not yet support all features of Ecto or the full JSON Schema specification. Contributions are welcome!

Example

Given the following schema module:

defmodule Product do
  @moduledoc "A product from Acme's catalog"
  use Ecto.Schema

  @primary_key false

  embedded_schema do
    field :product_name, :string
    field :price, :float
  end

  def changeset(data, params) do
    data
    |> cast(params, [:product_name, :price])
    |> validate_required([:product_name])
    |> validate_number(:price, greater_than: 0)
  end
end

Ostara will produce the following JSON data:

%{
  "$schema" => "https://json-schema.org/draft/2020-12/schema",
  "$id" => "product",
  "title" => "Product",
  "type" => "object",
  "description" => "A product from Acme's catalog",
  "properties" => %{
    "product_name" => %{
      "type" => "string"
    },
    "price" => %{
      "type" => "number",
      "exclusiveMinimum" => 0
    }
  },
  "required" => ["product_name"]
}

Installation

Ostara is available in Hex and can be installed by adding ostara to your list of dependencies in mix.exs:

def deps do
  [
    {:ostara, "~> 0.4.0"}
  ]
end

License

Ostara source code is released under Apache License 2.0. See LICENSE for more information.

About

🐇 Transforms Ecto schemas into JSON Schemas.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages

0