🧞 Convert JSON Objects to MySQL, JSON Schema, Mongoose, Google BigQuery, Swagger, and more.
Installations
npm install generate-schema
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
7.9.0
NPM Version
5.5.1
Score
99.6
Supply Chain
100
Quality
75.5
Maintenance
100
Vulnerability
100
License
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
Nijikokun
Download Statistics
Total Downloads
12,806,999
Last Day
14,537
Last Week
71,845
Last Month
297,870
Last Year
3,185,855
GitHub Statistics
1,042 Stars
77 Commits
136 Forks
25 Watching
2 Branches
13 Contributors
Bundle Size
8.32 kB
Minified
3.02 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.6.0
Package Id
generate-schema@2.6.0
Size
10.20 kB
NPM Version
5.5.1
Node Version
7.9.0
Publised On
20 Nov 2017
Total Downloads
Cumulative downloads
Total Downloads
12,806,999
Last day
8.5%
14,537
Compared to previous day
Last week
-11%
71,845
Compared to previous week
Last month
14.4%
297,870
Compared to previous month
Last year
12.9%
3,185,855
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Generate Schemas
Convert JSON Objects to MySQL Table Schema, JSON Schema, Mongoose Schema, ClickHouse Schema, Google BigQuery, or a Generic template for documentation, code generation, and more.
Table of Contents
Installation
Install with npm:
1$ npm i --save generate-schema
Optionally, add -g
to the above if you want the generate-schema
command line executable.
CLI
Usage: generate-schema [options ...] [file]
Common Options:
-h, --help output usage information
-V, --version output the version number
-q, --quiet Skip help message in program output
Mode Options:
-g, --generic Generic JSON Primitives schema output
-j, --json-schema JSON Schema output
-s, --mysql MySQL Table Schema output
-m, --mongoose Mongoose Schema output
-b, --big-query Google BigQuery Schema output
-c, --clickhouse Clickhouse Table Schema output
REPL Mode
When no file is specified, generate-schema
enters a REPL mode.
Example
$ generate-schema -b
generate-schema v2.5.1 (bigquery)
Type "exit" to quit.
Type {a:"b"} to see an example.
> {a:"b"}
[
{
"name": "a",
"type": "STRING",
"mode": "NULLABLE"
}
]
Usage
1var GenerateSchema = require('generate-schema')
Example
// Capture Schema Output
var schema = GenerateSchema.json('Product', [
{
"id": 2,
"name": "An ice sculpture",
"price": 12.50,
"tags": ["cold", "ice"],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
},
"warehouseLocation": {
"latitude": -78.75,
"longitude": 20.4
}
},
{
"id": 3,
"name": "A blue mouse",
"price": 25.50,
"dimensions": {
"length": 3.1,
"width": 1.0,
"height": 1.0
},
"warehouseLocation": {
"latitude": 54.4,
"longitude": -32.7
}
}
])
Outputs:
1{ 2 "$schema": "http://json-schema.org/draft-04/schema#", 3 "title": "Product Set", 4 "type": "array", 5 "items": { 6 "type": "object", 7 "properties": { 8 "id": { 9 "type": "number" 10 }, 11 "name": { 12 "type": "string" 13 }, 14 "price": { 15 "type": "number" 16 }, 17 "tags": { 18 "type": "array", 19 "items": { 20 "type": "string" 21 } 22 }, 23 "dimensions": { 24 "type": "object", 25 "properties": { 26 "length": { 27 "type": "number" 28 }, 29 "width": { 30 "type": "number" 31 }, 32 "height": { 33 "type": "number" 34 } 35 } 36 }, 37 "warehouseLocation": { 38 "type": "object", 39 "properties": { 40 "latitude": { 41 "type": "number" 42 }, 43 "longitude": { 44 "type": "number" 45 } 46 } 47 } 48 }, 49 "required": [ 50 "id", 51 "name", 52 "price", 53 "dimensions", 54 "warehouseLocation" 55 ], 56 "title": "Product" 57 } 58}
Methods
g.generic(Object object)
Generates a generic schema from object
. Property types are described using primitives.
g.mysql([String tableName,] Mixed object)
Generates MySQL Table Schema from object
.
tableName
is optional, defaults togeneric
object
must be of typeObject
orArray
g.json([String title,] Mixed object)
Generates JSON Schema from object
.
title
is optionalobject
must be of typeObject
orArray
g.mongoose(Object object)
Generates a Mongoose Schema from object
.
g.bigquery(Object object)
Generates a Google BigQuery schema from object
.
g.clickhouse([String tableName,] Mixed object, String dateField)
Generates ClickHouse Table Schema from object
.
tableName
is optional, defaults togeneric
object
must be of typeObject
orArray
dateField
Date field for ENGINE, must be of typeDate
License
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 8/24 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 15 are checked with a SAST tool
Score
3.4
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to generate-schema
prisma-generate-schema
Transform prisma datamodel SDL into graphql-js SDL
ts-json-schema-generator
Generate JSON schema from your Typescript sources
json-schema-defaults
Generate JSON object from default values in JSON Schema
generate-schema-default-value
Effortlessly convert your JSON Object to JSON Schema, Mongoose Schema, or a Generic template for quick documentation / upstart.