From eb0917d002e57353027fee9c8f07605de8f1ff6f Mon Sep 17 00:00:00 2001 From: Alex Varchuk Date: Fri, 20 May 2022 10:44:02 +0300 Subject: [PATCH] fix: constraints label details --- src/components/Fields/ArrayItemDetails.tsx | 13 ++++++++++++- src/components/Parameters/Parameters.tsx | 4 +++- src/components/Responses/ResponseDetails.tsx | 4 +++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/Fields/ArrayItemDetails.tsx b/src/components/Fields/ArrayItemDetails.tsx index db8837d2..776d229d 100644 --- a/src/components/Fields/ArrayItemDetails.tsx +++ b/src/components/Fields/ArrayItemDetails.tsx @@ -4,9 +4,20 @@ import { ConstraintsView } from './FieldContstraints'; import { Pattern } from './Pattern'; import { SchemaModel } from '../../services'; import styled from '../../styled-components'; +import { OptionsContext } from '../OptionsProvider'; export function ArrayItemDetails({ schema }: { schema: SchemaModel }) { - if (!schema || (schema.type === 'string' && !schema.constraints.length)) return null; + const { hideSchemaPattern } = React.useContext(OptionsContext); + if ( + !schema || + (schema.type === 'string' && !schema.constraints.length) || + ((!schema?.pattern || hideSchemaPattern) && + !schema.items && + !schema.displayFormat && + !schema.constraints.length) + ) { + return null; + } return ( diff --git a/src/components/Parameters/Parameters.tsx b/src/components/Parameters/Parameters.tsx index 6ff7e769..3f4275df 100644 --- a/src/components/Parameters/Parameters.tsx +++ b/src/components/Parameters/Parameters.tsx @@ -80,7 +80,9 @@ export function BodyContent(props: { return ( <> {description !== undefined && } - + {schema?.type === 'object' && ( + + )} { return ( <> - + {schema?.type === 'object' && ( + + )} );