diff --git a/src/__tests__/__snapshots__/index.spec.tsx.snap b/src/__tests__/__snapshots__/index.spec.tsx.snap index 208f8e89..e3252ab4 100644 --- a/src/__tests__/__snapshots__/index.spec.tsx.snap +++ b/src/__tests__/__snapshots__/index.spec.tsx.snap @@ -3,15 +3,15 @@ exports[`Expanded depth nested object static given initial level set to 0, should render top 2 levels 1`] = ` "
-
-
-
+
+
+
-
+
bar
object @@ -28,7 +28,7 @@ exports[`Expanded depth nested object static given initial level set to 0, shoul
-
+
foo
array[object] @@ -50,15 +50,15 @@ exports[`Expanded depth nested object static given initial level set to 0, shoul exports[`Expanded depth nested object static given initial level set to 1, should render top 3 levels 1`] = ` "
-
-
-
+
+
+
-
+
bar
object @@ -68,13 +68,13 @@ exports[`Expanded depth nested object static given initial level set to 1, shoul
-
+
-
+
barFoo
object @@ -125,7 +125,7 @@ exports[`Expanded depth nested object static given initial level set to 1, shoul
-
+
foo
array[object] @@ -135,7 +135,7 @@ exports[`Expanded depth nested object static given initial level set to 1, shoul
-
+
@@ -180,15 +180,15 @@ exports[`Expanded depth nested object static given initial level set to 1, shoul exports[`Expanded depth nested object static given initial level set to 2, should render top 4 levels 1`] = ` "
-
-
-
+
+
+
-
+
bar
object @@ -198,13 +198,13 @@ exports[`Expanded depth nested object static given initial level set to 2, shoul
-
+
-
+
barFoo
object @@ -214,7 +214,7 @@ exports[`Expanded depth nested object static given initial level set to 2, shoul
-
+
@@ -272,7 +272,7 @@ exports[`Expanded depth nested object static given initial level set to 2, shoul
-
+
foo
array[object] @@ -282,7 +282,7 @@ exports[`Expanded depth nested object static given initial level set to 2, shoul
-
+
@@ -327,8 +327,8 @@ exports[`Expanded depth nested object static given initial level set to 2, shoul exports[`HTML Output given anyOf combiner placed next to allOf given allOf merging enabled, should merge contents of allOf combiners 1`] = ` "
-
-
+
+
@@ -337,7 +337,7 @@ exports[`HTML Output given anyOf combiner placed next to allOf given allOf mergi
anyOf
-
+
@@ -438,8 +438,8 @@ exports[`HTML Output given anyOf combiner placed next to allOf given allOf mergi exports[`HTML Output given array with oneOf containing items, should merge it correctly 1`] = ` "
-
-
+
+
@@ -459,9 +459,9 @@ exports[`HTML Output given array with oneOf containing items, should merge it co exports[`HTML Output given complex type that includes array and complex array subtype, should not ignore subtype 1`] = ` "
-
-
-
+
+
+
@@ -500,13 +500,13 @@ exports[`HTML Output given complex type that includes array and complex array su exports[`HTML Output given multiple object and string type, should process properties 1`] = ` "
-
+
-
+
string @@ -519,7 +519,7 @@ exports[`HTML Output given multiple object and string type, should process prope
-
+
@@ -546,8 +546,8 @@ exports[`HTML Output given multiple object and string type, should process prope exports[`HTML Output given oneOf combiner placed next to allOf given allOf merging enabled, should merge contents of allOf combiners 1`] = ` "
-
-
+
+
@@ -556,7 +556,7 @@ exports[`HTML Output given oneOf combiner placed next to allOf given allOf mergi
oneOf
-
+
@@ -657,13 +657,13 @@ exports[`HTML Output given oneOf combiner placed next to allOf given allOf mergi exports[`HTML Output given read mode, should populate proper nodes 1`] = ` "
-
+
-
+
string @@ -676,7 +676,7 @@ exports[`HTML Output given read mode, should populate proper nodes 1`] = `
-
+
@@ -703,13 +703,13 @@ exports[`HTML Output given read mode, should populate proper nodes 1`] = ` exports[`HTML Output given standalone mode, should populate proper nodes 1`] = ` "
-
+
-
+
string @@ -722,7 +722,7 @@ exports[`HTML Output given standalone mode, should populate proper nodes 1`] = `
-
+
@@ -767,15 +767,15 @@ exports[`HTML Output given standalone mode, should populate proper nodes 1`] = ` exports[`HTML Output given visible $ref node, should try to inject the title immediately 1`] = ` "
-
-
-
+
+
+
-
+
foo
User @@ -785,7 +785,7 @@ exports[`HTML Output given visible $ref node, should try to inject the title imm
-
+
@@ -809,7 +809,7 @@ exports[`HTML Output given visible $ref node, should try to inject the title imm
-
+
user
User @@ -831,13 +831,13 @@ exports[`HTML Output given visible $ref node, should try to inject the title imm exports[`HTML Output given write mode, should populate proper nodes 1`] = ` "
-
+
-
+
string @@ -850,7 +850,7 @@ exports[`HTML Output given write mode, should populate proper nodes 1`] = `
-
+
@@ -877,15 +877,15 @@ exports[`HTML Output given write mode, should populate proper nodes 1`] = ` exports[`HTML Output should match arrays/of-allofs.json 1`] = ` "
-
-
-
+
+
+
-
+
array-all-objects
array[object] @@ -895,7 +895,7 @@ exports[`HTML Output should match arrays/of-allofs.json 1`] = `
-
+
@@ -940,11 +940,11 @@ exports[`HTML Output should match arrays/of-allofs.json 1`] = ` exports[`HTML Output should match arrays/of-arrays.json 1`] = ` "
-
-
+
+
array of:
-
+
@@ -988,11 +988,11 @@ exports[`HTML Output should match arrays/of-arrays.json 1`] = ` exports[`HTML Output should match arrays/of-complex-objects.json 1`] = ` "
-
-
+
+
array of:
-
+
@@ -1152,7 +1152,7 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = `
-
+
plan
@@ -1187,7 +1187,7 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = ` id=\\"react-aria-0-4\\" aria-labelledby=\\"react-aria-0-4 react-aria-0-6\\" type=\\"button\\" - class=\\"active:sl-bg-canvas-100 hover:sl-border-input focus:sl-border-input active:sl-border-button disabled:sl-opacity-50\\" + class=\\"hover:sl-border-input focus:sl-border-primary active:sl-border-primary disabled:sl-opacity-60\\" >
object
@@ -1201,7 +1201,7 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = `
-
+
@@ -1243,7 +1243,7 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = `
-
+
permissions
@@ -1257,7 +1257,7 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = `
-
+
@@ -1354,15 +1354,15 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = ` exports[`HTML Output should match arrays/of-objects.json 1`] = ` "
-
-
-
+
+
+
-
+
propertyIsArrayOfObjects
array[object] @@ -1372,7 +1372,7 @@ exports[`HTML Output should match arrays/of-objects.json 1`] = `
-
+
@@ -1401,20 +1401,20 @@ exports[`HTML Output should match arrays/of-objects.json 1`] = ` exports[`HTML Output should match arrays/of-refs.json 1`] = ` "
-
+
-
+
$ref(./models/todo-full.json)[]
-
+
@@ -1438,20 +1438,20 @@ exports[`HTML Output should match arrays/of-refs.json 1`] = ` exports[`HTML Output should match arrays/with-multiple-arrayish-items.json 1`] = ` "
-
+
-
+
array
-
+
@@ -1470,14 +1470,14 @@ exports[`HTML Output should match arrays/with-multiple-arrayish-items.json 1`] =
-
+
object
-
+
@@ -1540,20 +1540,20 @@ exports[`HTML Output should match arrays/with-multiple-arrayish-items.json 1`] = exports[`HTML Output should match arrays/with-ordered-items.json 1`] = ` "
-
+
-
+
array
-
+
@@ -1590,11 +1590,11 @@ exports[`HTML Output should match arrays/with-ordered-items.json 1`] = ` exports[`HTML Output should match arrays/with-single-arrayish-items.json 1`] = ` "
-
-
+
+
array of:
-
+
@@ -1656,15 +1656,15 @@ exports[`HTML Output should match arrays/with-single-arrayish-items.json 1`] = ` exports[`HTML Output should match combiners/allOfs/base.json 1`] = ` "
-
-
-
+
+
+
-
+
AllOfMergeObjects
object @@ -1674,7 +1674,7 @@ exports[`HTML Output should match combiners/allOfs/base.json 1`] = `
-
+
@@ -1753,7 +1753,7 @@ exports[`HTML Output should match combiners/allOfs/base.json 1`] = `
-
+
AllOfMergeObjectPropertyValidations
object @@ -1763,7 +1763,7 @@ exports[`HTML Output should match combiners/allOfs/base.json 1`] = `
-
+
@@ -1791,7 +1791,7 @@ exports[`HTML Output should match combiners/allOfs/base.json 1`] = `
-
+
AllOfMergeRefs
object @@ -1801,7 +1801,7 @@ exports[`HTML Output should match combiners/allOfs/base.json 1`] = `
-
+
@@ -1881,15 +1881,15 @@ exports[`HTML Output should match combiners/allOfs/base.json 1`] = ` exports[`HTML Output should match combiners/allOfs/complex.json 1`] = ` "
-
-
-
+
+
+
-
+
foo
object @@ -1899,13 +1899,13 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
-
+
-
+
user
allOf @@ -1916,26 +1916,26 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
-
+
-
+
object
-
+
-
+
names
@@ -1947,7 +1947,7 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
-
+
@@ -1972,7 +1972,7 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
-
+
users
array[object] @@ -1982,13 +1982,13 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
-
+
-
+
creation
object @@ -1998,13 +1998,13 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
-
+
-
+
user
allOf @@ -2015,13 +2015,13 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
-
+
-
+
object
@@ -2083,7 +2083,7 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
-
+
bar
object @@ -2093,13 +2093,13 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
-
+
-
+
foo
object @@ -2109,13 +2109,13 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
-
+
-
+
user
allOf @@ -2126,13 +2126,13 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
-
+
-
+
object
@@ -2157,11 +2157,11 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = ` exports[`HTML Output should match combiners/allOfs/todo-full.json 1`] = ` "
-
-
+
+
array of:
-
+
@@ -2281,7 +2281,7 @@ exports[`HTML Output should match combiners/allOfs/todo-full.json 1`] = `
-
+
user
User @@ -2292,7 +2292,7 @@ exports[`HTML Output should match combiners/allOfs/todo-full.json 1`] = `
-
+
@@ -2347,9 +2347,9 @@ exports[`HTML Output should match combiners/allOfs/todo-full.json 1`] = ` exports[`HTML Output should match combiners/allOfs/todo-full-2.json 1`] = ` "
-
-
-
+
+
+
@@ -2452,8 +2452,8 @@ exports[`HTML Output should match combiners/allOfs/todo-full-2.json 1`] = ` exports[`HTML Output should match combiners/allOfs/with-type.json 1`] = ` "
-
-
+
+
@@ -2462,7 +2462,7 @@ exports[`HTML Output should match combiners/allOfs/with-type.json 1`] = `
oneOf
-
+
@@ -2584,8 +2584,8 @@ exports[`HTML Output should match combiners/allOfs/with-type.json 1`] = ` exports[`HTML Output should match combiners/oneof-with-array-type.json 1`] = ` "
-
-
+
+
@@ -2594,7 +2594,7 @@ exports[`HTML Output should match combiners/oneof-with-array-type.json 1`] = `
oneOf
-
+
@@ -2642,8 +2642,8 @@ exports[`HTML Output should match combiners/oneof-with-array-type.json 1`] = ` exports[`HTML Output should match combiners/oneof-within-array-item.json 1`] = ` "
-
-
+
+
@@ -2651,7 +2651,7 @@ exports[`HTML Output should match combiners/oneof-within-array-item.json 1`] = `
-
+
@@ -2683,9 +2683,9 @@ exports[`HTML Output should match combiners/oneof-within-array-item.json 1`] = ` exports[`HTML Output should match default-schema.json 1`] = ` "
-
-
-
+
+
+
@@ -2848,7 +2848,7 @@ exports[`HTML Output should match default-schema.json 1`] = `
-
+
plan
@@ -2883,7 +2883,7 @@ exports[`HTML Output should match default-schema.json 1`] = ` id=\\"react-aria-0-4\\" aria-labelledby=\\"react-aria-0-4 react-aria-0-6\\" type=\\"button\\" - class=\\"active:sl-bg-canvas-100 hover:sl-border-input focus:sl-border-input active:sl-border-button disabled:sl-opacity-50\\" + class=\\"hover:sl-border-input focus:sl-border-primary active:sl-border-primary disabled:sl-opacity-60\\" >
object
@@ -2897,7 +2897,7 @@ exports[`HTML Output should match default-schema.json 1`] = `
-
+
@@ -2939,7 +2939,7 @@ exports[`HTML Output should match default-schema.json 1`] = `
-
+
permissions
@@ -2953,7 +2953,7 @@ exports[`HTML Output should match default-schema.json 1`] = `
-
+
@@ -2977,7 +2977,7 @@ exports[`HTML Output should match default-schema.json 1`] = `
-
+
ref
@@ -3054,9 +3054,9 @@ exports[`HTML Output should match default-schema.json 1`] = ` exports[`HTML Output should match formats-schema.json 1`] = ` "
-
-
-
+
+
+
@@ -3134,7 +3134,7 @@ exports[`HTML Output should match formats-schema.json 1`] = `
-
+
permissions
@@ -3149,7 +3149,7 @@ exports[`HTML Output should match formats-schema.json 1`] = `
-
+
@@ -3178,15 +3178,15 @@ exports[`HTML Output should match formats-schema.json 1`] = ` exports[`HTML Output should match references/base.json 1`] = ` "
-
-
-
+
+
+
-
+
billing_address
object @@ -3196,7 +3196,7 @@ exports[`HTML Output should match references/base.json 1`] = `
-
+
@@ -3255,7 +3255,7 @@ exports[`HTML Output should match references/base.json 1`] = `
-
+
shipping_address
object @@ -3277,15 +3277,15 @@ exports[`HTML Output should match references/base.json 1`] = ` exports[`HTML Output should match references/nested.json 1`] = ` "
-
-
-
+
+
+
-
+
parent
object @@ -3298,13 +3298,13 @@ exports[`HTML Output should match references/nested.json 1`] = `
-
+
-
+
parent
object @@ -3331,9 +3331,9 @@ exports[`HTML Output should match references/nested.json 1`] = ` exports[`HTML Output should match references/nullish.json 1`] = ` "
-
-
-
+
+
+
@@ -3360,15 +3360,15 @@ exports[`HTML Output should match references/nullish.json 1`] = ` exports[`HTML Output should match tickets.schema.json 1`] = ` "
-
-
-
+
+
+
-
+
availableTicketingOptions
$ref(../TicketingOptionInfo/TicketingOptionInfo.v1-0.yaml)[] @@ -3383,7 +3383,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
-
+
@@ -3425,7 +3425,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
-
+
ticketingOptionChoice
array[object] @@ -3440,7 +3440,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
-
+
@@ -3481,7 +3481,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
-
+
orderItemBreakdown
array[object] @@ -3496,7 +3496,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
-
+
@@ -3519,7 +3519,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
-
+
options
array[object] @@ -3534,7 +3534,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
-
+
@@ -3618,7 +3618,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
-
+
deliveryInfo
object @@ -3633,7 +3633,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
-
+
diff --git a/src/__tests__/index.spec.tsx b/src/__tests__/index.spec.tsx index 2b0851a3..6620923a 100644 --- a/src/__tests__/index.spec.tsx +++ b/src/__tests__/index.spec.tsx @@ -238,17 +238,17 @@ describe('Expanded depth', () => { expect(dumpDom(wrapper.getElement())).toMatchInlineSnapshot(` "
-
-
+
+
array of:
-
+
-
+
foo
array[object] @@ -275,17 +275,17 @@ describe('Expanded depth', () => { expect(dumpDom(wrapper.getElement())).toMatchInlineSnapshot(` "
-
-
+
+
array of:
-
+
-
+
foo
array[object] @@ -312,17 +312,17 @@ describe('Expanded depth', () => { expect(dumpDom(wrapper.getElement())).toMatchInlineSnapshot(` "
-
-
+
+
array of:
-
+
-
+
foo
array[object] @@ -332,13 +332,13 @@ describe('Expanded depth', () => {
-
+
-
+
bar
object @@ -401,11 +401,11 @@ describe('Expanded depth', () => { expect(dumpDom(wrapper.getElement())).toMatchInlineSnapshot(` "
-
-
+
+
array of:
-
+
@@ -427,7 +427,7 @@ describe('Expanded depth', () => {
-
+
foo
array[object] @@ -454,11 +454,11 @@ describe('Expanded depth', () => { expect(dumpDom(wrapper.getElement())).toMatchInlineSnapshot(` "
-
-
+
+
array of:
-
+
@@ -480,7 +480,7 @@ describe('Expanded depth', () => {
-
+
foo
array[object] @@ -507,11 +507,11 @@ describe('Expanded depth', () => { expect(dumpDom(wrapper.getElement())).toMatchInlineSnapshot(` "
-
-
+
+
array of:
-
+
@@ -533,7 +533,7 @@ describe('Expanded depth', () => {
-
+
foo
array[object] @@ -543,7 +543,7 @@ describe('Expanded depth', () => {
-
+
@@ -640,15 +640,15 @@ describe('Expanded depth', () => { expect(dumpDom(wrapper.getElement())).toMatchInlineSnapshot(` "
-
-
-
+
+
+
-
+
bar
object @@ -665,7 +665,7 @@ describe('Expanded depth', () => {
-
+
foo
array[object] @@ -720,7 +720,7 @@ describe('$ref resolving', () => { expect(dumpDom()).toMatchInlineSnapshot(` "
-
+
@@ -751,20 +751,20 @@ describe('$ref resolving', () => { expect(dumpDom()).toMatchInlineSnapshot(` "
-
+
-
+
$ref(#/foo)[]
-
+
diff --git a/src/components/JsonSchemaViewer.tsx b/src/components/JsonSchemaViewer.tsx index d06568e0..494d802d 100644 --- a/src/components/JsonSchemaViewer.tsx +++ b/src/components/JsonSchemaViewer.tsx @@ -89,7 +89,11 @@ const JsonSchemaViewerComponent: React.FC{emptyText}; + return ( + + {emptyText} + + ); } return ( @@ -98,7 +102,7 @@ const JsonSchemaViewerComponent: React.FC @@ -109,7 +113,9 @@ const JsonSchemaViewerComponent: React.FC = ({ error }) => { return ( - Error + + Error + {error !== null ? `: ${error.message}` : null} ); diff --git a/src/components/SchemaRow/SchemaRow.tsx b/src/components/SchemaRow/SchemaRow.tsx index 5ad9748b..1cd6d79a 100644 --- a/src/components/SchemaRow/SchemaRow.tsx +++ b/src/components/SchemaRow/SchemaRow.tsx @@ -7,8 +7,7 @@ import { SchemaNode, SchemaNodeKind, } from '@stoplight/json-schema-tree'; -import { Icon, Select } from '@stoplight/mosaic'; -import cn from 'classnames'; +import { Box, Flex, Icon, Select } from '@stoplight/mosaic'; import last from 'lodash/last.js'; import * as React from 'react'; @@ -56,19 +55,21 @@ export const SchemaRow: React.FunctionComponent = ({ schemaNode, const childNodes = React.useMemo(() => calculateChildrenToShow(typeToShow), [typeToShow]); const combiner = isRegularNode(schemaNode) && schemaNode.combiners?.length ? schemaNode.combiners[0] : null; return ( -
-
-
-
+ + + 0 ? () => setExpanded(!isExpanded) : undefined} - className={cn({ 'sl-cursor-pointer': childNodes.length > 0 })} + cursor={childNodes.length > 0 ? 'pointer' : undefined} > -
+ {childNodes.length > 0 ? : null} -
+ {schemaNode.subpath.length > 0 && shouldShowPropertyName(schemaNode) && ( -
{last(schemaNode.subpath)}
+ + {last(schemaNode.subpath)} + )} {choices.length === 1 && ( @@ -79,8 +80,11 @@ export const SchemaRow: React.FunctionComponent = ({ schemaNode, )} {onGoToRef && isReferenceNode(schemaNode) && schemaNode.external ? ( - { e.preventDefault(); e.stopPropagation(); @@ -88,11 +92,13 @@ export const SchemaRow: React.FunctionComponent = ({ schemaNode, }} > (go to ref) - + ) : null} {schemaNode.subpath.length > 1 && schemaNode.subpath[0] === 'patternProperties' ? ( -
(pattern property)
+ + (pattern property) + ) : null} {choices.length > 1 && (
"`, + `"
"`, ); }); @@ -164,7 +164,7 @@ describe('Property component', () => { const wrapper = render(schema); expect(wrapper.html()).toMatchInlineSnapshot( - `"
array[object]
foo
bar
baz
"`, + `"
array[object]
foo
bar
baz
"`, ); }); @@ -199,12 +199,12 @@ describe('Property component', () => { let wrapper = render(schema, ['properties', 'array-all-objects', 'items', 'properties', 'foo']); expect(wrapper.html()).toMatchInlineSnapshot( - `"
foo
string
"`, + `"
foo
string
"`, ); wrapper = render(schema, ['properties', 'array-all-objects', 'items', 'properties', 'bar']); expect(wrapper.html()).toMatchInlineSnapshot( - `"
bar
string
"`, + `"
bar
string
"`, ); }); @@ -224,7 +224,7 @@ describe('Property component', () => { const wrapper = mount(); expect(wrapper.html()).toMatchInlineSnapshot( - `"
foo
object
"`, + `"
foo
object
"`, ); wrapper.unmount(); }); diff --git a/src/consts.ts b/src/consts.ts index d52255d6..ab4239ae 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -1,4 +1,5 @@ import { SchemaCombinerName } from '@stoplight/json-schema-tree'; +import { NegativeSpaceVals, SpaceVals } from '@stoplight/mosaic'; import { Dictionary } from '@stoplight/types'; export const COMBINER_PRETTY_NAMES: Readonly> = { @@ -7,7 +8,10 @@ export const COMBINER_PRETTY_NAMES: Readonly