diff --git a/src/__tests__/index.spec.tsx b/src/__tests__/index.spec.tsx
index d6d28845..33cffbc8 100644
--- a/src/__tests__/index.spec.tsx
+++ b/src/__tests__/index.spec.tsx
@@ -165,7 +165,7 @@ describe('HTML Output', () => {
expect(dumpDom(
)).toMatchSnapshot();
});
- it('should render top-level description on allOf', () => {
+ describe('top level descriptions', () => {
const schema: JSONSchema4 = {
description: 'This is a description that should be rendered',
allOf: [
@@ -188,7 +188,15 @@ describe('HTML Output', () => {
],
};
- expect(dumpDom(
)).toMatchSnapshot();
+ it('should render top-level description on allOf', () => {
+ expect(dumpDom(
)).toMatchSnapshot();
+ });
+
+ it('should not render top-level description when skipTopLevelDescription=true', () => {
+ expect(
+ dumpDom(
),
+ ).toMatchSnapshot();
+ });
});
});
diff --git a/src/components/JsonSchemaViewer.tsx b/src/components/JsonSchemaViewer.tsx
index d4d99ae3..444a4640 100644
--- a/src/components/JsonSchemaViewer.tsx
+++ b/src/components/JsonSchemaViewer.tsx
@@ -26,6 +26,7 @@ export type JsonSchemaProps = Partial
& {
onTreePopulated?: (props: { rootNode: RootNode; nodeCount: number }) => void;
maxHeight?: number;
parentCrumbs?: string[];
+ skipTopLevelDescription?: boolean;
};
const JsonSchemaViewerComponent = ({
@@ -37,6 +38,7 @@ const JsonSchemaViewerComponent = ({
renderRootTreeLines,
disableCrumbs,
nodeHasChanged,
+ skipTopLevelDescription,
...rest
}: JsonSchemaProps & ErrorBoundaryForwardedProps) => {
const options = React.useMemo(
@@ -66,7 +68,7 @@ const JsonSchemaViewerComponent = ({
-
+
@@ -82,9 +84,18 @@ const JsonSchemaViewerInner = ({
onTreePopulated,
maxHeight,
parentCrumbs,
+ skipTopLevelDescription,
}: Pick<
JsonSchemaProps,
- 'schema' | 'viewMode' | 'className' | 'resolveRef' | 'emptyText' | 'onTreePopulated' | 'maxHeight' | 'parentCrumbs'
+ | 'schema'
+ | 'viewMode'
+ | 'className'
+ | 'resolveRef'
+ | 'emptyText'
+ | 'onTreePopulated'
+ | 'maxHeight'
+ | 'parentCrumbs'
+ | 'skipTopLevelDescription'
>) => {
const setHoveredNode = useUpdateAtom(hoveredNodeAtom);
const onMouseLeave = React.useCallback(() => {
@@ -153,7 +164,7 @@ const JsonSchemaViewerInner = ({
style={{ maxHeight }}
>
-
+
);
};
diff --git a/src/components/SchemaRow/TopLevelSchemaRow.tsx b/src/components/SchemaRow/TopLevelSchemaRow.tsx
index dc567026..9e101043 100644
--- a/src/components/SchemaRow/TopLevelSchemaRow.tsx
+++ b/src/components/SchemaRow/TopLevelSchemaRow.tsx
@@ -13,7 +13,10 @@ import { getInternalSchemaError } from '../shared/Validations';
import { SchemaRow, SchemaRowProps } from './SchemaRow';
import { useChoices } from './useChoices';
-export const TopLevelSchemaRow = ({ schemaNode }: Pick) => {
+export const TopLevelSchemaRow = ({
+ schemaNode,
+ skipDescription,
+}: Pick & { skipDescription?: boolean }) => {
const { selectedChoice, setSelectedChoice, choices } = useChoices(schemaNode);
const childNodes = React.useMemo(() => calculateChildrenToShow(selectedChoice.type), [selectedChoice.type]);
const nestingLevel = 0;
@@ -27,7 +30,7 @@ export const TopLevelSchemaRow = ({ schemaNode }: Pick
-
+ {!skipDescription ? : null}