From 755498bbd777eadf8e2b2556c7f5e802eb143231 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Mon, 24 Jul 2023 16:25:59 +0300 Subject: [PATCH] Respect `required` --- packages/fets/src/client/types.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/fets/src/client/types.ts b/packages/fets/src/client/types.ts index 9d34ab190..8a4a4b843 100644 --- a/packages/fets/src/client/types.ts +++ b/packages/fets/src/client/types.ts @@ -144,11 +144,17 @@ export type OASParamObj< interface OASParamToRequestParam extends Fn { return: this['arg0'] extends { name: string; in: infer TParamType } - ? { - [TKey in TParamType extends keyof OASParamPropMap - ? OASParamPropMap[TParamType] - : never]: OASParamObj; - } + ? this['arg0'] extends { required: true } + ? { + [TKey in TParamType extends keyof OASParamPropMap + ? OASParamPropMap[TParamType] + : never]: OASParamObj; + } + : { + [TKey in TParamType extends keyof OASParamPropMap + ? OASParamPropMap[TParamType] + : never]?: OASParamObj; + } : {}; }