File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ function convertExamples(schema) {
170170}
171171
172172function rewriteConst ( schema ) {
173- if ( schema . const ) {
173+ if ( Object . hasOwnProperty . call ( schema , ' const' ) ) {
174174 schema . enum = [ schema . const ] ;
175175 delete schema . const ;
176176 }
Original file line number Diff line number Diff line change @@ -19,3 +19,20 @@ it('const', async () => {
1919
2020 should ( result ) . deepEqual ( expected , 'converted' ) ;
2121} ) ;
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