Skip to content

andreashasse/exdantic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exdantic

Elixir wrapper for the erldantic library, providing type-safe JSON serialization, deserialization, JSON schema generation, and OpenAPI specification generation for Elixir applications.

Features

  • Type-safe JSON conversion - Convert Elixir terms to/from JSON with validation
  • JSON Schema generation - Generate JSON Schema specifications from type definitions
  • OpenAPI specification - Create OpenAPI 3.0 specifications for REST APIs
  • Detailed error reporting - Get precise error messages with location information

Installation

Add exdantic to your list of dependencies in mix.exs:

def deps do
  [
    {:exdantic, git: "https://github.com/andreashasse/exdantic.git"}
  ]
end

Usage

JSON Serialization/Deserialization

# Convert Elixir term to JSON
{:ok, json} = Exdantic.JSON.to_json(MyModule, :user_type, user_data)

# Convert JSON to Elixir term
{:ok, user} = Exdantic.JSON.from_json(MyModule, :user_type, json_data)

JSON Schema Generation

{:ok, schema} = Exdantic.JSONSchema.generate_schema(MyModule, :user_type)

OpenAPI Specification Generation

{:ok, spec} = Exdantic.OpenAPI.generate_spec(MyModule)

Convenience Functions

The main Exdantic module provides delegated functions for easy access:

{:ok, json} = Exdantic.to_json(MyModule, :user_type, user_data)
{:ok, user} = Exdantic.from_json(MyModule, :user_type, json_data)
{:ok, schema} = Exdantic.generate_schema(MyModule, :user_type)
{:ok, spec} = Exdantic.generate_spec(MyModule)

Modules

  • Exdantic.JSON - JSON serialization and deserialization with type validation
  • Exdantic.JSONSchema - JSON schema generation from type definitions
  • Exdantic.OpenAPI - OpenAPI 3.0 specification generation

Requirements

  • Elixir ~> 1.18
  • Erlang/OTP with built-in :json module support
  • erldantic library

License

This project is licensed under the same terms as the underlying erldantic library.

About

Elixir wrapper around erldantic

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages