JSON Schema to SimpleSchema Converter
Converts a JSON schema document to a SimpleSchema object, for use with Collection2 and AutoForm.
Install
meteor install bshamblen:json-simple-schema
Use
Simply load the contents of your JSON schema document from your local file system, or from a URL, and pass the parsed JSON object to the JSONSchema constructor:
1var jsonSchemaDoc = JSON.parse($.ajax({ 2 ype: 'GET', 3 url: 'http://example.com/path-to-json-schema-file', 4 async: false 5}).responseText); 6var jsonSchema = new JSONSchema(jsonSchemaDoc); 7var simpleSchema = jsonSchema.toSimpleSchema();
Disclaimer
This is the first iteration of this project, with minimal functionality. It currently supports base data types (including arrays), inline sub-objects and many of the validation options:
- title
- minimum
- maximum
- minLength
- maxLength
- enum
- minItems
- maxItems
- default
- pattern
- required
TODO
- Add support for internal
$refschemas, fromdefinitions - Add support for external
$refschemas, from a URI.
Contributing
Please feel free to contribute by sumbitting a pull request.