krg7880 / json-schema-generator Goto Github PK
View Code? Open in Web Editor NEWGenerates draft v4 schema from a local file or a remote JSON url.
License: MIT License
Generates draft v4 schema from a local file or a remote JSON url.
License: MIT License
When given an object like:
{myArray: ['one', 'two']}
The generator creates a schema like the following:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "",
"properties": {
"myArray": {
"type": "array",
"items": {
"required": [],
"properties": {}
}
}
},
"required": ["myArray"],
"type": "object"
}
The "items" should instead be something like:
"items": {
"type": "string",
"minLength": 1
}
The currently-generated schema breaks validators like ajv.
Patch available for [email protected]
✗ Prototype Pollution [High Severity][https://snyk.io/vuln/npm:extend:20180424] in [email protected]
introduced by [email protected] > [email protected] > [email protected] and 2 other path(s)
This might be a duplicate of #27 , but it seems the latest [email protected]
has old request
which contain [email protected]
.
Need a new version of it to pick up the [email protected]
based on https://snyk.io/vuln/npm:extend:20180424 .
Hi,
if I am passing JSON like this:-
{
"name":"tst1",
"date":"2012-04-30T02:15:12.356Z"
}
how its know it is type of date not a string?
Regular Expression Denial of Service (ReDoS)
High severity vulnerability found in sshpk
Description: Regular Expression Denial of Service (ReDoS)
Introduced through: [email protected]
From: [email protected] > [email protected] > [email protected] > [email protected]
Hi,
Is it possible to use the library in the browser? If yes, how do I package all the js file into a single for the purpose? Thanks for your help.
There seems to be an infinite loop on npm install
test seems to be pointing to "npm test" I suppose thats why
Hello there and thank you for this lib!
Please add support for additionalProperties
, they are true by default causing obsolete code in typescript.
I am using your json schema to validate two endpoints/responses, and I am having trouble using a working validator. The only one that works well, and with complex JSON is the deep.equal in Mocha/Chai.
The issue occurs when the required field appears with an array and not consistently in the same order, which deep.equal flags as a fail. Could you possible sort the required array, or at least produce an array that's consistently in the same order? That would really help me out.
$ npm install -g json-schema-generator
...
npm http fetch GET http://npm-registry01.prd.nytimes.com/wordwrap/-/wordwrap-0.0.2.tgz
npm ERR! cb() never called!
either ditch their npm-shrinkwrap.json from the published package, or to make sure that it's not pointing to their private registry when they publish the package to the public registry
~ @othiym23 at npm/npm#7146 (comment)
The json schema generator does not generate schema the way I want it to.
For e.g. When I create the schema on the object : {c: ["a", "b", "c"]}
The schema created is as below:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "",
"type": "object",
"properties": {
"c": {
"type": "array",
"items": {
"required": [
],
"properties": {
}
},
"value": [
"a",
"b",
"c"
]
}
},
"required": [
"c"
]
}
In the above schema - the array c
, has a default value of [“a”, “b”, “c”]
Instead my requirement is that, we should create the schema as below.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "",
"type": "object",
"properties": {
"c": {
"type": "array",
"items": {
"type": "string",
"enum": [
"a",
"b",
"c"
]
}
}
},
"required": [
"c"
]
}
Is it intended to always print "Node" in the bin/cli.js ?
https://github.com/krg7880/json-schema-generator/blob/master/bin/cli.js#L3
With this line its harder to use json-schema-generator in pipes:
I need to put "| tail -n +2" for receiving correct json document
cat package.json | json-schema-generator | tail -n +2 | json2yml
Instead of
cat package.json | json-schema-generator | json2yml
In an array of items in the array, required is set even if it is not true.
> const jsonSchemaGenerator = require('json-schema-generator')
undefined
> jsonSchemaGenerator([{a: 1, b: 2}, {a: 2, b: 3}, {b: 5}])
{
type: 'array',
'$schema': 'http://json-schema.org/draft-04/schema#',
description: '',
minItems: 1,
uniqueItems: true,
items: {
type: 'object',
required: [ 'a', 'b' ],
properties: { a: [Object], b: [Object] }
}
}
>
In the previous example a
cannot be required since it does not exist in the third element
✗ Regular Expression Denial of Service (ReDoS) [High Severity][https://snyk.io/vuln/npm:sshpk:20180409] in [email protected]
introduced by [email protected] > [email protected] > [email protected] > [email protected] and 1 other path(s)
This issue was fixed in versions: 1.14.1
Need this update for the security reason..
const gen = require('json-schema-generator')
const testObj = {test: []}
const schema = gen(testObj)
console.log(schema)
This outputs:
{ '$schema': 'http://json-schema.org/draft-04/schema#',
description: '',
type: 'object',
properties:
{ test:
{ type: 'array',
uniqueItems: undefined,
minItems: undefined,
items: [Object] } },
required: [ 'test' ] }
This is problematic as the value of minItems
inside schema.properties.test
is undefined, so when the original object is tested against the generated schema, we have a validation error.
var Validator = require('jsonschema').Validator
const validator = new Validator()
const result = validator.validate(testObj, schema, {throwError: false})
result.errors contains:
[ ValidationError {
property: 'instance.test',
message: 'does not meet minimum length of undefined',
schema:
{ type: 'array',
uniqueItems: undefined,
minItems: undefined,
items: [Object] },
instance: [],
name: 'minItems',
argument: undefined,
stack: 'instance.test does not meet minimum length of undefined' } ]
Prototype Pollution security issue
High severity vulnerability found in extend
Description: Prototype Pollution
Introduced through: [email protected]
From: [email protected] > [email protected] > [email protected]
Solution is to use the right version of request
which does not use [email protected]; if latest version of request
still has that issue, then request
needs to fix that by using the latest version of extend
where they fix this issue.
I did npm install json-schema-generator, then added this line of code.
schemaGen = require 'json-schema-generator';
I am getting the Error: Cannot find module 'pretty-data'.
It seems to be pretty-data needs to be moved from dev-dependencies to dependencies in package.json.
Thanks,
Raghu
When validating the following schema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"event_type": {
"type": "string"
},
"dependencies_type": {
"type": "string"
},
"agent_type": {
"type": "string"
},
"key": {
"type": "string"
},
"node": {
"type": "object",
"properties": {
"parent_id": {
"type": "string"
},
"value": {
"type": "object"
},
"id": {
"type": "string"
}
},
"required": [
"parent_id",
"value",
"id"
]
}
},
"required": [
"event_type",
"node",
"key",
"dependencies_type",
"agent_type"
]
}
The error below occurs. This is due to the type of the "value" field being "object".
RangeError: Maximum call stack size exceeded
at String.replace (native)
at new URLUtils (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/node_modules/json-schema-faker/node_modules/deref/lib/util/helpers.js:9:23)
at new URLUtils (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/node_modules/json-schema-faker/node_modules/deref/lib/util/helpers.js:24:16)
at parseURI (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/node_modules/json-schema-faker/node_modules/deref/lib/util/helpers.js:77:10)
at Object.resolveURL (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/node_modules/json-schema-faker/node_modules/deref/lib/util/helpers.js:83:10)
at Object.module.exports [as normalizeSchema] (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/node_modules/json-schema-faker/node_modules/deref/lib/util/normalize-schema.js:56:12)
at /home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/node_modules/json-schema-faker/node_modules/deref/lib/index.js:59:18
at Array.forEach (native)
at $ref (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/node_modules/json-schema-faker/node_modules/deref/lib/index.js:58:35)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/node_modules/json-schema-faker/lib/jsf.js:19:21)
at generateForProp (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:41:11)
at generateNegativeType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:81:11)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:389:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)
at generateNegativeDetailsForType (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:371:44)
at generateForTypes (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:390:44)
at generate (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:452:42)
at generateNegativesForObject (/home/miaou/projects/events/couchapp-dependencies/node_modules/json-schema-test-data-generator/dist/index.js:320:22)npm ERR! Test failed. See above for more details.
The test JSON example does not create the schema for child keys as it says in the documentation:
var jsonSchemaGenerator = require('json-schema-generator')
const json_raw = {
"title": "fresh fruit schema v1",
"type": "object",
"required": ["skin", "colors", "taste"],
"properties": {
"colors": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "string"
}
},
"skin": {
"type": "string"
},
"taste": {
"type": "number",
"minimum": 5
}
}
}
var jsonSchema = jsonSchemaGenerator(json_raw)
console.log(jsonSchema);
Outputs:
{
'$schema': 'http://json-schema.org/draft-04/schema#',
description: '',
type: 'object',
properties: {
extra: { type: 'object', properties: [Object], required: [Array] },
data: { type: 'object', properties: [Object], required: [Array] },
key: { type: 'object', properties: [Object], required: [Array] },
metadata: { type: 'object', properties: [Object], required: [Array] }
},
required: [ 'extra', 'data', 'key', 'metadata' ]
}
Update tough-cookie version to at least 2.3.0
https://github.com/krg7880/json-schema-generator/blob/master/npm-shrinkwrap.json#L150
Update request
to v2.81.1
Reason being is that the dependency tough-cookie
is v2.3.0
on that version while on request v2.47.x
and v2.51.x
uses tough-cookie v0.12.0
which has vulnerability issues
npm WARN deprecated [email protected]: ReDoS vulnerability parsing Set-Cookie
https://nodesecurity.io/advisories/130
The latest request
module has [email protected] which fixes this issue
There hasn't been a new version or comments on existing PRs in years. Looks like a fork of this project is getting some maintenance work at https://github.com/stoplightio/json-schema-generator.
If this project is still receiving PRs from the community, I'd be happy to open some to make this better.
Are there plans to include support for draft-06 or higher?
schema-test.js references the file /test/fixtures/schema/valid.json, but that file isn't part of the repository.
{"web-app": {
"servlet": [
{
"a": "atest",
"b": "btest",
"init-param": {
"orange": 4,
"watermelon": true}},
{
"a": "ctest",
"b": "dtest",
"init-param": {
"apple": 4,
"banana": true}}]
}}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "",
"type": "object",
"properties": {
"web-app": {
"type": "object",
"properties": {
"servlet": {
"type": "array",
"uniqueItems": true,
"minItems": 1,
"items": {
"required": [
"a",
"b"
],
"properties": {
"a": {
"type": "string",
"minLength": 1
},
"b": {
"type": "string",
"minLength": 1
},
"init-param": {
"type": "object",
"properties": {
"orange": {
"type": "number"
},
"watermelon": {
"type": "boolean"
}
},
"required": [
"orange",
"watermelon"
]
}
}
}
}
},
"required": [
"servlet"
]
}
},
"required": [
"web-app"
]
}
apple and banana are missing....
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.