Skip to content

Commit 85b622f

Browse files
authored
fix: displaying nested items with type string (#2634)
1 parent 639fd2c commit 85b622f

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

src/components/Fields/ArrayItemDetails.tsx

-8
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ export function ArrayItemDetails({ schema }: { schema: SchemaModel }) {
1818
return null;
1919
}
2020

21-
if (schema.type === 'string' && schema.pattern) {
22-
return (
23-
<Wrapper>
24-
[<Pattern schema={schema} />]
25-
</Wrapper>
26-
);
27-
}
28-
2921
return (
3022
<Wrapper>
3123
[ items

src/components/Fields/FieldDetails.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
TypePrefix,
99
TypeTitle,
1010
} from '../../common-elements/fields';
11-
import { getSerializedValue, isObject } from '../../utils';
11+
import { getSerializedValue, isArray, isObject } from '../../utils';
1212
import { ExternalDocumentation } from '../ExternalDocumentation/ExternalDocumentation';
1313
import { Markdown } from '../Markdown/Markdown';
1414
import { EnumValues } from './EnumValues';
@@ -30,7 +30,8 @@ export const FieldDetailsComponent = observer((props: FieldProps) => {
3030

3131
const { showExamples, field, renderDiscriminatorSwitch } = props;
3232
const { schema, description, deprecated, extensions, in: _in, const: _const } = field;
33-
const isArrayType = schema.type === 'array';
33+
const isArrayType =
34+
schema.type === 'array' || (isArray(schema.type) && schema.type.includes('array'));
3435

3536
const rawDefault = enumSkipQuotes || _in === 'header'; // having quotes around header field default values is confusing and inappropriate
3637

src/components/__tests__/FieldDetails.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('FieldDetailsComponent', () => {
9090
items: {
9191
type: 'string',
9292
pattern: '^see regex[0-9]$',
93-
constraints: [''],
93+
constraints: ['<= 128 characters'],
9494
externalDocs: undefined,
9595
},
9696
} as any as SchemaModel,

src/components/__tests__/__snapshots__/FieldDetails.test.tsx.snap

+10-2
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,21 @@ exports[`FieldDetailsComponent renders correctly when field items have string ty
161161
<span
162162
class="sc-kpDqfm sc-dAlyuH sc-dxcDKg cGRfjn gHomYR gXntsr"
163163
>
164-
[
164+
[ items
165+
<span>
166+
167+
<span
168+
class="sc-kpDqfm sc-gFqAkR cGRfjn fYEICH"
169+
>
170+
&lt;= 128 characters
171+
</span>
172+
</span>
165173
<span
166174
class="sc-kpDqfm sc-eDPEul cGRfjn cCKYVD"
167175
>
168176
^see regex[0-9]$
169177
</span>
170-
]
178+
]
171179
</span>
172180
</div>
173181

0 commit comments

Comments
 (0)