Releases: dragonwasrobot/json-schema-to-elm
Anonymous schema nodes and improved intermediate representation
Changed
- Simplifies
preamble.elm.eex
by removing all function imports and instead making qualified function calls, e.g.succeed
becomesDecode.succeed
in Elm decoders, and similarly for all other library calls expect the decode pipeline calls. - Renames
Util.elm
toEncode.elm
and removes function imports turning calls such asencodeRequired
intoEncode.required
. - Splits the parsing and decoding for enums into two so the
enumDecoder
calls a dedicatedparseEnum
function making it easier to reuse theparseEnum
in other contexts. - Updates dependencies in the generated
.tool-versions
,package.json
andelm.json
files. - Now inlines anonymous schema nodes in the generated Elm code to reduce the number of scenarios where we have to auto-generate type names like 'zero' and 'one'.
Fixed / Improved
- Updates elixir, erlang, mix project and dependency versions.
- Updates README with updated example output code.
- Updates example input/output files.
- Migrates all types to use
typed_struct
and also adds a propererror_type
union type. - Now uses proper static URL pointers to JSON schema standards in the generated error messages to reduce risk of these returning 404s in the future.
- Adds: Github action to build and test the code.
- Cleans: major refactoring of the code structure such that the EEx templates correspond to the different output types, e.g. product types, sum decoders, list fuzzers, etc., rather than the different input types, e.g. array, object, oneOf, etc.
- Cleans: related to the above point, all the different output elm types/decoders/encoders/fuzzers now have proper type specifications in the
elm_{types,decoders,encoders,fuzzers}.ex
util modules.
Various bug fixes
Adds
- travis-ci integration and 'build status' icon.
Fixes
- Various printer bugs and updates
json_schema
version.
JSON schema draft v7 and referencing overhaul
Changed
js2e
now requires input JSON schema files to have schema version set to draft v7.- Updated
json_schema
dependency tov0.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 theURI
type.
Elm 0.19
'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.
Fuzz tests
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.
Sanitised identifiers + all_of/any_of support
Sanitise identifiers, better all_of
/ any_of
support, and a large refactoring
- Sanitises / Elmifies JSON schema identifiers, such that the Elm code output is valid Elm
- Moves indentation- and naming-specific logic from
printer/util.ex
into a new
printer/utils
folder, - adjusts all printers to now use the
Naming.normalize_identifier()
function
before sending identifier names to Elm code templates, and - adds tests for the 'sanitise identifier' feature.
-
Fixes and refactors the
allOf
andanyOf
printers, such that they produce correct Elm code for decoding and encodingall_of
andany_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 wholeprinter/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
- Updates 'allOf' and 'anyOf' type descriptions to reflect new Elm
decoders/encoders, - updates
README.md
to include a section onjs2e
error reporting, and - creates a
CONTRIBUTING.md
file, detailing what potential contributors should
know before filing issues/PRs.
v2.4.0: 'Elixir 1.6' + 'JSON schema draft 6'
Adds Elixir 1.6 support.
- Elixir 1.6 contains a breaking change when parsing URIs, which has been taken care of.
- json-schema-to-elm now support json-schema draft version 6.
- default module name changed to 'Data'.
- json-schema-to-elm now uses mix formatter.
- minor bug fixes.
v2.3.0: Elm-style errors and Tuple types
Adds Elm-style error reporting and adds a TupleType
.
- Streamlines error handling across all files using
ParserResult
andPrinterResult
types, which encapsulate the result of parsing/printing a schema and any warnings/errors encountered along the way, - adds parser and printer error util modules for pretty printing errors,
- moves the logic from Predicates.ex into their respective parser files,
- moves schema version logic into its own module, and
- splits most of parser.ex into root parser and parser util.
- Adds support for parsing tuple types (see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.9).
- Fixes a bug where
TypePath
s were missing 'properties', 'anyOf', 'items', etc. values.
v2.2.0: Qualified references (#43)
Closes #39 by adding fully qualified names in the generated Elm code when referencing definitions from other modules. * Adds 'module' to schema definitions, * passes the schema definition context - instead of the type dictionary - to each printer function, * uses fully qualified names when referencing types, encoders and decoders from other modules in the generated Elm code, * removes the explicit import of types, decoders and encoders from other modules in the generated Elm code. Now just import the module and nothing else, * adds support for the 'title' property in the schema root object, * removes some code redundancy, and * updates readme with new elm output.
v2.1.0: 'anyOf' and 'allOf' support
Adds support for the anyOf
and allOf
types.