File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ function convertExamples(schema) {
170
170
}
171
171
172
172
function rewriteConst ( schema ) {
173
- if ( schema . const ) {
173
+ if ( Object . hasOwnProperty . call ( schema , ' const' ) ) {
174
174
schema . enum = [ schema . const ] ;
175
175
delete schema . const ;
176
176
}
Original file line number Diff line number Diff line change @@ -19,3 +19,20 @@ it('const', async () => {
19
19
20
20
should ( result ) . deepEqual ( expected , 'converted' ) ;
21
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
+ type : 'boolean' ,
34
+ enum : [ false ]
35
+ } ;
36
+
37
+ should ( result ) . deepEqual ( expected , 'converted' ) ;
38
+ } ) ;
You can’t perform that action at this time.
0 commit comments