Hi Simo, It would be great if we had a JSON Schema definition for the feature files and if we could use that for validation. The schema itself can already be useful for documentation purposes!
+1 from me. David On Fri, 5 Oct 2018 at 10:06, Simone Tripodi <[email protected]> wrote: > Hi all, > I did an experiment yesterday in the night with the Apache Johnzon JSON > Schema implementation [1], but it doesn't fails where it is expect to be. > I'll do some other tries during the WE :P > ~Simo > > [1] https://johnzon.apache.org/ > > http://people.apache.org/~simonetripodi/ > http://twitter.com/simonetripodi > > > On Thu, Oct 4, 2018 at 5:02 PM Simone Tripodi <[email protected]> > wrote: > > > Hi all mates, > > > > while working on an idea of a JSON streaming parser for the Feature > model, > > I noticed that the parser has the delegation of validating the input, > other > > than transforming the json structure the the Feature model. > > > > Given my experience of (many, sigh) years ago I when contributed to the > > Plexus Modello the JSON schema generator, I wrote an initial prototype of > > the Apache Sling Feature JSON schema[2] compliant with the latest #7 > draft, > > and playing around with tests model with an online schema validator[2]. > > The proposed schema supports extensions handling, validating the object > > value type (JSON/TEXT/ARTIFACTS). > > > > I see the advantages below of adopting such schema: > > > > * to have a formal and standard way to describe the Feature data > > structure in JSON model; > > > > * provide an easy way to assist users on editing Feature json files in > > the right way inside IDEs, as shown in Eclipse[3] and IntelliJ[4]; > > > > * separate the input validation - it can be delegated by the Feature > > Analyzer - and the parser phases (which should just take care of > > transforming the JSON data to the Feature model): unfortunately there are > > no up-to-date Java implementations, the most well-known [5] works on > > org.json implementation and the other one [6] is "still" at the draft #4 > > (aside that relies on too many dependencies). > > An alternative could be writing a simple validator for our use case, > based > > on the proposed schema. > > > > WDYT? > > I would like to contribute the schema [1] to one of the feature modules, > > maybe the -io is the more appropriate. > > > > I hope that could be interesting, have a nice day and all the best! > > ~Simo > > > > [1] > https://gist.github.com/simonetripodi/c69d2ffebdbd2c4b1355df60568f1ab5 > > [2] https://www.jsonschemavalidator.net/ > > [3] > > > https://stackoverflow.com/questions/50011837/how-to-do-json-schema-validation-in-eclipse > > [4] > > https://www.jetbrains.com/help/idea/settings-languages-json-schema.html > > [5] https://github.com/everit-org/json-schema > > [6] https://github.com/java-json-tools/json-schema-validator > > > > http://people.apache.org/~simonetripodi/ > > http://twitter.com/simonetripodi > > >
