Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ericgj/json-schema-suite
JSON Schema tools suite
https://github.com/ericgj/json-schema-suite
Last synced: 2 months ago
JSON representation
JSON Schema tools suite
- Host: GitHub
- URL: https://github.com/ericgj/json-schema-suite
- Owner: ericgj
- Created: 2013-10-14T16:59:52.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-01-24T00:36:04.000Z (about 11 years ago)
- Last Synced: 2023-12-26T18:12:16.149Z (about 1 year ago)
- Language: JavaScript
- Size: 308 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# json-schema-suite
JSON Schema components bundled for easy use.
- Configures Schema with validation and hyperlink plugins.
- Configures the Agent to use [visionmedia/superagent][superagent] as the
underlying http client.- Exposes Agent, as well as Schema and Validator for further configuration.
## Installation
__component__:
$ component install ericgj/json-schema-suite
__npm__:
$ npm install json-schema-suite
__browser standalone__:
Include `build.js` or `build.min.js` in a script tag.
This will give you a `window.jsonSchema` global.
If you would prefer a different global, clone this repo and rebuild like:$ component install
$ component build --standalone myGlobalThen move the `build/build.js` file into your project.
## Examples
```javascript
var suite = require('json-schema-suite')
// Simple validation
// see json-schema-valid for more detailsvar validator = new suite.Validator()
validator.validateRaw(schema,instance); // boolean
validator.error(); // validation error(s) wrapped in error object// HTTP correlation
var agent = new suite.Agent()
agent.get('/api', function(err,correlation){
// validation
correlation.once('error', function(e){
console.error(e);
})if (correlation.validate()) {
//...
}
// follow resolved links in correlations
agent.follow( correlation.rel('instances'), function(){
//...
});})
```
## API
See [json-schema-agent][agent], [json-schema-valid][valid],
[json-schema-core][core] for details.## Running tests
### In browser
```sh
$ node test/server.js
```
And browse `http://localhost:3000`.### In node
```sh
$ node test/server.js &
$ npm test
```## License
MIT
[agent]: https://github.com/ericgj/json-schema-agent
[valid]: https://github.com/ericgj/json-schema-valid
[core]: https://github.com/ericgj/json-schema-core
[superagent]: https://github.com/visionmedia/superagent