fix: default value for array query parameter (#2186)

This commit is contained in:
Alex Varchuk 2022-10-31 20:46:00 +02:00 committed by GitHub
parent 0753bbea4b
commit 3d410b6002
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,7 @@ import {
TypePrefix, TypePrefix,
TypeTitle, TypeTitle,
} from '../../common-elements/fields'; } from '../../common-elements/fields';
import { getSerializedValue } from '../../utils'; import { getSerializedValue, isObject } from '../../utils';
import { ExternalDocumentation } from '../ExternalDocumentation/ExternalDocumentation'; import { ExternalDocumentation } from '../ExternalDocumentation/ExternalDocumentation';
import { Markdown } from '../Markdown/Markdown'; import { Markdown } from '../Markdown/Markdown';
import { EnumValues } from './EnumValues'; import { EnumValues } from './EnumValues';
@ -52,6 +52,10 @@ export const FieldDetailsComponent = observer((props: FieldProps) => {
return null; return null;
}, [field, showExamples]); }, [field, showExamples]);
const defaultValue = isObject(schema.default)
? getSerializedValue(field, schema.default).replace(`${field.name}=`, '')
: schema.default;
return ( return (
<div> <div>
<div> <div>
@ -92,7 +96,7 @@ export const FieldDetailsComponent = observer((props: FieldProps) => {
<Badge type="warning"> {l('deprecated')} </Badge> <Badge type="warning"> {l('deprecated')} </Badge>
</div> </div>
)} )}
<FieldDetail raw={rawDefault} label={l('default') + ':'} value={schema.default} /> <FieldDetail raw={rawDefault} label={l('default') + ':'} value={defaultValue} />
{!renderDiscriminatorSwitch && ( {!renderDiscriminatorSwitch && (
<EnumValues isArrayType={isArrayType} values={schema.enum} /> <EnumValues isArrayType={isArrayType} values={schema.enum} />
)}{' '} )}{' '}