Skip to content

Commit 489950f

Browse files
authored
Merge pull request #247 from open-rpc/fix/json-schema-objects
fix(JSON Schema Objects): display key names and title separately
2 parents a2b58e4 + 71a5655 commit 489950f

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

Diff for: src/JSONSchema/SchemaRenderer.tsx

+26-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ const SchemaRenderer: React.FC<IProps> = ({ schema, required, name }) => {
2222
return (
2323
<TableRow>
2424
<TableCell colSpan={1} style={styles.cellWidth}>
25-
{schema.title || name}
25+
{name}
26+
</TableCell>
27+
<TableCell colSpan={1} style={styles.cellWidth}>
28+
{schema.title}
2629
</TableCell>
2730
<TableCell colSpan={1} style={styles.cellWidth}>
2831
<Typography variant="body1" color="primary">any of</Typography>
@@ -37,7 +40,10 @@ const SchemaRenderer: React.FC<IProps> = ({ schema, required, name }) => {
3740
return (
3841
<TableRow>
3942
<TableCell colSpan={1} style={styles.cellWidth}>
40-
{schema.title || name}
43+
{name}
44+
</TableCell>
45+
<TableCell colSpan={1} style={styles.cellWidth}>
46+
{schema.title}
4147
</TableCell>
4248
<TableCell colSpan={1} style={styles.cellWidth}>
4349
<Typography variant="body1" color="primary">all of</Typography>
@@ -67,7 +73,10 @@ const SchemaRenderer: React.FC<IProps> = ({ schema, required, name }) => {
6773
return (
6874
<TableRow>
6975
<TableCell colSpan={1} style={styles.cellWidth}>
70-
{schema.title || name}
76+
{name}
77+
</TableCell>
78+
<TableCell colSpan={1} style={styles.cellWidth}>
79+
{schema.title}
7180
</TableCell>
7281
<TableCell colSpan={1} style={styles.cellWidth}>
7382
<Typography variant="body1" color="primary">array of</Typography>
@@ -82,7 +91,10 @@ const SchemaRenderer: React.FC<IProps> = ({ schema, required, name }) => {
8291
return (
8392
<TableRow>
8493
<TableCell colSpan={1} style={styles.cellWidth}>
85-
{schema.title || name}
94+
{name}
95+
</TableCell>
96+
<TableCell colSpan={1} style={styles.cellWidth}>
97+
{schema.title}
8698
</TableCell>
8799
<TableCell colSpan={1} style={styles.cellWidth}>
88100
<Typography variant="body1" color="primary">array of</Typography>
@@ -98,7 +110,10 @@ const SchemaRenderer: React.FC<IProps> = ({ schema, required, name }) => {
98110
return (
99111
<TableRow>
100112
<TableCell colSpan={1} style={styles.cellWidth}>
101-
{schema.title || name}
113+
{name}
114+
</TableCell>
115+
<TableCell colSpan={1} style={styles.cellWidth}>
116+
{schema.title}
102117
</TableCell>
103118
<TableCell colSpan={1} style={styles.cellWidth}>
104119
<Typography variant="body1" color="primary">object</Typography>
@@ -108,6 +123,7 @@ const SchemaRenderer: React.FC<IProps> = ({ schema, required, name }) => {
108123
<TableHead>
109124
<TableRow>
110125
<TableCell>Name</TableCell>
126+
<TableCell>Title</TableCell>
111127
<TableCell>Type</TableCell>
112128
<TableCell>Pattern</TableCell>
113129
<TableCell>Required</TableCell>
@@ -147,8 +163,11 @@ const SchemaRenderer: React.FC<IProps> = ({ schema, required, name }) => {
147163
};
148164
return (
149165
<TableRow key={schema.title}>
150-
<TableCell component="th" scope="row" style={styles.cellWidth}>
151-
{schema.title || name}
166+
<TableCell colSpan={1} style={styles.cellWidth}>
167+
{name}
168+
</TableCell>
169+
<TableCell colSpan={1} style={styles.cellWidth}>
170+
{schema.title}
152171
</TableCell>
153172
<TableCell style={{
154173
...styles.cellWidth,

Diff for: src/JSONSchema/fields/JSONSchemaFields.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class JSONSchemaFields extends Component<IProps> {
3434
<TableHead>
3535
<TableRow>
3636
<TableCell>Name</TableCell>
37+
<TableCell>Title</TableCell>
3738
<TableCell>Type</TableCell>
3839
<TableCell>Pattern</TableCell>
3940
<TableCell>Required</TableCell>

0 commit comments

Comments
 (0)