We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 35f865a + 71bef7b commit ed38775Copy full SHA for ed38775
2 files changed
index.js
@@ -170,7 +170,7 @@ function convertExamples(schema) {
170
}
171
172
function rewriteConst(schema) {
173
- if (schema.const) {
+ if (Object.hasOwnProperty.call(schema, 'const')) {
174
schema.enum = [ schema.const ];
175
delete schema.const;
176
test/const.test.js
@@ -19,3 +19,20 @@ it('const', async () => {
19
20
should(result).deepEqual(expected, 'converted');
21
});
22
+
23
+it('falsy const', async () => {
24
+ const schema = {
25
+ $schema: 'http://json-schema.org/draft-04/schema#',
26
+ type: 'boolean',
27
+ const: false
28
+ };
29
30
+ const result = await convert(schema);
31
32
+ const expected = {
33
34
+ enum: [ false ]
35
36
37
+ should(result).deepEqual(expected, 'converted');
38
+});
0 commit comments