diff --git a/src/components/Fields/ArrayItemDetails.tsx b/src/components/Fields/ArrayItemDetails.tsx index bbae19911d..b45f56a8b8 100644 --- a/src/components/Fields/ArrayItemDetails.tsx +++ b/src/components/Fields/ArrayItemDetails.tsx @@ -18,14 +18,6 @@ export function ArrayItemDetails({ schema }: { schema: SchemaModel }) { return null; } - if (schema.type === 'string' && schema.pattern) { - return ( - - [] - - ); - } - return ( [ items diff --git a/src/components/Fields/FieldDetails.tsx b/src/components/Fields/FieldDetails.tsx index 40c1122f01..570c382f6f 100644 --- a/src/components/Fields/FieldDetails.tsx +++ b/src/components/Fields/FieldDetails.tsx @@ -8,7 +8,7 @@ import { TypePrefix, TypeTitle, } from '../../common-elements/fields'; -import { getSerializedValue, isObject } from '../../utils'; +import { getSerializedValue, isArray, isObject } from '../../utils'; import { ExternalDocumentation } from '../ExternalDocumentation/ExternalDocumentation'; import { Markdown } from '../Markdown/Markdown'; import { EnumValues } from './EnumValues'; @@ -30,7 +30,8 @@ export const FieldDetailsComponent = observer((props: FieldProps) => { const { showExamples, field, renderDiscriminatorSwitch } = props; const { schema, description, deprecated, extensions, in: _in, const: _const } = field; - const isArrayType = schema.type === 'array'; + const isArrayType = + schema.type === 'array' || (isArray(schema.type) && schema.type.includes('array')); const rawDefault = enumSkipQuotes || _in === 'header'; // having quotes around header field default values is confusing and inappropriate diff --git a/src/components/__tests__/FieldDetails.test.tsx b/src/components/__tests__/FieldDetails.test.tsx index 0d70fe55cd..03331ed828 100644 --- a/src/components/__tests__/FieldDetails.test.tsx +++ b/src/components/__tests__/FieldDetails.test.tsx @@ -90,7 +90,7 @@ describe('FieldDetailsComponent', () => { items: { type: 'string', pattern: '^see regex[0-9]$', - constraints: [''], + constraints: ['<= 128 characters'], externalDocs: undefined, }, } as any as SchemaModel, diff --git a/src/components/__tests__/__snapshots__/FieldDetails.test.tsx.snap b/src/components/__tests__/__snapshots__/FieldDetails.test.tsx.snap index a8b1a44fac..5d6e6811c8 100644 --- a/src/components/__tests__/__snapshots__/FieldDetails.test.tsx.snap +++ b/src/components/__tests__/__snapshots__/FieldDetails.test.tsx.snap @@ -161,13 +161,21 @@ exports[`FieldDetailsComponent renders correctly when field items have string ty - [ + [ items + + + + <= 128 characters + + ^see regex[0-9]$ - ] + ]