Generates Elm types, JSON decoders, JSON encoders and fuzz tests from JSON schema specifications
preamble.elm.eex
by removing all function imports and instead making qualified function calls, e.g. succeed
becomes Decode.succeed
in Elm decoders, and similarly for all other library calls expect the decode pipeline calls.Util.elm
to Encode.elm
and removes function imports turning calls such as encodeRequired
into Encode.required
.enumDecoder
calls a dedicated parseEnum
function making it easier to reuse the parseEnum
in other contexts..tool-versions
, package.json
and elm.json
files.typed_struct
and also adds a proper error_type
union type.elm_{types,decoders,encoders,fuzzers}.ex
util modules.js2e
now requires input JSON schema files to have schema version set to draft v7.json_schema
dependency to v0.2.0
which has breaking changes as it perform a much needed overhaul of how references are handled by the parser such that both local and global references are now handled with the URI
type.'JSON schema to Elm' now generates Elm 0.19 compatible code. No option has been added for generating backwards compatible code to Elm 0.18, so this is a breaking change for the generated code.
Adds fuzz tests to the generated Elm output and now also generates a slightly more elaborate directory structure, see README.md
, allowing the user to much easier test that the generated decoders and encoders behave as expected before merging them into their existing project.
Reduces the noise when referencing qualified Elm types and functions across modules in the generated files by using import Data.Foo as Foo
statements.
all_of
/ any_of
support, and a large refactoringprinter/util.ex
into a new
printer/utils
folder,Naming.normalize_identifier()
function
before sending identifier names to Elm code templates, andFixes and refactors the allOf
and anyOf
printers, such that they produce correct Elm code for decoding and encoding all_of
and any_of
JSON schema nodes.
Adds contexts 'parser' and 'printer'
We isolate all parser related code in the parser
folder and expose the
parser.ex
module as the interface for that folder / context.
We repeat this exercise for the printer
folder / context.
Furthermore, we remove all the import statements and replace them with more explicit aliases.
Splits the JS2E.Printer.Util
module into a whole printer/utils
folder in order to increase cohesion, i.e. have one util module per relevant
area of printing.
Fixes all dialyzer errors except for allOf/anyOf/oneOf printers
Improves documentation
README.md
to include a section on js2e
error reporting, andCONTRIBUTING.md
file, detailing what potential contributors should
know before filing issues/PRs.Adds Elixir 1.6 support.
Adds Elm-style error reporting and adds a TupleType
.
ParserResult
and PrinterResult
types, which encapsulate the result of parsing/printing a schema and any warnings/errors encountered along the way,TypePath
s were missing 'properties', 'anyOf', 'items', etc. values.First working version, implements most of the JSON schema spec that makes sense. Converts JSON schema files into Elm types and JSON decoders.
Adds JSON Encoders to the set of outputted Elm definitions.