@zuplo/cli 6.71.22 → 6.71.25
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/node_modules/@fastify/fast-json-stringify-compiler/.github/dependabot.yml +42 -2
- package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/ci.yml +6 -1
- package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/lock-threads.yml +19 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/LICENSE +1 -1
- package/node_modules/@fastify/fast-json-stringify-compiler/README.md +1 -1
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.gitattributes +2 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/dependabot.yml +13 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/ci.yml +33 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/lock-threads.yml +19 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/LICENSE +22 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/README.md +742 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-branch.js +116 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-lib.js +339 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-thread.js +33 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench.js +391 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/build/build-schema-validator.js +26 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/eslint.config.js +9 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/example.js +81 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/server.js +42 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/index.js +1308 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/location.js +24 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/merge-schemas.js +9 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/schema-validator.js +1134 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/serializer.js +141 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/standalone.js +34 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/validator.js +96 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/package.json +89 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/additionalProperties.test.js +332 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/allof.test.js +751 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/any.test.js +231 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/anyof.test.js +812 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/array.test.js +688 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/asNumber.test.js +13 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/basic.test.js +400 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/bigint.test.js +76 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/clean-cache.test.js +47 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/const.test.js +314 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/date.test.js +639 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/debug-mode.test.js +130 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/defaults.test.js +376 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/enum.test.js +37 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fix-604.test.js +25 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fixtures/.keep +0 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/if-then-else.test.js +540 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/inferType.test.js +92 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/infinity.test.js +55 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/integer.test.js +194 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/invalidSchema.test.js +38 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-479.test.js +57 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-793.test.js +107 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-794.test.js +177 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-836.test.js +183 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-add-comma.test.js +57 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/README.md +10 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4/required.json +54 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4.test.js +12 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6/required.json +70 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6.test.js +12 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7/required.json +70 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7.test.js +12 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/util.js +31 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/missing-values.test.js +88 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/multi-type-serializer.test.js +19 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nestedObjects.test.js +63 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nullable.test.js +543 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/oneof.test.js +510 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/patternProperties.test.js +168 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/recursion.test.js +245 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.json +12 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.test.js +2077 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/regex.test.js +32 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/required.test.js +204 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/requiresAjv.test.js +50 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize.test.js +141 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize2.test.js +18 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize3.test.js +17 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize4.test.js +16 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize5.test.js +16 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize6.test.js +22 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize7.test.js +68 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/side-effect.test.js +196 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/standalone-mode.test.js +219 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/string.test.js +84 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/surrogate.test.js +67 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/toJSON.test.js +203 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typebox.test.js +36 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typesArray.test.js +550 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/unknownFormats.test.js +27 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/webpack.test.js +50 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.d.ts +219 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.tst.ts +259 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/package.json +6 -11
- package/node_modules/@fastify/fast-json-stringify-compiler/types/{index.test-d.ts → index.tst.ts} +34 -32
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts +5 -0
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core-stateless.js +50 -10
- package/node_modules/@posthog/core/dist/posthog-core-stateless.mjs +47 -10
- package/node_modules/@posthog/core/dist/posthog-core.d.ts +2 -2
- package/node_modules/@posthog/core/dist/posthog-core.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core.js +10 -6
- package/node_modules/@posthog/core/dist/posthog-core.mjs +11 -7
- package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.d.ts +1 -0
- package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.js +3 -0
- package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.mjs +3 -0
- package/node_modules/@posthog/core/dist/utils/promise-queue.d.ts +3 -0
- package/node_modules/@posthog/core/dist/utils/promise-queue.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/utils/promise-queue.js +15 -3
- package/node_modules/@posthog/core/dist/utils/promise-queue.mjs +15 -3
- package/node_modules/@posthog/core/package.json +1 -1
- package/node_modules/@posthog/core/src/posthog-core-stateless.ts +80 -14
- package/node_modules/@posthog/core/src/posthog-core.ts +18 -7
- package/node_modules/@posthog/core/src/testing/PostHogCoreTestClient.ts +4 -0
- package/node_modules/@posthog/core/src/utils/promise-queue.ts +17 -4
- package/node_modules/@posthog/types/dist/posthog.d.ts +12 -0
- package/node_modules/@posthog/types/dist/posthog.d.ts.map +1 -1
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/posthog.ts +13 -0
- package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
- package/node_modules/@protobufjs/utf8/index.js +29 -18
- package/node_modules/@protobufjs/utf8/package.json +2 -2
- package/node_modules/@protobufjs/utf8/tests/index.js +5 -0
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/buffer.d.ts +64 -25
- package/node_modules/@types/node/crypto.d.ts +18 -5
- package/node_modules/@types/node/diagnostics_channel.d.ts +237 -3
- package/node_modules/@types/node/dns.d.ts +1 -1
- package/node_modules/@types/node/ffi.d.ts +486 -0
- package/node_modules/@types/node/fs/promises.d.ts +3 -0
- package/node_modules/@types/node/fs.d.ts +21 -6
- package/node_modules/@types/node/http.d.ts +25 -0
- package/node_modules/@types/node/index.d.ts +1 -0
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/process.d.ts +14 -1
- package/node_modules/@types/node/quic.d.ts +92 -11
- package/node_modules/@types/node/sqlite.d.ts +55 -0
- package/node_modules/@types/node/stream/iter.d.ts +150 -0
- package/node_modules/@types/node/stream.d.ts +32 -0
- package/node_modules/@types/node/test.d.ts +112 -2
- package/node_modules/@types/node/ts5.6/index.d.ts +1 -0
- package/node_modules/@types/node/ts5.7/index.d.ts +1 -0
- package/node_modules/@types/node/util.d.ts +19 -2
- package/node_modules/@types/node/v8.d.ts +84 -2
- package/node_modules/@types/node/worker_threads.d.ts +8 -7
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/out/esm/index.js +11 -11
- package/node_modules/@zuplo/graphql/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-54PA7VDV.js → chunk-4QJJMELB.js} +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-54PA7VDV.js.map → chunk-4QJJMELB.js.map} +1 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-MJWTZPC2.js +402 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-MJWTZPC2.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +7 -7
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +263 -19
- package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +33 -7
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -1
- package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -1
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +1 -1
- package/node_modules/hono/dist/cjs/utils/body.js +12 -4
- package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
- package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
- package/node_modules/hono/dist/middleware/serve-static/index.js +1 -1
- package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
- package/node_modules/hono/dist/utils/body.js +12 -4
- package/node_modules/hono/dist/utils/buffer.js +2 -1
- package/node_modules/hono/dist/validator/validator.js +3 -3
- package/node_modules/hono/package.json +8 -7
- package/node_modules/iconv-lite/encodings/sbcs-data.js +2 -0
- package/node_modules/iconv-lite/encodings/utf32.js +10 -3
- package/node_modules/iconv-lite/package.json +2 -2
- package/node_modules/iconv-lite/types/encodings.d.ts +2 -0
- package/node_modules/protobufjs/dist/light/protobuf.js +2 -2
- package/node_modules/protobufjs/dist/light/protobuf.min.js +2 -2
- package/node_modules/protobufjs/dist/minimal/protobuf.js +2 -2
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +2 -2
- package/node_modules/protobufjs/dist/protobuf.js +5 -2
- package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/package.json +1 -1
- package/node_modules/protobufjs/src/parse.js +3 -0
- package/node_modules/toad-cache/README.md +10 -9
- package/node_modules/toad-cache/dist/toad-cache.cjs +139 -139
- package/node_modules/toad-cache/dist/toad-cache.mjs +136 -140
- package/node_modules/toad-cache/package.json +8 -8
- package/node_modules/toad-cache/toad-cache.d.cts +20 -14
- package/node_modules/toad-cache/toad-cache.d.ts +18 -14
- package/package.json +6 -6
- package/node_modules/@fastify/fast-json-stringify-compiler/.eslintrc +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-36XLJ4X6.js +0 -389
- package/node_modules/@zuplo/runtime/out/esm/chunk-36XLJ4X6.js.map +0 -1
- package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-36XLJ4X6.js.LEGAL.txt → chunk-MJWTZPC2.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { test } = require('node:test')
|
|
4
|
+
const build = require('..')
|
|
5
|
+
|
|
6
|
+
process.env.TZ = 'UTC'
|
|
7
|
+
|
|
8
|
+
test('allOf: combine type and format ', (t) => {
|
|
9
|
+
t.plan(1)
|
|
10
|
+
|
|
11
|
+
const schema = {
|
|
12
|
+
allOf: [
|
|
13
|
+
{ type: 'string' },
|
|
14
|
+
{ format: 'time' }
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
const stringify = build(schema)
|
|
18
|
+
const date = new Date(1674263005800)
|
|
19
|
+
const value = stringify(date)
|
|
20
|
+
t.assert.equal(value, '"01:03:25"')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test('allOf: combine additional properties ', (t) => {
|
|
24
|
+
t.plan(1)
|
|
25
|
+
|
|
26
|
+
const schema = {
|
|
27
|
+
allOf: [
|
|
28
|
+
{ type: 'object' },
|
|
29
|
+
{
|
|
30
|
+
type: 'object',
|
|
31
|
+
additionalProperties: { type: 'boolean' }
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
const stringify = build(schema)
|
|
36
|
+
const data = { property: true }
|
|
37
|
+
const value = stringify(data)
|
|
38
|
+
t.assert.equal(value, JSON.stringify(data))
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
test('allOf: combine pattern properties', (t) => {
|
|
42
|
+
t.plan(1)
|
|
43
|
+
|
|
44
|
+
const schema = {
|
|
45
|
+
allOf: [
|
|
46
|
+
{ type: 'object' },
|
|
47
|
+
{
|
|
48
|
+
type: 'object',
|
|
49
|
+
patternProperties: {
|
|
50
|
+
foo: {
|
|
51
|
+
type: 'number'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
const stringify = build(schema)
|
|
58
|
+
const data = { foo: 42 }
|
|
59
|
+
const value = stringify(data)
|
|
60
|
+
t.assert.equal(value, JSON.stringify(data))
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('object with allOf and multiple schema on the allOf', (t) => {
|
|
64
|
+
t.plan(4)
|
|
65
|
+
|
|
66
|
+
const schema = {
|
|
67
|
+
title: 'object with allOf and multiple schema on the allOf',
|
|
68
|
+
type: 'object',
|
|
69
|
+
allOf: [
|
|
70
|
+
{
|
|
71
|
+
type: 'object',
|
|
72
|
+
required: [
|
|
73
|
+
'name'
|
|
74
|
+
],
|
|
75
|
+
properties: {
|
|
76
|
+
name: {
|
|
77
|
+
type: 'string'
|
|
78
|
+
},
|
|
79
|
+
tag: {
|
|
80
|
+
type: 'string'
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
required: [
|
|
86
|
+
'id'
|
|
87
|
+
],
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
id: {
|
|
91
|
+
type: 'integer'
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
const stringify = build(schema)
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
stringify({
|
|
101
|
+
id: 1
|
|
102
|
+
})
|
|
103
|
+
} catch (e) {
|
|
104
|
+
t.assert.equal(e.message, '"name" is required!')
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
stringify({
|
|
109
|
+
name: 'string'
|
|
110
|
+
})
|
|
111
|
+
} catch (e) {
|
|
112
|
+
t.assert.equal(e.message, '"id" is required!')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
t.assert.equal(stringify({
|
|
116
|
+
id: 1,
|
|
117
|
+
name: 'string'
|
|
118
|
+
}), '{"name":"string","id":1}')
|
|
119
|
+
|
|
120
|
+
t.assert.equal(stringify({
|
|
121
|
+
id: 1,
|
|
122
|
+
name: 'string',
|
|
123
|
+
tag: 'otherString'
|
|
124
|
+
}), '{"name":"string","id":1,"tag":"otherString"}')
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
test('object with allOf and one schema on the allOf', (t) => {
|
|
128
|
+
t.plan(1)
|
|
129
|
+
|
|
130
|
+
const schema = {
|
|
131
|
+
title: 'object with allOf and one schema on the allOf',
|
|
132
|
+
type: 'object',
|
|
133
|
+
allOf: [
|
|
134
|
+
{
|
|
135
|
+
required: [
|
|
136
|
+
'id'
|
|
137
|
+
],
|
|
138
|
+
type: 'object',
|
|
139
|
+
properties: {
|
|
140
|
+
id: {
|
|
141
|
+
type: 'integer'
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
const stringify = build(schema)
|
|
148
|
+
|
|
149
|
+
const value = stringify({
|
|
150
|
+
id: 1
|
|
151
|
+
})
|
|
152
|
+
t.assert.equal(value, '{"id":1}')
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
test('object with allOf and no schema on the allOf', (t) => {
|
|
156
|
+
t.plan(1)
|
|
157
|
+
|
|
158
|
+
const schema = {
|
|
159
|
+
title: 'object with allOf and no schema on the allOf',
|
|
160
|
+
type: 'object',
|
|
161
|
+
allOf: []
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
build(schema)
|
|
166
|
+
t.fail()
|
|
167
|
+
} catch (e) {
|
|
168
|
+
t.assert.equal(e.message, 'schema is invalid: data/allOf must NOT have fewer than 1 items')
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
test('object with nested allOfs', (t) => {
|
|
173
|
+
t.plan(1)
|
|
174
|
+
|
|
175
|
+
const schema = {
|
|
176
|
+
title: 'object with nested allOfs',
|
|
177
|
+
type: 'object',
|
|
178
|
+
allOf: [
|
|
179
|
+
{
|
|
180
|
+
required: [
|
|
181
|
+
'id1'
|
|
182
|
+
],
|
|
183
|
+
type: 'object',
|
|
184
|
+
properties: {
|
|
185
|
+
id1: {
|
|
186
|
+
type: 'integer'
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
allOf: [
|
|
192
|
+
{
|
|
193
|
+
type: 'object',
|
|
194
|
+
properties: {
|
|
195
|
+
id2: {
|
|
196
|
+
type: 'integer'
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
type: 'object',
|
|
202
|
+
properties: {
|
|
203
|
+
id3: {
|
|
204
|
+
type: 'integer'
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const stringify = build(schema)
|
|
214
|
+
const value = stringify({
|
|
215
|
+
id1: 1,
|
|
216
|
+
id2: 2,
|
|
217
|
+
id3: 3,
|
|
218
|
+
id4: 4 // extra prop shouldn't be in result
|
|
219
|
+
})
|
|
220
|
+
t.assert.equal(value, '{"id1":1,"id2":2,"id3":3}')
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
test('object with anyOf nested inside allOf', (t) => {
|
|
224
|
+
t.plan(1)
|
|
225
|
+
|
|
226
|
+
const schema = {
|
|
227
|
+
title: 'object with anyOf nested inside allOf',
|
|
228
|
+
type: 'object',
|
|
229
|
+
allOf: [
|
|
230
|
+
{
|
|
231
|
+
required: ['id1', 'obj'],
|
|
232
|
+
type: 'object',
|
|
233
|
+
properties: {
|
|
234
|
+
id1: {
|
|
235
|
+
type: 'integer'
|
|
236
|
+
},
|
|
237
|
+
obj: {
|
|
238
|
+
type: 'object',
|
|
239
|
+
properties: {
|
|
240
|
+
nested: { type: 'string' }
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
anyOf: [
|
|
247
|
+
{
|
|
248
|
+
type: 'object',
|
|
249
|
+
properties: {
|
|
250
|
+
id2: { type: 'string' }
|
|
251
|
+
},
|
|
252
|
+
required: ['id2']
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
type: 'object',
|
|
256
|
+
properties: {
|
|
257
|
+
id3: {
|
|
258
|
+
type: 'integer'
|
|
259
|
+
},
|
|
260
|
+
nestedObj: {
|
|
261
|
+
type: 'object',
|
|
262
|
+
properties: {
|
|
263
|
+
nested: { type: 'string' }
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
required: ['id3']
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
type: 'object',
|
|
271
|
+
properties: {
|
|
272
|
+
id4: { type: 'integer' }
|
|
273
|
+
},
|
|
274
|
+
required: ['id4']
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const stringify = build(schema)
|
|
282
|
+
const value = stringify({
|
|
283
|
+
id1: 1,
|
|
284
|
+
id3: 3,
|
|
285
|
+
id4: 4, // extra prop shouldn't be in result
|
|
286
|
+
obj: { nested: 'yes' },
|
|
287
|
+
nestedObj: { nested: 'yes' }
|
|
288
|
+
})
|
|
289
|
+
t.assert.equal(value, '{"id1":1,"obj":{"nested":"yes"},"id3":3,"nestedObj":{"nested":"yes"}}')
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
test('object with $ref in allOf', (t) => {
|
|
293
|
+
t.plan(1)
|
|
294
|
+
|
|
295
|
+
const schema = {
|
|
296
|
+
title: 'object with $ref in allOf',
|
|
297
|
+
type: 'object',
|
|
298
|
+
definitions: {
|
|
299
|
+
id1: {
|
|
300
|
+
type: 'object',
|
|
301
|
+
properties: {
|
|
302
|
+
id1: {
|
|
303
|
+
type: 'integer'
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
allOf: [
|
|
309
|
+
{
|
|
310
|
+
$ref: '#/definitions/id1'
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const stringify = build(schema)
|
|
316
|
+
const value = stringify({
|
|
317
|
+
id1: 1,
|
|
318
|
+
id2: 2 // extra prop shouldn't be in result
|
|
319
|
+
})
|
|
320
|
+
t.assert.equal(value, '{"id1":1}')
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
test('object with $ref and other object in allOf', (t) => {
|
|
324
|
+
t.plan(1)
|
|
325
|
+
|
|
326
|
+
const schema = {
|
|
327
|
+
title: 'object with $ref in allOf',
|
|
328
|
+
type: 'object',
|
|
329
|
+
definitions: {
|
|
330
|
+
id1: {
|
|
331
|
+
type: 'object',
|
|
332
|
+
properties: {
|
|
333
|
+
id1: {
|
|
334
|
+
type: 'integer'
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
allOf: [
|
|
340
|
+
{
|
|
341
|
+
$ref: '#/definitions/id1'
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
type: 'object',
|
|
345
|
+
properties: {
|
|
346
|
+
id2: {
|
|
347
|
+
type: 'integer'
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const stringify = build(schema)
|
|
355
|
+
const value = stringify({
|
|
356
|
+
id1: 1,
|
|
357
|
+
id2: 2,
|
|
358
|
+
id3: 3 // extra prop shouldn't be in result
|
|
359
|
+
})
|
|
360
|
+
t.assert.equal(value, '{"id1":1,"id2":2}')
|
|
361
|
+
})
|
|
362
|
+
|
|
363
|
+
test('object with multiple $refs in allOf', (t) => {
|
|
364
|
+
t.plan(1)
|
|
365
|
+
|
|
366
|
+
const schema = {
|
|
367
|
+
title: 'object with $ref in allOf',
|
|
368
|
+
type: 'object',
|
|
369
|
+
definitions: {
|
|
370
|
+
id1: {
|
|
371
|
+
type: 'object',
|
|
372
|
+
properties: {
|
|
373
|
+
id1: {
|
|
374
|
+
type: 'integer'
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
id2: {
|
|
379
|
+
type: 'object',
|
|
380
|
+
properties: {
|
|
381
|
+
id2: {
|
|
382
|
+
type: 'integer'
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
allOf: [
|
|
388
|
+
{
|
|
389
|
+
$ref: '#/definitions/id1'
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
$ref: '#/definitions/id2'
|
|
393
|
+
}
|
|
394
|
+
]
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const stringify = build(schema)
|
|
398
|
+
const value = stringify({
|
|
399
|
+
id1: 1,
|
|
400
|
+
id2: 2,
|
|
401
|
+
id3: 3 // extra prop shouldn't be in result
|
|
402
|
+
})
|
|
403
|
+
t.assert.equal(value, '{"id1":1,"id2":2}')
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
test('allOf with nested allOf in $ref', (t) => {
|
|
407
|
+
t.plan(1)
|
|
408
|
+
|
|
409
|
+
const schema = {
|
|
410
|
+
title: 'allOf with nested allOf in $ref',
|
|
411
|
+
type: 'object',
|
|
412
|
+
definitions: {
|
|
413
|
+
group: {
|
|
414
|
+
type: 'object',
|
|
415
|
+
allOf: [{
|
|
416
|
+
properties: {
|
|
417
|
+
id2: {
|
|
418
|
+
type: 'integer'
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}, {
|
|
422
|
+
properties: {
|
|
423
|
+
id3: {
|
|
424
|
+
type: 'integer'
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}]
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
allOf: [
|
|
431
|
+
{
|
|
432
|
+
type: 'object',
|
|
433
|
+
properties: {
|
|
434
|
+
id1: {
|
|
435
|
+
type: 'integer'
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
required: [
|
|
439
|
+
'id1'
|
|
440
|
+
]
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
$ref: '#/definitions/group'
|
|
444
|
+
}
|
|
445
|
+
]
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const stringify = build(schema)
|
|
449
|
+
const value = stringify({
|
|
450
|
+
id1: 1,
|
|
451
|
+
id2: 2,
|
|
452
|
+
id3: 3,
|
|
453
|
+
id4: 4 // extra prop shouldn't be in result
|
|
454
|
+
})
|
|
455
|
+
t.assert.equal(value, '{"id1":1,"id2":2,"id3":3}')
|
|
456
|
+
})
|
|
457
|
+
|
|
458
|
+
test('object with external $refs in allOf', (t) => {
|
|
459
|
+
t.plan(1)
|
|
460
|
+
|
|
461
|
+
const externalSchema = {
|
|
462
|
+
first: {
|
|
463
|
+
definitions: {
|
|
464
|
+
id1: {
|
|
465
|
+
type: 'object',
|
|
466
|
+
properties: {
|
|
467
|
+
id1: {
|
|
468
|
+
type: 'integer'
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
second: {
|
|
475
|
+
definitions: {
|
|
476
|
+
id2: {
|
|
477
|
+
$id: '#id2',
|
|
478
|
+
type: 'object',
|
|
479
|
+
properties: {
|
|
480
|
+
id2: {
|
|
481
|
+
type: 'integer'
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
const schema = {
|
|
490
|
+
title: 'object with $ref in allOf',
|
|
491
|
+
type: 'object',
|
|
492
|
+
allOf: [
|
|
493
|
+
{
|
|
494
|
+
$ref: 'first#/definitions/id1'
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
$ref: 'second#/definitions/id2'
|
|
498
|
+
}
|
|
499
|
+
]
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const stringify = build(schema, { schema: externalSchema })
|
|
503
|
+
const value = stringify({
|
|
504
|
+
id1: 1,
|
|
505
|
+
id2: 2,
|
|
506
|
+
id3: 3 // extra prop shouldn't be in result
|
|
507
|
+
})
|
|
508
|
+
t.assert.equal(value, '{"id1":1,"id2":2}')
|
|
509
|
+
})
|
|
510
|
+
|
|
511
|
+
test('allof with local anchor reference', (t) => {
|
|
512
|
+
t.plan(1)
|
|
513
|
+
|
|
514
|
+
const externalSchemas = {
|
|
515
|
+
Test: {
|
|
516
|
+
$id: 'Test',
|
|
517
|
+
definitions: {
|
|
518
|
+
Problem: {
|
|
519
|
+
type: 'object',
|
|
520
|
+
properties: {
|
|
521
|
+
type: {
|
|
522
|
+
type: 'string'
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
ValidationFragment: {
|
|
527
|
+
type: 'string'
|
|
528
|
+
},
|
|
529
|
+
ValidationErrorProblem: {
|
|
530
|
+
type: 'object',
|
|
531
|
+
allOf: [
|
|
532
|
+
{
|
|
533
|
+
$ref: '#/definitions/Problem'
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
type: 'object',
|
|
537
|
+
properties: {
|
|
538
|
+
validation: {
|
|
539
|
+
$ref: '#/definitions/ValidationFragment'
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
]
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const schema = { $ref: 'Test#/definitions/ValidationErrorProblem' }
|
|
550
|
+
const stringify = build(schema, { schema: externalSchemas })
|
|
551
|
+
const data = { type: 'foo', validation: 'bar' }
|
|
552
|
+
|
|
553
|
+
t.assert.equal(stringify(data), JSON.stringify(data))
|
|
554
|
+
})
|
|
555
|
+
|
|
556
|
+
test('allOf: multiple nested $ref properties', (t) => {
|
|
557
|
+
t.plan(2)
|
|
558
|
+
|
|
559
|
+
const externalSchema1 = {
|
|
560
|
+
$id: 'externalSchema1',
|
|
561
|
+
oneOf: [
|
|
562
|
+
{ $ref: '#/definitions/id1' }
|
|
563
|
+
],
|
|
564
|
+
definitions: {
|
|
565
|
+
id1: {
|
|
566
|
+
type: 'object',
|
|
567
|
+
properties: {
|
|
568
|
+
id1: {
|
|
569
|
+
type: 'integer'
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
additionalProperties: false
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
const externalSchema2 = {
|
|
578
|
+
$id: 'externalSchema2',
|
|
579
|
+
oneOf: [
|
|
580
|
+
{ $ref: '#/definitions/id2' }
|
|
581
|
+
],
|
|
582
|
+
definitions: {
|
|
583
|
+
id2: {
|
|
584
|
+
type: 'object',
|
|
585
|
+
properties: {
|
|
586
|
+
id2: {
|
|
587
|
+
type: 'integer'
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
additionalProperties: false
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
const schema = {
|
|
596
|
+
anyOf: [
|
|
597
|
+
{ $ref: 'externalSchema1' },
|
|
598
|
+
{ $ref: 'externalSchema2' }
|
|
599
|
+
]
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
const stringify = build(schema, { schema: [externalSchema1, externalSchema2] })
|
|
603
|
+
|
|
604
|
+
t.assert.equal(stringify({ id1: 1 }), JSON.stringify({ id1: 1 }))
|
|
605
|
+
t.assert.equal(stringify({ id2: 2 }), JSON.stringify({ id2: 2 }))
|
|
606
|
+
})
|
|
607
|
+
|
|
608
|
+
test('allOf: throw Error if types mismatch ', (t) => {
|
|
609
|
+
t.plan(1)
|
|
610
|
+
|
|
611
|
+
const schema = {
|
|
612
|
+
allOf: [
|
|
613
|
+
{ type: 'string' },
|
|
614
|
+
{ type: 'number' }
|
|
615
|
+
]
|
|
616
|
+
}
|
|
617
|
+
t.assert.throws(() => {
|
|
618
|
+
build(schema)
|
|
619
|
+
}, {
|
|
620
|
+
message: 'Failed to merge "type" keyword schemas.',
|
|
621
|
+
schemas: [['string'], ['number']]
|
|
622
|
+
})
|
|
623
|
+
})
|
|
624
|
+
|
|
625
|
+
test('allOf: throw Error if format mismatch ', (t) => {
|
|
626
|
+
t.plan(1)
|
|
627
|
+
|
|
628
|
+
const schema = {
|
|
629
|
+
allOf: [
|
|
630
|
+
{ format: 'date' },
|
|
631
|
+
{ format: 'time' }
|
|
632
|
+
]
|
|
633
|
+
}
|
|
634
|
+
t.assert.throws(() => {
|
|
635
|
+
build(schema)
|
|
636
|
+
}, {
|
|
637
|
+
message: 'Failed to merge "format" keyword schemas.'
|
|
638
|
+
// schemas: ['date', 'time']
|
|
639
|
+
})
|
|
640
|
+
})
|
|
641
|
+
|
|
642
|
+
test('recursive nested allOfs', (t) => {
|
|
643
|
+
t.plan(1)
|
|
644
|
+
|
|
645
|
+
const schema = {
|
|
646
|
+
type: 'object',
|
|
647
|
+
properties: {
|
|
648
|
+
foo: {
|
|
649
|
+
additionalProperties: false,
|
|
650
|
+
allOf: [{ $ref: '#' }]
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
const data = { foo: {} }
|
|
656
|
+
const stringify = build(schema)
|
|
657
|
+
t.assert.equal(stringify(data), JSON.stringify(data))
|
|
658
|
+
})
|
|
659
|
+
|
|
660
|
+
test('recursive nested allOfs', (t) => {
|
|
661
|
+
t.plan(1)
|
|
662
|
+
|
|
663
|
+
const schema = {
|
|
664
|
+
type: 'object',
|
|
665
|
+
properties: {
|
|
666
|
+
foo: {
|
|
667
|
+
additionalProperties: false,
|
|
668
|
+
allOf: [{ allOf: [{ $ref: '#' }] }]
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
const data = { foo: {} }
|
|
674
|
+
const stringify = build(schema)
|
|
675
|
+
t.assert.equal(stringify(data), JSON.stringify(data))
|
|
676
|
+
})
|
|
677
|
+
|
|
678
|
+
test('external recursive allOfs', (t) => {
|
|
679
|
+
t.plan(1)
|
|
680
|
+
|
|
681
|
+
const externalSchema = {
|
|
682
|
+
type: 'object',
|
|
683
|
+
properties: {
|
|
684
|
+
foo: {
|
|
685
|
+
properties: {
|
|
686
|
+
bar: { type: 'string' }
|
|
687
|
+
},
|
|
688
|
+
allOf: [{ $ref: '#' }]
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
const schema = {
|
|
694
|
+
type: 'object',
|
|
695
|
+
properties: {
|
|
696
|
+
a: { $ref: 'externalSchema#/properties/foo' },
|
|
697
|
+
b: { $ref: 'externalSchema#/properties/foo' }
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
const data = {
|
|
702
|
+
a: {
|
|
703
|
+
foo: {},
|
|
704
|
+
bar: '42',
|
|
705
|
+
baz: 42
|
|
706
|
+
},
|
|
707
|
+
b: {
|
|
708
|
+
foo: {},
|
|
709
|
+
bar: '42',
|
|
710
|
+
baz: 42
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
const stringify = build(schema, { schema: { externalSchema } })
|
|
714
|
+
t.assert.equal(stringify(data), '{"a":{"bar":"42","foo":{}},"b":{"bar":"42","foo":{}}}')
|
|
715
|
+
})
|
|
716
|
+
|
|
717
|
+
test('do not crash with $ref prop', (t) => {
|
|
718
|
+
t.plan(1)
|
|
719
|
+
|
|
720
|
+
const schema = {
|
|
721
|
+
title: 'object with $ref',
|
|
722
|
+
type: 'object',
|
|
723
|
+
properties: {
|
|
724
|
+
outside: {
|
|
725
|
+
$ref: '#/$defs/outside'
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
$defs: {
|
|
729
|
+
inside: {
|
|
730
|
+
type: 'object',
|
|
731
|
+
properties: {
|
|
732
|
+
$ref: {
|
|
733
|
+
type: 'string'
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
},
|
|
737
|
+
outside: {
|
|
738
|
+
allOf: [{
|
|
739
|
+
$ref: '#/$defs/inside'
|
|
740
|
+
}]
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
const stringify = build(schema)
|
|
745
|
+
const value = stringify({
|
|
746
|
+
outside: {
|
|
747
|
+
$ref: 'true'
|
|
748
|
+
}
|
|
749
|
+
})
|
|
750
|
+
t.assert.equal(value, '{"outside":{"$ref":"true"}}')
|
|
751
|
+
})
|