Skip to content

Commit 2930cb1

Browse files
authored
fix(json-schema-viewer): Description for oneOf/anyOf does not display (#176)
* fix(json-viewer-schema): Description not showing on oneOf and anyOf * removed <div> failing test * changes made per @P0lip request * removed storybook code * removed <div> to pass test
1 parent 2a5f00e commit 2930cb1

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/__stories__/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
// NOTE: The ordering of these imports determines the ordering in Storybook
22
import './JsonSchemaViewer';
3+
import './SchemaRow';

src/components/SchemaRow/SchemaRow.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ export interface SchemaRowProps {
2525
}
2626

2727
export const SchemaRow: React.FunctionComponent<SchemaRowProps> = ({ schemaNode, nestingLevel }) => {
28-
const description = isRegularNode(schemaNode) ? schemaNode.annotations.description : null;
29-
3028
const { defaultExpandedDepth, renderRowAddon, onGoToRef, hideExamples } = useJSVOptionsContext();
3129

3230
const [isExpanded, setExpanded] = React.useState<boolean>(
@@ -35,6 +33,7 @@ export const SchemaRow: React.FunctionComponent<SchemaRowProps> = ({ schemaNode,
3533

3634
const { selectedChoice, setSelectedChoice, choices } = useChoices(schemaNode);
3735
const typeToShow = selectedChoice.type;
36+
const description = isRegularNode(typeToShow) ? typeToShow.annotations.description : null;
3837

3938
const refNode = React.useMemo<ReferenceNode | null>(() => {
4039
if (isReferenceNode(schemaNode)) {
@@ -119,7 +118,6 @@ export const SchemaRow: React.FunctionComponent<SchemaRowProps> = ({ schemaNode,
119118
validations={isRegularNode(schemaNode) ? schemaNode.validations : {}}
120119
/>
121120
</div>
122-
123121
{typeof description === 'string' && description.length > 0 && (
124122
<div className="sl-flex sl-flex-1 sl-my-2 sl-text-base">
125123
<Description value={description} />

0 commit comments

Comments
 (0)