Default value for array query parameter with explode:true (default) and 2+ items is rendered incorrectly (regression from #1806 fix)
Describe the bug
When a query parameter is an array with a default containing 2 or more items, and the parameter uses the default OpenAPI serialization (style: form, explode: true — i.e. no style/explode fields set at all, which is the spec default for query params), the rendered "Default:" value is mangled. It shows the first item concatenated with a dangling ¶mName= fragment instead of a clean list.
Expected behavior
The "Default:" field should show something like ["Cat", "Dog"] or Cat, Dog — matching how example values for the same shape are displayed.
Minimal reproducible OpenAPI snippet(if possible)
paths:
/species:
get:
parameters:
- name: animals
in: query
required: false
schema:
type: array
items:
type: string
enum: ["Cat", "Dog", "Bird", "Fish", "Elephant"]
default: ["Cat", "Dog"]
description: Animal species.
responses:
"200":
description: OKScreenshots
Root cause
In src/components/Fields/FieldDetails.tsx:
const defaultValue =
isObject(schema.default) && field.in
? getSerializedValue(field, schema.default).replace(`${field.name}=`, '')
: schema.default;isObject()(fromsrc/utils/helpers.ts) istypeof item === 'object', which istruefor arrays, so any array-type parameter default takes this branch.getSerializedValue→serializeParameterValue→serializeQueryParameterserializes the default using the parameter'sstyle/explodethe same way it would appear on the wire. For the defaultexplode: true, a 2-item array serializes toreport_types=EFT&report_types=Credit Card(tworeport_types=occurrences)..replace(${field.name}=, '')is a plain string replace, which only removes the first occurrence, not all of them (.replaceAllwould be needed). This leaves the second&report_types=fragment in the displayed value.
This is a regression introduced by the fix for #1806 (PR #2186). That fix's own repro used explode: false with a comma-joined default, which serializes to a single name=val1,val2,val3 string (only one occurrence of name=), so the single-occurrence .replace() happened to fully strip it in that case. It was never tested against the explode: true + 2-or-more-items case, which is actually the more common case since it's the OpenAPI default for query array parameters (no explicit style/explode needed to trigger it).
Suggested fix
Replace the single-occurrence .replace(...) with .replaceAll(...), or better, avoid stripping via string manipulation entirely and instead render the parsed array default directly (e.g. join with the same separator/format used for example arrays) rather than round-tripping through wire-serialization + string-stripping.
Environment
- ReDoc version: latest (
redoc@latestvia jsdelivr) — bug also present onmainbranch - OpenAPI version: 3.0 / 3.1 (style/explode defaults are shared across both)
Source: Redocly/redoc