diff --git a/src/components/JsonSchemaViewer.tsx b/src/components/JsonSchemaViewer.tsx
index ddbe7b80..058f8415 100644
--- a/src/components/JsonSchemaViewer.tsx
+++ b/src/components/JsonSchemaViewer.tsx
@@ -66,7 +66,7 @@ const JsonSchemaViewerComponent: React.FC
diff --git a/src/components/SchemaRow/SchemaRow.tsx b/src/components/SchemaRow/SchemaRow.tsx
index 1793cbe2..e11879c3 100644
--- a/src/components/SchemaRow/SchemaRow.tsx
+++ b/src/components/SchemaRow/SchemaRow.tsx
@@ -3,6 +3,7 @@ import {
isMirroredNode,
isReferenceNode,
isRegularNode,
+ isRootNode,
ReferenceNode,
SchemaNode,
SchemaNodeKind,
@@ -56,9 +57,13 @@ export const SchemaRow: React.FunctionComponent
= ({ schemaNode,
const isBrokenRef = typeof refNode?.error === 'string';
const childNodes = React.useMemo(() => calculateChildrenToShow(typeToShow), [typeToShow]);
-
return (
-
+
= ({ schemaNode,
/>
) : null}
-
+
{schemaNode.subpath.length > 0 && shouldShowPropertyName(schemaNode) && (
{last(schemaNode.subpath)}
)}
@@ -137,7 +142,7 @@ export const SchemaRow: React.FunctionComponent
= ({ schemaNode,
{typeof description === 'string' && description.length > 0 && (
-
+
)}
diff --git a/src/components/shared/Caret.tsx b/src/components/shared/Caret.tsx
index b1c1f3b6..59e591e1 100644
--- a/src/components/shared/Caret.tsx
+++ b/src/components/shared/Caret.tsx
@@ -10,7 +10,7 @@ export interface ICaret {
export const Caret: React.FunctionComponent
= ({ style, size, isExpanded }) => (
diff --git a/src/components/shared/Validations.tsx b/src/components/shared/Validations.tsx
index bf1edcd1..b7187f12 100644
--- a/src/components/shared/Validations.tsx
+++ b/src/components/shared/Validations.tsx
@@ -1,5 +1,6 @@
import { RegularNode } from '@stoplight/json-schema-tree';
import { Dictionary } from '@stoplight/types';
+import cn from 'classnames';
import { capitalize, keys, omit, pick, pickBy, uniq } from 'lodash';
import * as React from 'react';
@@ -99,9 +100,7 @@ const NumberValidations = ({
{entries
.map(([key, value]) => numberValidationFormatters[key](value))
.map((value, i) => (
-
- {value}
-
+
))}
);
@@ -127,9 +126,7 @@ const KeyValueValidation = ({ name, values }: { name: string; values: string[] }
{capitalize(name)}:
{uniq(values).map(value => (
-
- {value}
-
+
))}
);
@@ -137,20 +134,27 @@ const KeyValueValidation = ({ name, values }: { name: string; values: string[] }
const NameValidations = ({ validations }: { validations: Dictionary }) => (
<>
- {keys(validations)
- .filter(key => validations[key])
- .map(key => {
- return (
-
-
- {key}
-
-
- );
- })}
+ {keys(validations).length ? (
+
+ {keys(validations)
+ .filter(key => validations[key])
+ .map(key => (
+
+ ))}
+
+ ) : null}
>
);
+const Value = ({ name, className }: { name: string; className?: string }) => (
+
+ {name}
+
+);
+
export function validationCount(schemaNode: RegularNode) {
const validations = getValidationsFromSchema(schemaNode);
const validationKeys = keys(omit(validations, excludedValidations));
diff --git a/src/components/shared/__tests__/Property.spec.tsx b/src/components/shared/__tests__/Property.spec.tsx
index 4674f726..14aad0c4 100644
--- a/src/components/shared/__tests__/Property.spec.tsx
+++ b/src/components/shared/__tests__/Property.spec.tsx
@@ -83,7 +83,7 @@ describe('Property component', () => {
const wrapper = render(schema, ['properties', 'foo']);
expect(wrapper.find(SchemaRow).html()).toMatchInlineSnapshot(
- `""`,
+ `""`,
);
});
@@ -102,7 +102,7 @@ describe('Property component', () => {
const wrapper = render(schema, ['properties', 'foo']);
expect(wrapper.find(SchemaRow).html()).toMatchInlineSnapshot(
- `""`,
+ `""`,
);
});
@@ -120,7 +120,7 @@ describe('Property component', () => {
const wrapper = render(schema, ['items', 'properties', 'foo']);
expect(wrapper.html()).toMatchInlineSnapshot(
- `""`,
+ `""`,
);
});
@@ -141,7 +141,7 @@ describe('Property component', () => {
const wrapper = render(schema);
expect(wrapper.html()).toMatchInlineSnapshot(
- `""`,
+ `""`,
);
});
@@ -164,7 +164,7 @@ describe('Property component', () => {
const wrapper = render(schema);
expect(wrapper.html()).toMatchInlineSnapshot(
- `""`,
+ `""`,
);
});
@@ -199,12 +199,12 @@ describe('Property component', () => {
let wrapper = render(schema, ['properties', 'array-all-objects', 'items', 'properties', 'foo']);
expect(wrapper.html()).toMatchInlineSnapshot(
- `""`,
+ `""`,
);
wrapper = render(schema, ['properties', 'array-all-objects', 'items', 'properties', 'bar']);
expect(wrapper.html()).toMatchInlineSnapshot(
- `""`,
+ `""`,
);
});
@@ -224,7 +224,7 @@ describe('Property component', () => {
const wrapper = mount();
expect(wrapper.html()).toMatchInlineSnapshot(
- `""`,
+ `""`,
);
wrapper.unmount();
});
diff --git a/src/index.ts b/src/index.ts
index 598bd62c..f07e59b3 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,2 +1,2 @@
-export { JsonSchemaViewer } from './components';
+export { JsonSchemaViewer, Validations } from './components';
export * from './types';