fast-json-stringify
Advanced tools
Comparing version 2.5.1 to 2.5.2
@@ -960,3 +960,3 @@ 'use strict' | ||
function buildArray (location, code, name, key = null) { | ||
const schema = location.schema | ||
let schema = location.schema | ||
code += ` | ||
@@ -983,2 +983,6 @@ function ${name} (obj) { | ||
if (schema.items.$ref) { | ||
if (!schema[fjsCloned]) { | ||
schema = clone(location.schema) | ||
schema[fjsCloned] = true | ||
} | ||
location = refFinder(schema.items.$ref, location) | ||
@@ -1220,3 +1224,3 @@ schema.items = location.schema | ||
code += ` | ||
if(ajv.validate(${require('util').inspect(schema, { depth: null, showHidden: false })}, obj${accessor})) | ||
if(ajv.validate(${JSON.stringify(schema)}, obj${accessor})) | ||
json += '${JSON.stringify(schema.const)}' | ||
@@ -1223,0 +1227,0 @@ else |
{ | ||
"name": "fast-json-stringify", | ||
"version": "2.5.1", | ||
"version": "2.5.2", | ||
"description": "Stringify your JSON at max speed", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -124,1 +124,35 @@ 'use strict' | ||
}) | ||
test('must not mutate items $ref', t => { | ||
t.plan(2) | ||
const referenceSchema = { | ||
$id: 'ShowSchema', | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
type: 'object', | ||
properties: { | ||
name: { | ||
type: 'string' | ||
} | ||
} | ||
} | ||
const schema = { | ||
$id: 'ListSchema', | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
type: 'array', | ||
items: { | ||
$ref: 'ShowSchema#' | ||
} | ||
} | ||
const clonedSchema = clone(schema) | ||
const stringify = build(schema, { | ||
schema: { | ||
[referenceSchema.$id]: referenceSchema | ||
} | ||
}) | ||
const value = stringify([{ name: 'foo' }]) | ||
t.is(value, '[{"name":"foo"}]') | ||
t.deepEqual(schema, clonedSchema) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
325285
9769