diff --git a/package.json b/package.json
index 7f3cd30a..2da432f3 100644
--- a/package.json
+++ b/package.json
@@ -43,9 +43,10 @@
"dependencies": {
"@fortawesome/free-solid-svg-icons": "^5.15.2",
"@stoplight/json": "^3.10.0",
- "@stoplight/json-schema-tree": "^1.1.3",
+ "@stoplight/json-schema-tree": "^2.0.0",
"@stoplight/mosaic": "1.0.0-beta.46",
"@stoplight/react-error-boundary": "^1.0.0",
+ "@types/json-schema": "^7.0.7",
"classnames": "^2.2.6",
"lodash": "^4.17.19"
},
@@ -61,7 +62,6 @@
"@types/classnames": "^2.2.11",
"@types/enzyme": "^3.10.8",
"@types/jest": "^26.0.18",
- "@types/json-schema": "^7.0.6",
"@types/lodash": "^4.14.149",
"@types/node": "^12.7.2",
"@types/react": "16.9.2",
diff --git a/src/__tests__/__snapshots__/index.spec.tsx.snap b/src/__tests__/__snapshots__/index.spec.tsx.snap
index 0fbc2602..5e959e3c 100644
--- a/src/__tests__/__snapshots__/index.spec.tsx.snap
+++ b/src/__tests__/__snapshots__/index.spec.tsx.snap
@@ -1067,15 +1067,15 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = `
+
+ Allowed value:
+ \\"Constant name\\"
+
Example values:
\\"Example name\\"
\\"Different name\\"
-
- Allowed value:
- \\"Constant name\\"
-
@@ -2816,15 +2816,15 @@ exports[`HTML Output should match default-schema.json 1`] = `
+
+ Allowed value:
+ \\"Constant name\\"
+
Example values:
\\"Example name\\"
\\"Different name\\"
-
- Allowed value:
- \\"Constant name\\"
-
@@ -3671,7 +3671,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
- example
+ examples
diff --git a/src/components/JsonSchemaViewer.tsx b/src/components/JsonSchemaViewer.tsx
index 47d3557a..126a68be 100644
--- a/src/components/JsonSchemaViewer.tsx
+++ b/src/components/JsonSchemaViewer.tsx
@@ -2,15 +2,15 @@ import { isRegularNode, SchemaTree as JsonSchemaTree, SchemaTreeRefDereferenceFn
import { Box, Provider as MosaicProvider } from '@stoplight/mosaic';
import { ErrorBoundaryForwardedProps, FallbackProps, withErrorBoundary } from '@stoplight/react-error-boundary';
import cn from 'classnames';
-import type { JSONSchema4 } from 'json-schema';
import * as React from 'react';
import { JSVOptions, JSVOptionsContextProvider } from '../contexts';
+import type { JSONSchema } from '../types';
import { TopLevelSchemaRow } from './SchemaRow';
import { ChildStack } from './shared/ChildStack';
export type JsonSchemaProps = Partial & {
- schema: JSONSchema4;
+ schema: JSONSchema;
emptyText?: string;
className?: string;
resolveRef?: SchemaTreeRefDereferenceFn;
diff --git a/src/components/shared/Validations.tsx b/src/components/shared/Validations.tsx
index f697f4b4..71879635 100644
--- a/src/components/shared/Validations.tsx
+++ b/src/components/shared/Validations.tsx
@@ -25,7 +25,7 @@ export const numberValidationNames = [
'exclusiveMaximum',
];
-const exampleValidationNames = ['examples', 'example', 'x-example'];
+const exampleValidationNames = ['examples'];
const excludedValidations = ['exclusiveMinimum', 'exclusiveMaximum', 'readOnly', 'writeOnly'];
@@ -58,11 +58,8 @@ const createValidationsFormatter = (name: string, options?: { exact?: boolean; n
};
const validationFormatters: Record ValidationFormat | null> = {
- ['const']: createValidationsFormatter('Allowed'),
enum: createValidationsFormatter('Allowed'),
examples: createValidationsFormatter('Example'),
- example: createValidationsFormatter('Example'),
- ['x-example']: createValidationsFormatter('Example'),
multipleOf: createValidationsFormatter('Multiple of', { exact: true }),
pattern: createValidationsFormatter('Match pattern', { exact: true, nowrap: true }),
default: createValidationsFormatter('Default'),
@@ -208,8 +205,6 @@ export function getValidationsFromSchema(schemaNode: RegularNode) {
? {
...(schemaNode.annotations.default ? { default: schemaNode.annotations.default } : null),
...(schemaNode.annotations.examples ? { examples: schemaNode.annotations.examples } : null),
- ...(schemaNode.annotations.const ? { const: schemaNode.annotations.const } : null),
- ...(schemaNode.annotations['x-example'] ? { ['x-example']: schemaNode.annotations['x-example'] } : null),
}
: null),
...getFilteredValidations(schemaNode),
diff --git a/src/types.ts b/src/types.ts
index ccef917e..54a9cd35 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -1,4 +1,5 @@
import type { ReferenceNode, SchemaNode } from '@stoplight/json-schema-tree';
+import { JSONSchema4, JSONSchema6, JSONSchema7 } from 'json-schema';
import * as React from 'react';
export type GoToRefHandler = (node: ReferenceNode) => void;
@@ -11,3 +12,5 @@ export interface SchemaRowProps {
export type RowAddonRenderer = (props: SchemaRowProps) => React.ReactNode;
export type ViewMode = 'read' | 'write' | 'standalone';
+
+export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
diff --git a/yarn.lock b/yarn.lock
index c99c32b6..d9c02909 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2365,14 +2365,15 @@
json-schema-compare "^0.2.2"
lodash "^4.17.4"
-"@stoplight/json-schema-tree@^1.1.3":
- version "1.1.3"
- resolved "https://registry.yarnpkg.com/@stoplight/json-schema-tree/-/json-schema-tree-1.1.3.tgz#c2aafa1b10c506e7ebec7a4904ff3bd325f7102f"
- integrity sha512-n/mmhLEu4qrZO/UxQBYyPNid2v4Zq6fuzUK9pBMpNxQtxXmmge62lFWDnc3Q8nzXwRio0OPuMmZS9RO0Q0hmOg==
+"@stoplight/json-schema-tree@^2.0.0":
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/@stoplight/json-schema-tree/-/json-schema-tree-2.0.0.tgz#00d54cb6aa2a791c34be91fc30cc92e6d448258c"
+ integrity sha512-vnzcb0TC07xh89lAVGjBTJ2CWvCqmDJDIs3u+gvgvjDPY86CQ0Wl4D2Cmb0iuqd986aiDPc8vDQf1N0dSq5+9A==
dependencies:
- "@stoplight/json" "^3.10.0"
+ "@stoplight/json" "^3.12.0"
"@stoplight/json-schema-merge-allof" "^0.7.5"
"@stoplight/lifecycle" "^2.3.2"
+ "@types/json-schema" "^7.0.7"
magic-error "^0.0.0"
"@stoplight/json@^3.10.0", "@stoplight/json@^3.6":
@@ -2386,6 +2387,17 @@
lodash "^4.17.15"
safe-stable-stringify "^1.1"
+"@stoplight/json@^3.12.0":
+ version "3.12.0"
+ resolved "https://registry.yarnpkg.com/@stoplight/json/-/json-3.12.0.tgz#26c8d32da78eac6a760ba2c9cca6ae717dc417b4"
+ integrity sha512-c0bvFOGICk8QWIat72Td2GG6Bdvq/6O2jQcDZ8rEjh56YOdC/YPn1S8ihKu3AntJCtvqC9eTfadWBqkNK9HAjw==
+ dependencies:
+ "@stoplight/ordered-object-literal" "^1.0.1"
+ "@stoplight/types" "^11.9.0"
+ jsonc-parser "~2.2.1"
+ lodash "^4.17.15"
+ safe-stable-stringify "^1.1"
+
"@stoplight/lifecycle@^2.3.2":
version "2.3.2"
resolved "https://registry.yarnpkg.com/@stoplight/lifecycle/-/lifecycle-2.3.2.tgz#d61dff9ba20648241432e2daaef547214dc8976e"
@@ -3200,11 +3212,16 @@
jest-diff "^26.0.0"
pretty-format "^26.0.0"
-"@types/json-schema@^7.0.3", "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.6":
+"@types/json-schema@^7.0.3", "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5":
version "7.0.6"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0"
integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==
+"@types/json-schema@^7.0.7":
+ version "7.0.7"
+ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
+ integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==
+
"@types/json5@^0.0.29":
version "0.0.29"
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"