Skip to content

Commit 428f3be

Browse files
committed
Clean up model schema design
1 parent 06ef12e commit 428f3be

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

src/components/models/SchemaRow.astro

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,48 @@
11
---
2-
import { Type } from "~/components";
2+
import { Type, MetaInfo } from "~/components";
33
import { type SchemaNode } from "@stoplight/json-schema-tree";
44
5-
const { node } = Astro.props;
5+
const { node, root } = Astro.props;
66
---
77

8-
<li class="my-2 !list-none">
9-
<code class="mr-2 font-mono rounded-md bg-gray-100">
10-
{node.subpath[node.subpath.length - 1]}
11-
</code>
8+
<li
9+
class={`py-2 !my-0 !list-none ${root ? "" : "border-l border-l-gray-200 pl-4"}`}
10+
>
11+
{
12+
node.title ? (
13+
<span class="mr-2 font-bold">{node.title}</span>
14+
) : (
15+
<code class="mr-2 !pr-0 font-mono rounded-md bg-gray-100">
16+
{node.subpath[node.subpath.length - 1]}
17+
</code>
18+
)
19+
}
20+
1221
{node.primaryType && <Type text={node.primaryType} />}
22+
{node.combiners && node.combiners.includes("oneOf") && <Type text="one of" />}
1323

1424
{
1525
node.annotations.default && (
16-
<span class="text-xs mr-2">default {node.annotations.default}</span>
26+
<MetaInfo text={`default ${node.annotations.default}`} />
1727
)
1828
}
1929
{
2030
(node.validations.minLength !== undefined ||
2131
node.validations.minimum !== undefined) && (
22-
<span class="text-xs mr-2">
23-
min {node.validations.minLength || node.validations.minimum}
24-
</span>
32+
<MetaInfo
33+
text={`min ${node.validations.minLength || node.validations.minimum}`}
34+
/>
2535
)
2636
}
2737
{
2838
(node.validations.maxLength !== undefined ||
2939
node.validations.maximum !== undefined) && (
30-
<span class="text-xs">
31-
max {node.validations.maxLength || node.validations.maximum}
32-
</span>
40+
<MetaInfo
41+
text={`max ${node.validations.maxLength || node.validations.maximum}`}
42+
/>
3343
)
3444
}
35-
<p>{node.annotations.description}</p>
45+
<p class="!mb-0">{node.annotations.description}</p>
3646

3747
{
3848
node.children && (

src/components/models/SchemaViewer.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jsonSchemaTree.populate();
5656
<ul class="list-none m-0 p-0">
5757
{
5858
(jsonSchemaTree.root.children[0] as RegularNode).children?.map(
59-
(node: SchemaNode) => <SchemaRow node={node} />,
59+
(node: SchemaNode) => <SchemaRow node={node} root />,
6060
)
6161
}
6262
</ul>

0 commit comments

Comments
 (0)