relationship to NoRedInk/json-elm-schema
ericgj opened this issue · 2 comments
Wondering if there was any talk of merging these efforts down the line, or if you see the two as having distinct features.
From a quick look, it seems yours is further along in terms of the json-schema spec, and has unicode support; but json-elm-schema has EncodingProgram that enables a node-based CLI for generating JSON from Elm-defined schemas. Did you have any plans to do JSON Schema generation like this? It shouldn't be too hard I guess since you do have Json.Schema.Builder.encode. Maybe I'll give it a try.
I do like the fact that your library has less dependencies, and seems to have support for "tuple typing" (that's the difference between withItem and withItems yes?), and building $refs.
EDIT: I now see Json.Schema.Builder.encode generates Elm, not JSON. So my question remains, any plans to do JSON generation? It is a key feature in my case, where I want the canonical representation to be in Elm and to generate the JSON files for the server side, rather than the other way around.
if there was any talk of merging these efforts
There's currently no such conversation going. I guess at some point we should be starting one.
any plans to do JSON generation
Are you talking about serialising Schema as JSON value? There's Json.Schema.Definitions.encode function which takes Schema and returns Value. There's one problem with this function remaining though: json schema allows additional properties to be present along with standard keywords, and this is not allowed by encode function which acts as a whitelist and only leaves standard keywords.
the difference between withItem and withItems yes?
yep, it's like array treatment as a list (of same type, withItem) and a tuple (any types withItems).
I've been doing some things for NoRedInk/json-elm-schema and although there is a schema decoder there, I think the philosophy of the two are different. The NoRedInk version is focused on generating JSON schemas that are correct, in some sense, whereas this library is focused on working with existing JSON schemas from the outside, which may be incomplete and inconsistent.