Skip to content

Commit 2d98709

Browse files
sserrataclaude
andauthored
fix(theme): guard against unknown parameter in values to prevent crash (#1360)
Parameters with non-OAS3 `in` values (e.g. `formData` from OAS2 specs) would cause a page crash since the params map only keys on the four valid OAS3 locations (path, query, header, cookie). Use optional chaining to skip unknown values gracefully instead of throwing. Fixes #1359 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1f62529 commit 2d98709

File tree

2 files changed

+2
-2
lines changed
  • packages/docusaurus-theme-openapi-docs/src/theme

2 files changed

+2
-2
lines changed

packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Request/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function Request({ item }: { item: ApiItem }) {
102102
(param: { in: "path" | "query" | "header" | "cookie" }) => {
103103
const paramType = param.in;
104104
const paramsArray: ParameterObject[] = paramsObject[paramType];
105-
paramsArray.push(param as ParameterObject);
105+
paramsArray?.push(param as ParameterObject);
106106
}
107107
);
108108

packages/docusaurus-theme-openapi-docs/src/theme/ApiItem/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default function ApiItem(props: Props): JSX.Element {
122122
(param: { in: "path" | "query" | "header" | "cookie" }) => {
123123
const paramType = param.in;
124124
const paramsArray: ParameterObject[] = params[paramType];
125-
paramsArray.push(param as ParameterObject);
125+
paramsArray?.push(param as ParameterObject);
126126
}
127127
);
128128
const auth = createAuth({

0 commit comments

Comments
 (0)