Skip to content

Commit b0338da

Browse files
committed
fix(explorer): keep scalar query and header values on exploded parameters
A parameter declared explode: true whose value was not a JSON object was routed into the exploded-object branch of setQueryParams, which enumerated a non-object and replaced the typed value with an empty string in the sent request and the code snippet; the header branch threw on a decoded null. Fall through to the scalar handling, which serialises an exploded scalar the same way as an unexploded one.
1 parent 30d04a5 commit b0338da

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

‎packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/buildPostmanRequest.ts‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,8 @@ function setQueryParams(postman: sdk.Request, queryParams: Param[]) {
7777
value: String(val),
7878
})
7979
);
80-
} else {
81-
return new sdk.QueryParam({
82-
key: param.name,
83-
value: Object.entries(jsonResult)
84-
.map(([key, val]) => `${key},${val}`)
85-
.join(","),
86-
});
8780
}
81+
// A scalar has nothing to explode; fall through to the scalar handling
8882
}
8983

9084
// Parameter allows empty value: "/hello?extended"
@@ -251,7 +245,7 @@ function setHeaders(
251245
});
252246
}
253247
}
254-
} else if (typeof jsonResult === "object") {
248+
} else if (jsonResult && typeof jsonResult === "object") {
255249
if (param.style === "simple") {
256250
if (param.explode) {
257251
// Each key-value pair in the object is a separate header

0 commit comments

Comments
 (0)