Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/searchfe/json-schema-generator
JSON schema generator supports draft 07
https://github.com/searchfe/json-schema-generator
draft07 generator json schema
Last synced: 3 months ago
JSON representation
JSON schema generator supports draft 07
- Host: GitHub
- URL: https://github.com/searchfe/json-schema-generator
- Owner: searchfe
- License: mit
- Created: 2018-11-15T03:50:00.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T09:32:32.000Z (about 2 years ago)
- Last Synced: 2024-10-04T15:40:33.154Z (4 months ago)
- Topics: draft07, generator, json, schema
- Language: JavaScript
- Size: 1 MB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# JSON Schema Generator
[![Build Status](https://travis-ci.com/harttle/json-schema-generator.svg?branch=master)](https://travis-ci.com/harttle/json-schema-generator)
[![Coverage Status](https://coveralls.io/repos/github/harttle/json-schema-generator/badge.svg?branch=master)](https://coveralls.io/github/harttle/json-schema-generator?branch=master)Spec: http://json-schema.org/latest/json-schema-validation.html
## Install
```bash
npm install --save jsg07
```## Usage
```javascript
const jsg = require('jsg07');let schema = jsg.infer({
name: 'Mike',
male: true,
tags: ['Gentle', 'Nice']
});
console.log(JSON.stringify(schema, null, 4));
```## Output
```
{
"title": "An object value",
"required": [
"name",
"male",
"tags"
],
"properties": {
"name": {
"title": "A string value",
"default": "",
"pattern": "^(.*)$",
"examples": [
"Mike"
],
"$id": "#/properties/name",
"type": "string"
},
"male": {
"title": "A boolean value",
"default": false,
"examples": [
true
],
"$id": "#/properties/male",
"type": "boolean"
},
"tags": {
"title": "An array of items",
"items": {
"title": "A string value",
"default": "",
"pattern": "^(.*)$",
"examples": [
"Gentle"
],
"$id": "#/properties/tags/items",
"type": "string"
},
"$id": "#/properties/tags",
"type": "array"
}
},
"$id": "http://example.org/root.json#",
"type": "object",
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#"
}
```