Has anyone worked on a way to generate a (tentative) JSON-Schema
(http://json-schema.org/) from an existing Collection?
Hi Julien,
A few folks have mentioned interest in using JSON Schema Validation but I haven't come across any generic implementations for generating or validating JSON-Schema from MongoDB yet.
Schema.js uses MapReduce to work out the coverage and types of fields in a collection, so you could massage the results from that to generate your JSON Schema. For example, you could infer based on the 'coverage %' whether a field should be optional or required. You could use JSV to validate documents against the expected schema.
I'd be interested to see if anyone does have solutions. The JSON-Schema spec is still an evolving draft so you would definitely be an early adopter ;-).
Cheers,
Stephen