File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -772,6 +772,10 @@ function generateFuncName () {
772772function buildValue ( location , input ) {
773773 let schema = location . schema
774774
775+ if ( typeof schema === 'boolean' ) {
776+ return `json += JSON.stringify(${ input } )`
777+ }
778+
775779 if ( schema . $ref ) {
776780 location = resolveRef ( location , schema . $ref )
777781 schema = location . schema
Original file line number Diff line number Diff line change @@ -359,3 +359,16 @@ test('render a single quote as JSON', (t) => {
359359 t . equal ( output , JSON . stringify ( toStringify ) )
360360 t . ok ( validate ( JSON . parse ( output ) ) , 'valid schema' )
361361} )
362+
363+ test ( 'returns JSON.stringify if schema type is boolean' , t => {
364+ t . plan ( 1 )
365+
366+ const schema = {
367+ type : 'array' ,
368+ items : true
369+ }
370+
371+ const array = [ 1 , true , 'test' ]
372+ const stringify = build ( schema )
373+ t . equal ( stringify ( array ) , JSON . stringify ( array ) )
374+ } )
You can’t perform that action at this time.
0 commit comments