@@ -677,6 +677,86 @@ describe('SchemaTree', () => {
677677 it ( 'given empty schema, should output empty tree' , ( ) => {
678678 expect ( printTree ( { } ) ) . toEqual ( '' ) ;
679679 } ) ;
680+
681+ it ( 'should override description' , ( ) => {
682+ const schema = {
683+ type : 'object' ,
684+ properties : {
685+ caves : {
686+ type : 'array' ,
687+ items : {
688+ summary : 'Bear cave' ,
689+ $ref : '#/$defs/Cave' ,
690+ description : 'Apparently Tom likes bears' ,
691+ } ,
692+ } ,
693+ greatestBear : {
694+ $ref : '#/$defs/Bear' ,
695+ description : 'The greatest bear!' ,
696+ } ,
697+ bestBear : {
698+ $ref : '#/$defs/Bear' ,
699+ summary : 'The best bear!' ,
700+ } ,
701+ } ,
702+ $defs : {
703+ Bear : {
704+ type : 'string' ,
705+ summary : "Tom's favorite bear" ,
706+ } ,
707+ Cave : {
708+ type : 'string' ,
709+ summary : 'A cave' ,
710+ description : '_Everyone_ ~hates~ loves caves' ,
711+ } ,
712+ } ,
713+ } ;
714+
715+ const tree = new SchemaTree ( schema , { } ) ;
716+ tree . populate ( ) ;
717+
718+ expect ( tree . root ) . toEqual (
719+ expect . objectContaining ( {
720+ children : [
721+ expect . objectContaining ( {
722+ primaryType : 'object' ,
723+ types : [ 'object' ] ,
724+ children : [
725+ expect . objectContaining ( {
726+ primaryType : 'array' ,
727+ subpath : [ 'properties' , 'caves' ] ,
728+ types : [ 'array' ] ,
729+ children : [
730+ expect . objectContaining ( {
731+ primaryType : 'string' ,
732+ types : [ 'string' ] ,
733+ subpath : [ 'items' ] ,
734+ annotations : {
735+ description : 'Apparently Tom likes bears' ,
736+ } ,
737+ } ) ,
738+ ] ,
739+ } ) ,
740+ expect . objectContaining ( {
741+ primaryType : 'string' ,
742+ types : [ 'string' ] ,
743+ subpath : [ 'properties' , 'greatestBear' ] ,
744+ annotations : {
745+ description : 'The greatest bear!' ,
746+ } ,
747+ } ) ,
748+ expect . objectContaining ( {
749+ primaryType : 'string' ,
750+ types : [ 'string' ] ,
751+ subpath : [ 'properties' , 'bestBear' ] ,
752+ annotations : { } ,
753+ } ) ,
754+ ] ,
755+ } ) ,
756+ ] ,
757+ } ) ,
758+ ) ;
759+ } ) ;
680760 } ) ;
681761
682762 describe ( 'position' , ( ) => {
0 commit comments