File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed
packages/elements-core/src/components/Docs/Model Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,21 @@ describe('Model', () => {
135135 expect ( textboxDescription ) . toHaveTextContent ( 'example schema description' ) ;
136136 } ) ;
137137
138+ it ( 'displays child description at top of doc for allOf-inheriting objects' , async ( ) => {
139+ const desc = 'child schema description' ;
140+ // allOf-inheriting properties from parent but having its own description
141+ const allOfSchema : JSONSchema7 = {
142+ allOf : [ exampleSchema ] ,
143+ description : desc ,
144+ } ;
145+ render ( < Model data = { allOfSchema } /> ) ;
146+ const description = screen . queryAllByText ( desc ) ;
147+ const textboxDescription = screen . getByRole ( 'textbox' ) ;
148+
149+ expect ( description ) . toHaveLength ( 1 ) ;
150+ expect ( textboxDescription ) . toHaveTextContent ( desc ) ;
151+ } ) ;
152+
138153 it ( 'does not display description at top of doc for non-objects' , async ( ) => {
139154 render ( < Model data = { exampleStringSchema } /> ) ;
140155 const description = screen . queryByRole ( 'textbox' ) ;
Original file line number Diff line number Diff line change @@ -93,12 +93,13 @@ const ModelComponent: React.FC<ModelProps> = ({
9393
9494 const description = (
9595 < VStack spacing = { 10 } >
96- { data . description && data . type === 'object' && (
97- < Box pos = "relative" >
98- < MarkdownViewer role = "textbox" markdown = { data . description } />
99- < NodeAnnotation change = { descriptionChanged } />
100- </ Box >
101- ) }
96+ { data . description &&
97+ ( data . type === 'object' || ( data . allOf || [ ] ) . some ( s => ( s as JSONSchema7 ) . type === 'object' ) ) && (
98+ < Box pos = "relative" >
99+ < MarkdownViewer role = "textbox" markdown = { data . description } />
100+ < NodeAnnotation change = { descriptionChanged } />
101+ </ Box >
102+ ) }
102103
103104 < NodeVendorExtensions data = { data } />
104105
You can’t perform that action at this time.
0 commit comments