open-rpc/docs-react

Array of types is not supported

Opened this issue · 0 comments

Hi,

It seems that having an array of types (which is valid json schema) is not supported by this tool. For example "type": ["string", "null"] is displayed as "stringnull".

image

After taking a quick look at the code I believe the problem is coming from the following piece where the assumption is made that type is always a single value.

<TableCell style={{
...styles.cellWidth,
color: colorMap[schema.type as any],
}}>{schema.type}</TableCell>

Using an array of types is particularly convenient to define a simple nullable type like a nullable string for example. A workaround is to use oneOf but this is a bit more verbose so it would be nice to support array of types I think.

Thanks,
Antoine