Skip to content

Commit 59b51b6

Browse files
committed
feat: collapsible refs
1 parent 0269218 commit 59b51b6

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

src/components/SchemaRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const SchemaRow: React.FunctionComponent<ISchemaRow> = ({ className, node
5555
</div>
5656

5757
<Validations
58-
required={false}
58+
required={/* todo: implement me */ false}
5959
// required={!!schemaNode.required}
6060
validations={{
6161
...('annotations' in schemaNode &&

src/components/shared/Property.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import { JsonPath } from '@stoplight/types';
22
import { size as _size } from 'lodash-es';
33
import * as React from 'react';
44
import { GoToRefHandler, IArrayNode, IObjectNode, SchemaKind, SchemaNode } from '../../types';
5-
import { isArrayNodeWithItems } from '../../utils/guards';
5+
import { isArrayNodeWithItems, isCombinerNode, isRefNode } from '../../utils/guards';
66
import { inferType } from '../../utils/inferType';
7-
import { isCombinerNode, isRefNode } from '../../utils/nodes';
87
import { Types } from './Types';
98

109
export interface IProperty {

src/tree/populateTree.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { JsonPath } from '@stoplight/types';
44
import { JSONSchema4 } from 'json-schema';
55
import { IArrayNode, IObjectNode, SchemaKind, SchemaTreeListNode } from '../types';
66
import { getPrimaryType } from '../utils/getPrimaryType';
7+
import { isCombinerNode, isRefNode } from '../utils/guards';
78
import { isCombiner } from '../utils/isCombiner';
8-
import { isCombinerNode, isRefNode } from '../utils/nodes';
99
import { MetadataStore } from './metadata';
1010
import { walk } from './walk';
1111

@@ -39,7 +39,7 @@ export const populateTree: Walker = (schema, parent, level, path, options) => {
3939
};
4040

4141
if (isRefNode(node) && isLocalRef(node.$ref) && node.$ref !== '#') {
42-
(node as TreeListParentNode).children = [];
42+
(treeNode as TreeListParentNode).children = [];
4343
} else if (isCombinerNode(node)) {
4444
if (node.properties !== void 0) {
4545
(treeNode as TreeListParentNode).children = [];

src/utils/__tests__/isCombiner.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isCombinerNode } from '../nodes';
1+
import { isCombinerNode } from '../guards';
22

33
describe('isCombinerNode function', () => {
44
test('should return false if object without combiner is given', () => {

src/utils/guards.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { JSONSchema4 } from 'json-schema';
22
import { isObjectLike as _isObjectLike } from 'lodash-es';
3-
import { IArrayNode, SchemaKind, SchemaNode } from '../types';
3+
import { IArrayNode, ICombinerNode, IRefNode, SchemaKind, SchemaNode } from '../types';
44

55
export const isArrayNodeWithItems = (
66
node: SchemaNode,
77
): node is Omit<IArrayNode, 'items'> & { items: JSONSchema4 | JSONSchema4[] } =>
88
'type' in node && 'items' in node && node.type === SchemaKind.Array && _isObjectLike(node.items);
9+
10+
export const isRefNode = (node: SchemaNode): node is IRefNode => '$ref' in node;
11+
12+
export const isCombinerNode = (node: SchemaNode): node is ICombinerNode => 'combiner' in node;

src/utils/nodes.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)