From 79ca769f325e61d73750acd8842f95c258391464 Mon Sep 17 00:00:00 2001 From: Alex Varchuk Date: Wed, 21 Jul 2021 16:40:24 +0300 Subject: [PATCH] fix: crash types in requestBody --- src/components/Schema/ArraySchema.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/Schema/ArraySchema.tsx b/src/components/Schema/ArraySchema.tsx index 48e7dc41..eab37595 100644 --- a/src/components/Schema/ArraySchema.tsx +++ b/src/components/Schema/ArraySchema.tsx @@ -4,7 +4,8 @@ import { Schema, SchemaProps } from './Schema'; import { ArrayClosingLabel, ArrayOpenningLabel } from '../../common-elements'; import styled from '../../styled-components'; -import {humanizeConstraints} from "../../utils"; +import { humanizeConstraints } from '../../utils'; +import { TypeName } from '../../common-elements/fields'; const PaddedSchema = styled.div` padding-left: ${({ theme }) => theme.spacing.unit * 2}px; @@ -13,12 +14,20 @@ const PaddedSchema = styled.div` export class ArraySchema extends React.PureComponent { render() { const itemsSchema = this.props.schema.items!; + const schema = this.props.schema; + const itemConstraintSchema = ( min: number | undefined = undefined, max: number | undefined = undefined, ) => ({ type: 'array', minItems: min, maxItems: max }); - const minMaxItems = humanizeConstraints(itemConstraintSchema(itemsSchema.schema.minItems, itemsSchema.schema.maxItems)); + const minMaxItems = humanizeConstraints(itemConstraintSchema(itemsSchema?.schema?.minItems, itemsSchema?.schema?.maxItems)); + + if (schema.displayType && !itemsSchema && !minMaxItems.length) { + return (
+ {schema.displayType} +
); + } return (