Skip to content

Commit

Permalink
fix: default value for array query parameter (#2186)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVarchuk authored Oct 31, 2022
1 parent 0753bbe commit 3d410b6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/Fields/FieldDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TypePrefix,
TypeTitle,
} from '../../common-elements/fields';
import { getSerializedValue } from '../../utils';
import { getSerializedValue, isObject } from '../../utils';
import { ExternalDocumentation } from '../ExternalDocumentation/ExternalDocumentation';
import { Markdown } from '../Markdown/Markdown';
import { EnumValues } from './EnumValues';
Expand Down Expand Up @@ -52,6 +52,10 @@ export const FieldDetailsComponent = observer((props: FieldProps) => {
return null;
}, [field, showExamples]);

const defaultValue = isObject(schema.default)
? getSerializedValue(field, schema.default).replace(`${field.name}=`, '')
: schema.default;

return (
<div>
<div>
Expand Down Expand Up @@ -92,7 +96,7 @@ export const FieldDetailsComponent = observer((props: FieldProps) => {
<Badge type="warning"> {l('deprecated')} </Badge>
</div>
)}
<FieldDetail raw={rawDefault} label={l('default') + ':'} value={schema.default} />
<FieldDetail raw={rawDefault} label={l('default') + ':'} value={defaultValue} />
{!renderDiscriminatorSwitch && (
<EnumValues isArrayType={isArrayType} values={schema.enum} />
)}{' '}
Expand Down

0 comments on commit 3d410b6

Please sign in to comment.