fast-json-stringify 5.0.3 → 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -489,6 +489,10 @@ function mergeAllOfSchema (location, schema, mergedSchema) {
489
489
  }
490
490
  }
491
491
  delete mergedSchema.allOf
492
+
493
+ mergedSchema.$id = `merged_${randomUUID()}`
494
+ ajvInstance.addSchema(mergedSchema)
495
+ location.schemaId = mergedSchema.$id
492
496
  }
493
497
 
494
498
  function buildInnerObject (location) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-json-stringify",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "description": "Stringify your JSON at max speed",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -0,0 +1,57 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const build = require('..')
5
+
6
+ test('should validate anyOf after allOf merge', (t) => {
7
+ t.plan(1)
8
+
9
+ const schema = {
10
+ $id: 'schema',
11
+ type: 'object',
12
+ allOf: [
13
+ {
14
+ $id: 'base',
15
+ type: 'object',
16
+ properties: {
17
+ name: {
18
+ type: 'string'
19
+ }
20
+ },
21
+ required: [
22
+ 'name'
23
+ ]
24
+ },
25
+ {
26
+ $id: 'inner_schema',
27
+ type: 'object',
28
+ properties: {
29
+ union: {
30
+ $id: '#id',
31
+ anyOf: [
32
+ {
33
+
34
+ $id: 'guid',
35
+ type: 'string'
36
+ },
37
+ {
38
+
39
+ $id: 'email',
40
+ type: 'string'
41
+ }
42
+ ]
43
+ }
44
+ },
45
+ required: [
46
+ 'union'
47
+ ]
48
+ }
49
+ ]
50
+ }
51
+
52
+ const stringify = build(schema)
53
+
54
+ t.equal(
55
+ stringify({ name: 'foo', union: 'a8f1cc50-5530-5c62-9109-5ba9589a6ae1' }),
56
+ '{"name":"foo","union":"a8f1cc50-5530-5c62-9109-5ba9589a6ae1"}')
57
+ })