Json Schema To Elm Versions Save

Generates Elm types, JSON decoders, JSON encoders and fuzz tests from JSON schema specifications

v2.9.0

2 years ago

Changed

  • Simplifies 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.
  • Renames Util.elm to Encode.elm and removes function imports turning calls such as encodeRequired into Encode.required.
  • Splits the parsing and decoding for enums into two so the enumDecoder calls a dedicated parseEnum function making it easier to reuse the parseEnum in other contexts.
  • Updates dependencies in the generated .tool-versions, package.json and elm.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 proper error_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.

v2.8.1

4 years ago

Adds

  • travis-ci integration and 'build status' icon.

Fixes

  • Various printer bugs and updates json_schema version.

v2.8.0

5 years ago

Changed

  • js2e now requires input JSON schema files to have schema version set to draft v7.
  • Updated 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.

v2.7.0

5 years ago

'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.

v2.6.0

5 years ago

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.

v2.5.0

6 years ago

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 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

  • Updates 'allOf' and 'anyOf' type descriptions to reflect new Elm decoders/encoders,
  • updates README.md to include a section on js2e error reporting, and
  • creates a CONTRIBUTING.md file, detailing what potential contributors should know before filing issues/PRs.

v2.4.0

6 years ago

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

6 years ago

Adds Elm-style error reporting and adds a TupleType.

  • Streamlines error handling across all files using ParserResult and PrinterResult 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 TypePaths were missing 'properties', 'anyOf', 'items', etc. values.

v1.0.0

6 years ago

First working version, implements most of the JSON schema spec that makes sense. Converts JSON schema files into Elm types and JSON decoders.

v2.0.0

6 years ago

Adds JSON Encoders to the set of outputted Elm definitions.