Skip to content

Commit 3d410b6

Browse files
authored
fix: default value for array query parameter (#2186)
1 parent 0753bbe commit 3d410b6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/components/Fields/FieldDetails.tsx

Lines changed: 6 additions & 2 deletions
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 } from '../../utils';
11+
import { getSerializedValue, isObject } from '../../utils';
1212
import { ExternalDocumentation } from '../ExternalDocumentation/ExternalDocumentation';
1313
import { Markdown } from '../Markdown/Markdown';
1414
import { EnumValues } from './EnumValues';
@@ -52,6 +52,10 @@ export const FieldDetailsComponent = observer((props: FieldProps) => {
5252
return null;
5353
}, [field, showExamples]);
5454

55+
const defaultValue = isObject(schema.default)
56+
? getSerializedValue(field, schema.default).replace(`${field.name}=`, '')
57+
: schema.default;
58+
5559
return (
5660
<div>
5761
<div>
@@ -92,7 +96,7 @@ export const FieldDetailsComponent = observer((props: FieldProps) => {
9296
<Badge type="warning"> {l('deprecated')} </Badge>
9397
</div>
9498
)}
95-
<FieldDetail raw={rawDefault} label={l('default') + ':'} value={schema.default} />
99+
<FieldDetail raw={rawDefault} label={l('default') + ':'} value={defaultValue} />
96100
{!renderDiscriminatorSwitch && (
97101
<EnumValues isArrayType={isArrayType} values={schema.enum} />
98102
)}{' '}

0 commit comments

Comments
 (0)