Skip to content

Commit 48dde2e

Browse files
committed
feat: support booleanish schemas & additionalProperties
1 parent 44abda7 commit 48dde2e

22 files changed

+169
-31
lines changed

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
rootDir: process.cwd(),
33
testEnvironment: 'node',
4+
roots: ['<rootDir>/src'],
45
setupFilesAfterEnv: ['./setupTests.ts'],
56
testMatch: ['<rootDir>/src/**/__tests__/*.(ts|js)?(x)'],
67
transform: {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
type: array
2+
additionalItems: {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
type: array
2+
additionalItems: false
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type: array
2+
additionalItems:
3+
type: object
4+
properties:
5+
baz:
6+
type: number
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
type: array
2+
additionalItems: true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "object",
3+
"additionalProperties": {}
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "object",
3+
"additionalProperties": false
4+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"type": "object",
3+
"additionalProperties": {
4+
"type": "object",
5+
"properties": {
6+
"baz": {
7+
"type": "number"
8+
}
9+
}
10+
}
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "object",
3+
"additionalProperties": true
4+
}

src/__tests__/__snapshots__/tree.spec.ts.snap

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,16 @@ exports[`SchemaTree output should generate valid tree for combiners/allOfs/neste
823823
│ └─ #/properties/order
824824
│ ├─ types
825825
│ │ └─ 0: object
826-
│ └─ primaryType: object
826+
│ ├─ primaryType: object
827+
│ └─ children
828+
│ └─ 0
829+
│ └─ #/properties/order/additionalProperties
830+
│ ├─ types
831+
│ │ └─ 0: string
832+
│ ├─ primaryType: string
833+
│ └─ enum
834+
│ ├─ 0: ASC
835+
│ └─ 1: DESC
827836
└─ 7
828837
└─ #/properties/nextToken
829838
├─ types
@@ -1246,6 +1255,53 @@ exports[`SchemaTree output should generate valid tree for formats-schema.json 1`
12461255
"
12471256
`;
12481257

1258+
exports[`SchemaTree output should generate valid tree for objects/additional-empty.json 1`] = `
1259+
"└─ #
1260+
├─ types
1261+
│ └─ 0: object
1262+
├─ primaryType: object
1263+
└─ children
1264+
└─ 0
1265+
└─ #/additionalProperties
1266+
"
1267+
`;
1268+
1269+
exports[`SchemaTree output should generate valid tree for objects/additional-false.json 1`] = `
1270+
"└─ #
1271+
├─ types
1272+
│ └─ 0: object
1273+
└─ primaryType: object
1274+
"
1275+
`;
1276+
1277+
exports[`SchemaTree output should generate valid tree for objects/additional-schema.json 1`] = `
1278+
"└─ #
1279+
├─ types
1280+
│ └─ 0: object
1281+
├─ primaryType: object
1282+
└─ children
1283+
└─ 0
1284+
└─ #/additionalProperties
1285+
├─ types
1286+
│ └─ 0: object
1287+
├─ primaryType: object
1288+
└─ children
1289+
└─ 0
1290+
└─ #/additionalProperties/properties/baz
1291+
├─ types
1292+
│ └─ 0: number
1293+
└─ primaryType: number
1294+
"
1295+
`;
1296+
1297+
exports[`SchemaTree output should generate valid tree for objects/additional-true.json 1`] = `
1298+
"└─ #
1299+
├─ types
1300+
│ └─ 0: object
1301+
└─ primaryType: object
1302+
"
1303+
`;
1304+
12491305
exports[`SchemaTree output should generate valid tree for references/base.json 1`] = `
12501306
"└─ #
12511307
├─ types

0 commit comments

Comments
 (0)