Skip to content

Commit 2e5dabf

Browse files
authored
Bump json-schema-walker to 1.0.0 to support null default values (#37)
1 parent 499e9f5 commit 2e5dabf

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"dependencies": {
3737
"@apidevtools/json-schema-ref-parser": "^9.0.9",
38-
"json-schema-walker": "^0.0.4",
38+
"json-schema-walker": "^1.0.0",
3939
"openapi-types": "^12.0.0",
4040
"yargs": "^17.5.1"
4141
},

test/default-null.test.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import convert from '../src';
2+
3+
it('supports default values of null', async ({ expect }) => {
4+
const schema = {
5+
$schema: 'http://json-schema.org/draft-04/schema#',
6+
type: 'object',
7+
properties: {
8+
nullableStringWithDefault: {
9+
default: null,
10+
oneOf: [{ type: 'string' }, { type: 'null' }],
11+
}
12+
}
13+
};
14+
15+
const result = await convert(schema);
16+
17+
const expected = {
18+
type: 'object',
19+
properties: {
20+
nullableStringWithDefault: {
21+
default: null,
22+
oneOf: [{ type: 'string' }, { nullable: true }],
23+
}
24+
}
25+
};
26+
27+
expect(result).toEqual(expected);
28+
});

0 commit comments

Comments
 (0)