Skip to content

Commit 3f0607e

Browse files
committed
Make parameters with default value non-optional
if respective option is set
1 parent 40c2e9e commit 3f0607e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/openapi-typescript/src/transform/parameters-array.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ export function transformParametersArray(
8787
continue;
8888
}
8989
let optional: ts.QuestionToken | undefined = undefined;
90-
if (paramIn !== "path" && !(resolved as ParameterObject).required) {
90+
const isNonOptional =
91+
(resolved as ParameterObject).required ||
92+
(options.ctx.makeParametersWithDefaultNotUndefined && resolved.schema?.default !== undefined);
93+
if (paramIn !== "path" && !isNonOptional) {
9194
optional = QUESTION_TOKEN;
9295
}
9396
const subType =

0 commit comments

Comments
 (0)