File tree Expand file tree Collapse file tree 5 files changed +28
-12
lines changed
src/components/Docs/Model Expand file tree Collapse file tree 5 files changed +28
-12
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @stoplight/elements-core" ,
3- "version" : " 9.0.6 " ,
3+ "version" : " 9.0.7 " ,
44 "sideEffects" : [
55 " web-components.min.js" ,
66 " src/web-components/**" ,
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
Original file line number Diff line number Diff line change 11{
22 "name" : " @stoplight/elements-dev-portal" ,
3- "version" : " 3.0.6 " ,
3+ "version" : " 3.0.7 " ,
44 "description" : " UI components for composing beautiful developer documentation." ,
55 "keywords" : [],
66 "sideEffects" : [
6666 "dependencies" : {
6767 "@stoplight/markdown-viewer" : " ^5.7.1" ,
6868 "@stoplight/mosaic" : " ^1.53.4" ,
69- "@stoplight/elements-core" : " ~9.0.6 " ,
69+ "@stoplight/elements-core" : " ~9.0.7 " ,
7070 "@stoplight/path" : " ^1.3.2" ,
7171 "@stoplight/types" : " ^14.0.0" ,
7272 "classnames" : " ^2.2.6" ,
Original file line number Diff line number Diff line change 11{
22 "name" : " @stoplight/elements" ,
3- "version" : " 9.0.6 " ,
3+ "version" : " 9.0.7 " ,
44 "description" : " UI components for composing beautiful developer documentation." ,
55 "keywords" : [],
66 "sideEffects" : [
6363 ]
6464 },
6565 "dependencies" : {
66- "@stoplight/elements-core" : " ~9.0.4 " ,
66+ "@stoplight/elements-core" : " ~9.0.7 " ,
6767 "@stoplight/http-spec" : " ^7.1.0" ,
6868 "@stoplight/json" : " ^3.18.1" ,
6969 "@stoplight/mosaic" : " ^1.53.4" ,
109109 "release" : {
110110 "extends" : " @stoplight/scripts/release"
111111 }
112- }
112+ }
You can’t perform that action at this time.
0 commit comments