|
1 | 1 | import React from "react"; |
2 | 2 | import { JSONSchema4 } from "json-schema"; |
3 | | -import { TableRow, TableCell, Typography } from "@material-ui/core"; |
| 3 | +import { TableRow, TableCell, Typography, Table, TableHead, TableBody } from "@material-ui/core"; |
4 | 4 | import JSONSchemaFields from "./fields/JSONSchemaFields"; |
5 | 5 | import _ from "lodash"; |
6 | 6 | import { grey, green, purple, yellow, blue } from "@material-ui/core/colors"; |
@@ -104,23 +104,38 @@ const SchemaRenderer: React.FC<IProps> = ({ schema, required, name }) => { |
104 | 104 | <Typography variant="body1" color="primary">object</Typography> |
105 | 105 | </TableCell> |
106 | 106 | <TableCell colSpan={5}> |
107 | | - {schema.properties && Object.entries(schema.properties).map(([n, prop]: [string, JSONSchema4], i: number) => { |
108 | | - return ( |
109 | | - <JSONSchemaFields |
110 | | - key={n} |
111 | | - schema={prop} |
112 | | - name={n} |
113 | | - hideHeader={i !== 0} |
114 | | - required={schema.required && schema.required.includes(n)} |
115 | | - /> |
116 | | - ); |
117 | | - })} |
| 107 | + <Table> |
| 108 | + <TableHead> |
| 109 | + <TableRow> |
| 110 | + <TableCell>Name</TableCell> |
| 111 | + <TableCell>Type</TableCell> |
| 112 | + <TableCell>Pattern</TableCell> |
| 113 | + <TableCell>Required</TableCell> |
| 114 | + <TableCell>Description</TableCell> |
| 115 | + </TableRow> |
| 116 | + </TableHead> |
| 117 | + <TableBody> |
| 118 | + {schema.properties && |
| 119 | + Object.entries(schema.properties) |
| 120 | + .map(([n, prop]: [string, JSONSchema4], i: number) => { |
| 121 | + return ( |
| 122 | + <JSONSchemaFields |
| 123 | + key={n} |
| 124 | + schema={prop} |
| 125 | + name={n} |
| 126 | + hideHeader={true} |
| 127 | + required={schema.required && schema.required.includes(n)} |
| 128 | + /> |
| 129 | + ); |
| 130 | + })} |
| 131 | + </TableBody> |
| 132 | + </Table> |
118 | 133 | </TableCell> |
119 | 134 | </TableRow> |
120 | 135 | ); |
121 | 136 | } |
122 | 137 |
|
123 | | - const colorMap: {[k: string]: string} = { |
| 138 | + const colorMap: { [k: string]: string } = { |
124 | 139 | any: grey[500], |
125 | 140 | array: blue[300], |
126 | 141 | boolean: blue[500], |
|
0 commit comments