Skip to content

Commit 4e49cbf

Browse files
committed
fix: pattern property + divider
1 parent c523823 commit 4e49cbf

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/components/SchemaRow.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,9 @@ const ICON_SIZE = 12;
2222
const ICON_DIMENSION = 20;
2323
const ROW_OFFSET = 7;
2424

25-
export const validationKeys = {
26-
common: ['deprecated', 'enum', 'format', 'example'],
27-
number: ['minimum', 'maximum', 'multipleOf', 'exclusiveMinimum', 'exclusiveMaximum'],
28-
integer: ['minimum', 'maximum', 'multipleOf', 'exclusiveMinimum', 'exclusiveMaximum'],
29-
string: ['minLength', 'maxLength', 'pattern'],
30-
array: ['uniqueItems', 'maxItems', 'minItems'],
31-
object: ['additionalProperties', 'minProperties', 'maxProperties'],
32-
};
33-
3425
export const SchemaRow: React.FunctionComponent<ISchemaRow> = ({ node, treeStore }) => {
3526
const schemaNode = node.metadata as SchemaNodeWithMeta;
36-
const { showDivider, name, $ref, subtype, required } = schemaNode;
27+
const { name, $ref, subtype, required } = schemaNode;
3728

3829
const type = isRef(schemaNode) ? '$ref' : isCombiner(schemaNode) ? schemaNode.combiner : schemaNode.type;
3930
const description = get(schemaNode, 'annotations.description');
@@ -79,9 +70,9 @@ export const SchemaRow: React.FunctionComponent<ISchemaRow> = ({ node, treeStore
7970
</div>
8071
)}
8172

82-
{showDivider && (
73+
{schemaNode.divider && (
8374
<div className="flex items-center w-full h-2 absolute" style={{ top: -11, left: -16 }}>
84-
<div className="font-bold text-darken-7 pr-2">OR</div>
75+
<div className="font-bold text-darken-7 pr-2">{schemaNode.divider}</div>
8576
<div className="flex-1 bg-darken-5" style={{ height: 2 }} />
8677
</div>
8778
)}
@@ -96,6 +87,10 @@ export const SchemaRow: React.FunctionComponent<ISchemaRow> = ({ node, treeStore
9687

9788
{node.canHaveChildren && <span className="ml-2 text-darken-7">{`{${childrenCount}}`}</span>}
9889

90+
{'pattern' in schemaNode && schemaNode.pattern ? (
91+
<span className="text-darken-7 ml-2">(pattern property)</span>
92+
) : null}
93+
9994
{description && (
10095
<Popover
10196
boundary="window"
@@ -128,10 +123,16 @@ export const SchemaRow: React.FunctionComponent<ISchemaRow> = ({ node, treeStore
128123
</span>
129124
));
130125
} else if (typeof validation === 'object') {
131-
elem = [<span key={index} className="px-1 bg-red-2 text-red-7 text-sm rounded">{'{...}'}</span>];
126+
elem = [
127+
<span key={index} className="px-1 bg-red-2 text-red-7 text-sm rounded">
128+
{'{...}'}
129+
</span>,
130+
];
132131
} else {
133132
elem = [
134-
<span key={index} className="px-1 bg-red-2 text-red-7 text-sm rounded">{JSON.stringify(validation)}</span>,
133+
<span key={index} className="px-1 bg-red-2 text-red-7 text-sm rounded">
134+
{JSON.stringify(validation)}
135+
</span>,
135136
];
136137
}
137138

0 commit comments

Comments
 (0)