@@ -278,67 +278,97 @@ describe('jschema_adapter', () => {
278278 title : 'ProcessTask'
279279 } ) ;
280280
281- expect ( JSON . stringify ( cleanJschema ) ) . eq (
282- JSON . stringify ( {
283- $defs : {
284- ProcessAModel : {
285- description : 'A process model with the same parameter name as ProcessBModel.' ,
286- properties : {
287- step : {
288- const : 'ProcessA' ,
289- title : 'Step' ,
290- type : 'string' ,
291- description : 'A literal to identify the process type.'
292- } ,
293- parameter1 : {
294- title : 'Parameter1' ,
295- type : 'number' ,
296- description : 'An integer parameter in A.'
297- }
281+ expect ( cleanJschema ) . deep . eq ( {
282+ $defs : {
283+ ProcessAModel : {
284+ description : 'A process model with the same parameter name as ProcessBModel.' ,
285+ properties : {
286+ step : {
287+ const : 'ProcessA' ,
288+ title : 'Step' ,
289+ type : 'string' ,
290+ description : 'A literal to identify the process type.'
298291 } ,
299- required : [ 'step' , 'parameter1' ] ,
300- title : 'ProcessAModel' ,
301- type : 'object'
292+ parameter1 : {
293+ title : 'Parameter1' ,
294+ type : 'number' ,
295+ description : 'An integer parameter in A.'
296+ }
302297 } ,
303- ProcessBModel : {
304- description : 'B process model with the same parameter name as ProcessAModel.' ,
305- properties : {
306- step : {
307- const : 'ProcessB' ,
308- title : 'Step' ,
309- type : 'string' ,
310- description : 'A literal to identify the process type.'
311- } ,
312- parameter1 : {
313- title : 'Parameter1' ,
314- type : 'number' ,
315- description : 'An integer parameter in B.'
316- }
298+ required : [ 'step' , 'parameter1' ] ,
299+ title : 'ProcessAModel' ,
300+ type : 'object'
301+ } ,
302+ ProcessBModel : {
303+ description : 'B process model with the same parameter name as ProcessAModel.' ,
304+ properties : {
305+ step : {
306+ const : 'ProcessB' ,
307+ title : 'Step' ,
308+ type : 'string' ,
309+ description : 'A literal to identify the process type.'
310+ } ,
311+ parameter1 : {
312+ title : 'Parameter1' ,
313+ type : 'number' ,
314+ description : 'An integer parameter in B.'
315+ }
316+ } ,
317+ required : [ 'step' , 'parameter1' ] ,
318+ title : 'ProcessBModel' ,
319+ type : 'object'
320+ }
321+ } ,
322+ additionalProperties : false ,
323+ properties : {
324+ proc_step : {
325+ oneOf : [
326+ {
327+ $ref : '#/$defs/ProcessAModel'
317328 } ,
318- required : [ 'step' , 'parameter1' ] ,
319- title : 'ProcessBModel' ,
320- type : 'object'
329+ {
330+ $ref : '#/$defs/ProcessBModel'
331+ }
332+ ] ,
333+ title : 'Proc Step' ,
334+ description : 'The processing step to apply.'
335+ }
336+ } ,
337+ required : [ 'proc_step' ] ,
338+ type : 'object' ,
339+ title : 'ProcessTask'
340+ } ) ;
341+ } ) ;
342+
343+ it ( 'Strip discriminator, schema with default null value (ref #871)' , ( ) => {
344+ const schema = stripDiscriminator ( {
345+ properties : {
346+ advanced_options : {
347+ type : 'object' ,
348+ properties : {
349+ position_scale : { type : 'number' }
350+ } ,
351+ default : {
352+ position_scale : null
321353 }
322- } ,
323- additionalProperties : false ,
324- properties : {
325- proc_step : {
326- oneOf : [
327- {
328- $ref : '#/$defs/ProcessAModel'
329- } ,
330- {
331- $ref : '#/$defs/ProcessBModel'
332- }
333- ] ,
334- title : 'Proc Step' ,
335- description : 'The processing step to apply.'
354+ }
355+ } ,
356+ type : 'object'
357+ } ) ;
358+
359+ expect ( schema ) . deep . eq ( {
360+ properties : {
361+ advanced_options : {
362+ type : 'object' ,
363+ properties : {
364+ position_scale : { type : 'number' }
365+ } ,
366+ default : {
367+ position_scale : null
336368 }
337- } ,
338- required : [ 'proc_step' ] ,
339- type : 'object' ,
340- title : 'ProcessTask'
341- } )
342- ) ;
369+ }
370+ } ,
371+ type : 'object'
372+ } ) ;
343373 } ) ;
344374} ) ;
0 commit comments