From f06d1fcc380f756484630e24749b397d98c0e87d Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Tue, 30 Dec 2025 01:37:31 -0800 Subject: [PATCH] feat: support `exactOptionalPropertyTypes` Refs: https://github.com/hey-api/openapi-ts/issues/2236 --- .changeset/fluffy-guests-train.md | 5 +++ .../src/client/client/types.gen.ts | 2 +- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 26 +++++------ .../src/client/core/types.gen.ts | 20 +++++---- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/client/types.gen.ts | 2 +- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 26 +++++------ .../src/client/core/types.gen.ts | 20 +++++---- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 26 +++++------ .../src/client/core/types.gen.ts | 20 +++++---- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/client/client.gen.ts | 11 ++--- .../src/client/client/types.gen.ts | 43 ++++++++++--------- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 26 +++++------ .../src/client/core/types.gen.ts | 20 +++++---- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/client/client.gen.ts | 11 ++--- .../src/client/client/types.gen.ts | 43 ++++++++++--------- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 26 +++++------ .../src/client/core/types.gen.ts | 20 +++++---- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/client/types.gen.ts | 2 +- .../openapi-ts-ky/src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 26 +++++------ .../src/client/core/types.gen.ts | 20 +++++---- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/client/client.gen.ts | 9 +--- .../src/client/client/types.gen.ts | 2 +- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 26 +++++------ .../src/client/core/types.gen.ts | 20 +++++---- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/client/types.gen.ts | 2 +- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 26 +++++------ .../src/client/core/types.gen.ts | 20 +++++---- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/client/client.gen.ts | 11 ++--- .../src/client/client/types.gen.ts | 43 ++++++++++--------- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 26 +++++------ .../src/client/core/types.gen.ts | 20 +++++---- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/client/client.gen.ts | 11 ++--- .../src/client/client/types.gen.ts | 42 +++++++++--------- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 24 +++++------ .../src/client/core/types.gen.ts | 15 ++++--- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/client/types.gen.ts | 2 +- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 26 +++++------ .../src/client/core/types.gen.ts | 20 +++++---- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/client/client.gen.ts | 11 ++--- .../src/client/client/types.gen.ts | 43 ++++++++++--------- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 26 +++++------ .../src/client/core/types.gen.ts | 20 +++++---- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/client/client.gen.ts | 11 ++--- .../src/client/client/types.gen.ts | 43 ++++++++++--------- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 26 +++++------ .../src/client/core/types.gen.ts | 20 +++++---- .../src/client/core/utils.gen.ts | 6 +-- .../src/client/client/client.gen.ts | 11 ++--- .../src/client/client/types.gen.ts | 42 +++++++++--------- .../src/client/core/auth.gen.ts | 6 +-- .../src/client/core/bodySerializer.gen.ts | 8 ++-- .../src/client/core/params.gen.ts | 12 +++--- .../src/client/core/pathSerializer.gen.ts | 2 +- .../src/client/core/serverSentEvents.gen.ts | 24 +++++------ .../src/client/core/types.gen.ts | 15 ++++--- .../src/client/core/utils.gen.ts | 6 +-- packages/custom-client/src/types.ts | 35 +++++++-------- .../@tanstack/meta/client/client.gen.ts | 11 ++--- .../@tanstack/meta/client/types.gen.ts | 43 ++++++++++--------- .../plugins/@tanstack/meta/core/auth.gen.ts | 6 +-- .../@tanstack/meta/core/bodySerializer.gen.ts | 8 ++-- .../plugins/@tanstack/meta/core/params.gen.ts | 12 +++--- .../@tanstack/meta/core/pathSerializer.gen.ts | 2 +- .../meta/core/serverSentEvents.gen.ts | 26 +++++------ .../plugins/@tanstack/meta/core/types.gen.ts | 20 +++++---- .../plugins/@tanstack/meta/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../body-response-text-plain/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../2.0.x/form-data/client/client.gen.ts | 11 ++--- .../2.0.x/form-data/client/types.gen.ts | 43 ++++++++++--------- .../2.0.x/form-data/core/auth.gen.ts | 6 +-- .../form-data/core/bodySerializer.gen.ts | 8 ++-- .../2.0.x/form-data/core/params.gen.ts | 12 +++--- .../form-data/core/pathSerializer.gen.ts | 2 +- .../form-data/core/serverSentEvents.gen.ts | 26 +++++------ .../2.0.x/form-data/core/types.gen.ts | 20 +++++---- .../2.0.x/form-data/core/utils.gen.ts | 6 +-- .../common/default-class/client/types.gen.ts | 2 +- .../common/default-class/core/auth.gen.ts | 6 +-- .../default-class/core/bodySerializer.gen.ts | 8 ++-- .../common/default-class/core/params.gen.ts | 12 +++--- .../default-class/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../common/default-class/core/types.gen.ts | 20 +++++---- .../common/default-class/core/utils.gen.ts | 6 +-- .../common/default/client/types.gen.ts | 2 +- .../@angular/common/default/core/auth.gen.ts | 6 +-- .../common/default/core/bodySerializer.gen.ts | 8 ++-- .../common/default/core/params.gen.ts | 12 +++--- .../common/default/core/pathSerializer.gen.ts | 2 +- .../default/core/serverSentEvents.gen.ts | 26 +++++------ .../@angular/common/default/core/types.gen.ts | 20 +++++---- .../@angular/common/default/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../sdk-nested-classes/client/client.gen.ts | 11 ++--- .../sdk-nested-classes/client/types.gen.ts | 43 ++++++++++--------- .../sdk-nested-classes/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-nested-classes/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-nested-classes/core/types.gen.ts | 20 +++++---- .../sdk-nested-classes/core/utils.gen.ts | 6 +-- .../@hey-api/sdk/default/client/client.gen.ts | 11 ++--- .../@hey-api/sdk/default/client/types.gen.ts | 43 ++++++++++--------- .../@hey-api/sdk/default/core/auth.gen.ts | 6 +-- .../sdk/default/core/bodySerializer.gen.ts | 8 ++-- .../@hey-api/sdk/default/core/params.gen.ts | 12 +++--- .../sdk/default/core/pathSerializer.gen.ts | 2 +- .../sdk/default/core/serverSentEvents.gen.ts | 26 +++++------ .../@hey-api/sdk/default/core/types.gen.ts | 20 +++++---- .../@hey-api/sdk/default/core/utils.gen.ts | 6 +-- .../sdk/instance/client/client.gen.ts | 11 ++--- .../@hey-api/sdk/instance/client/types.gen.ts | 43 ++++++++++--------- .../@hey-api/sdk/instance/core/auth.gen.ts | 6 +-- .../sdk/instance/core/bodySerializer.gen.ts | 8 ++-- .../@hey-api/sdk/instance/core/params.gen.ts | 12 +++--- .../sdk/instance/core/pathSerializer.gen.ts | 2 +- .../sdk/instance/core/serverSentEvents.gen.ts | 26 +++++------ .../@hey-api/sdk/instance/core/types.gen.ts | 20 +++++---- .../@hey-api/sdk/instance/core/utils.gen.ts | 6 +-- .../sdk/throwOnError/client/client.gen.ts | 11 ++--- .../sdk/throwOnError/client/types.gen.ts | 43 ++++++++++--------- .../sdk/throwOnError/core/auth.gen.ts | 6 +-- .../throwOnError/core/bodySerializer.gen.ts | 8 ++-- .../sdk/throwOnError/core/params.gen.ts | 12 +++--- .../throwOnError/core/pathSerializer.gen.ts | 2 +- .../throwOnError/core/serverSentEvents.gen.ts | 26 +++++------ .../sdk/throwOnError/core/types.gen.ts | 20 +++++---- .../sdk/throwOnError/core/utils.gen.ts | 6 +-- .../type-format-valibot/client/client.gen.ts | 11 ++--- .../type-format-valibot/client/types.gen.ts | 43 ++++++++++--------- .../type-format-valibot/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../type-format-valibot/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../type-format-valibot/core/types.gen.ts | 20 +++++---- .../type-format-valibot/core/utils.gen.ts | 6 +-- .../type-format-zod/client/client.gen.ts | 11 ++--- .../type-format-zod/client/types.gen.ts | 43 ++++++++++--------- .../type-format-zod/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../type-format-zod/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../type-format-zod/core/types.gen.ts | 20 +++++---- .../type-format-zod/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../colada/asClass/client/client.gen.ts | 11 ++--- .../@pinia/colada/asClass/client/types.gen.ts | 43 ++++++++++--------- .../@pinia/colada/asClass/core/auth.gen.ts | 6 +-- .../colada/asClass/core/bodySerializer.gen.ts | 8 ++-- .../@pinia/colada/asClass/core/params.gen.ts | 12 +++--- .../colada/asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../@pinia/colada/asClass/core/types.gen.ts | 20 +++++---- .../@pinia/colada/asClass/core/utils.gen.ts | 6 +-- .../@pinia/colada/fetch/client/client.gen.ts | 11 ++--- .../@pinia/colada/fetch/client/types.gen.ts | 43 ++++++++++--------- .../@pinia/colada/fetch/core/auth.gen.ts | 6 +-- .../colada/fetch/core/bodySerializer.gen.ts | 8 ++-- .../@pinia/colada/fetch/core/params.gen.ts | 12 +++--- .../colada/fetch/core/pathSerializer.gen.ts | 2 +- .../colada/fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../@pinia/colada/fetch/core/types.gen.ts | 20 +++++---- .../@pinia/colada/fetch/core/utils.gen.ts | 6 +-- .../asClass/client/client.gen.ts | 11 ++--- .../asClass/client/types.gen.ts | 43 ++++++++++--------- .../asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../asClass/core/types.gen.ts | 20 +++++---- .../asClass/core/utils.gen.ts | 6 +-- .../axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../axios/core/types.gen.ts | 20 +++++---- .../axios/core/utils.gen.ts | 6 +-- .../fetch/client/client.gen.ts | 11 ++--- .../fetch/client/types.gen.ts | 43 ++++++++++--------- .../fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../fetch/core/types.gen.ts | 20 +++++---- .../fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../name-builder/core/types.gen.ts | 20 +++++---- .../name-builder/core/utils.gen.ts | 6 +-- .../react-query/asClass/client/client.gen.ts | 11 ++--- .../react-query/asClass/client/types.gen.ts | 43 ++++++++++--------- .../react-query/asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../react-query/asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../react-query/asClass/core/types.gen.ts | 20 +++++---- .../react-query/asClass/core/utils.gen.ts | 6 +-- .../react-query/axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../react-query/axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../react-query/axios/core/types.gen.ts | 20 +++++---- .../react-query/axios/core/utils.gen.ts | 6 +-- .../react-query/fetch/client/client.gen.ts | 11 ++--- .../react-query/fetch/client/types.gen.ts | 43 ++++++++++--------- .../react-query/fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../react-query/fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../react-query/fetch/core/types.gen.ts | 20 +++++---- .../react-query/fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../react-query/name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../name-builder/core/types.gen.ts | 20 +++++---- .../name-builder/core/utils.gen.ts | 6 +-- .../solid-query/asClass/client/client.gen.ts | 11 ++--- .../solid-query/asClass/client/types.gen.ts | 43 ++++++++++--------- .../solid-query/asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../solid-query/asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../solid-query/asClass/core/types.gen.ts | 20 +++++---- .../solid-query/asClass/core/utils.gen.ts | 6 +-- .../solid-query/axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../solid-query/axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../solid-query/axios/core/types.gen.ts | 20 +++++---- .../solid-query/axios/core/utils.gen.ts | 6 +-- .../solid-query/fetch/client/client.gen.ts | 11 ++--- .../solid-query/fetch/client/types.gen.ts | 43 ++++++++++--------- .../solid-query/fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../solid-query/fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../solid-query/fetch/core/types.gen.ts | 20 +++++---- .../solid-query/fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../solid-query/name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../name-builder/core/types.gen.ts | 20 +++++---- .../name-builder/core/utils.gen.ts | 6 +-- .../svelte-query/asClass/client/client.gen.ts | 11 ++--- .../svelte-query/asClass/client/types.gen.ts | 43 ++++++++++--------- .../svelte-query/asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../svelte-query/asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../svelte-query/asClass/core/types.gen.ts | 20 +++++---- .../svelte-query/asClass/core/utils.gen.ts | 6 +-- .../svelte-query/axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../svelte-query/axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../svelte-query/axios/core/types.gen.ts | 20 +++++---- .../svelte-query/axios/core/utils.gen.ts | 6 +-- .../svelte-query/fetch/client/client.gen.ts | 11 ++--- .../svelte-query/fetch/client/types.gen.ts | 43 ++++++++++--------- .../svelte-query/fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../svelte-query/fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../svelte-query/fetch/core/types.gen.ts | 20 +++++---- .../svelte-query/fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../name-builder/core/types.gen.ts | 20 +++++---- .../name-builder/core/utils.gen.ts | 6 +-- .../vue-query/asClass/client/client.gen.ts | 11 ++--- .../vue-query/asClass/client/types.gen.ts | 43 ++++++++++--------- .../vue-query/asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../vue-query/asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../vue-query/asClass/core/types.gen.ts | 20 +++++---- .../vue-query/asClass/core/utils.gen.ts | 6 +-- .../vue-query/axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../vue-query/axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../vue-query/axios/core/types.gen.ts | 20 +++++---- .../vue-query/axios/core/utils.gen.ts | 6 +-- .../vue-query/fetch/client/client.gen.ts | 11 ++--- .../vue-query/fetch/client/types.gen.ts | 43 ++++++++++--------- .../vue-query/fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../vue-query/fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../vue-query/fetch/core/types.gen.ts | 20 +++++---- .../vue-query/fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../vue-query/name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../vue-query/name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../vue-query/name-builder/core/types.gen.ts | 20 +++++---- .../vue-query/name-builder/core/utils.gen.ts | 6 +-- .../2.0.x/schema-unknown/client/client.gen.ts | 11 ++--- .../2.0.x/schema-unknown/client/types.gen.ts | 43 ++++++++++--------- .../2.0.x/schema-unknown/core/auth.gen.ts | 6 +-- .../schema-unknown/core/bodySerializer.gen.ts | 8 ++-- .../2.0.x/schema-unknown/core/params.gen.ts | 12 +++--- .../schema-unknown/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../2.0.x/schema-unknown/core/types.gen.ts | 20 +++++---- .../2.0.x/schema-unknown/core/utils.gen.ts | 6 +-- .../security-api-key/client/client.gen.ts | 11 ++--- .../security-api-key/client/types.gen.ts | 43 ++++++++++--------- .../2.0.x/security-api-key/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../2.0.x/security-api-key/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../2.0.x/security-api-key/core/types.gen.ts | 20 +++++---- .../2.0.x/security-api-key/core/utils.gen.ts | 6 +-- .../2.0.x/security-basic/client/client.gen.ts | 11 ++--- .../2.0.x/security-basic/client/types.gen.ts | 43 ++++++++++--------- .../2.0.x/security-basic/core/auth.gen.ts | 6 +-- .../security-basic/core/bodySerializer.gen.ts | 8 ++-- .../2.0.x/security-basic/core/params.gen.ts | 12 +++--- .../security-basic/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../2.0.x/security-basic/core/types.gen.ts | 20 +++++---- .../2.0.x/security-basic/core/utils.gen.ts | 6 +-- .../2.0.x/security-false/client/client.gen.ts | 11 ++--- .../2.0.x/security-false/client/types.gen.ts | 43 ++++++++++--------- .../2.0.x/security-false/core/auth.gen.ts | 6 +-- .../security-false/core/bodySerializer.gen.ts | 8 ++-- .../2.0.x/security-false/core/params.gen.ts | 12 +++--- .../security-false/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../2.0.x/security-false/core/types.gen.ts | 20 +++++---- .../2.0.x/security-false/core/utils.gen.ts | 6 +-- .../security-oauth2/client/client.gen.ts | 11 ++--- .../2.0.x/security-oauth2/client/types.gen.ts | 43 ++++++++++--------- .../2.0.x/security-oauth2/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../2.0.x/security-oauth2/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../2.0.x/security-oauth2/core/types.gen.ts | 20 +++++---- .../2.0.x/security-oauth2/core/utils.gen.ts | 6 +-- .../servers-base-path/client/client.gen.ts | 11 ++--- .../servers-base-path/client/types.gen.ts | 43 ++++++++++--------- .../2.0.x/servers-base-path/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../servers-base-path/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../2.0.x/servers-base-path/core/types.gen.ts | 20 +++++---- .../2.0.x/servers-base-path/core/utils.gen.ts | 6 +-- .../2.0.x/servers-host/client/client.gen.ts | 11 ++--- .../2.0.x/servers-host/client/types.gen.ts | 43 ++++++++++--------- .../2.0.x/servers-host/core/auth.gen.ts | 6 +-- .../servers-host/core/bodySerializer.gen.ts | 8 ++-- .../2.0.x/servers-host/core/params.gen.ts | 12 +++--- .../servers-host/core/pathSerializer.gen.ts | 2 +- .../servers-host/core/serverSentEvents.gen.ts | 26 +++++------ .../2.0.x/servers-host/core/types.gen.ts | 20 +++++---- .../2.0.x/servers-host/core/utils.gen.ts | 6 +-- .../2.0.x/servers/client/client.gen.ts | 11 ++--- .../2.0.x/servers/client/types.gen.ts | 43 ++++++++++--------- .../2.0.x/servers/core/auth.gen.ts | 6 +-- .../2.0.x/servers/core/bodySerializer.gen.ts | 8 ++-- .../2.0.x/servers/core/params.gen.ts | 12 +++--- .../2.0.x/servers/core/pathSerializer.gen.ts | 2 +- .../servers/core/serverSentEvents.gen.ts | 26 +++++------ .../2.0.x/servers/core/types.gen.ts | 20 +++++---- .../2.0.x/servers/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../transforms-read-write/client/types.gen.ts | 43 ++++++++++--------- .../transforms-read-write/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../transforms-read-write/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../transforms-read-write/core/types.gen.ts | 20 +++++---- .../transforms-read-write/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../body-response-text-plain/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../3.0.x/content-types/core/auth.gen.ts | 6 +-- .../content-types/core/bodySerializer.gen.ts | 8 ++-- .../3.0.x/content-types/core/params.gen.ts | 12 +++--- .../content-types/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../3.0.x/content-types/core/types.gen.ts | 20 +++++---- .../3.0.x/content-types/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../internal-name-conflict/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../internal-name-conflict/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../internal-name-conflict/core/types.gen.ts | 20 +++++---- .../internal-name-conflict/core/utils.gen.ts | 6 +-- .../core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../parameter-explode-false/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../parameter-explode-false/core/types.gen.ts | 20 +++++---- .../parameter-explode-false/core/utils.gen.ts | 6 +-- .../common/default-class/client/types.gen.ts | 2 +- .../common/default-class/core/auth.gen.ts | 6 +-- .../default-class/core/bodySerializer.gen.ts | 8 ++-- .../common/default-class/core/params.gen.ts | 12 +++--- .../default-class/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../common/default-class/core/types.gen.ts | 20 +++++---- .../common/default-class/core/utils.gen.ts | 6 +-- .../common/default/client/types.gen.ts | 2 +- .../@angular/common/default/core/auth.gen.ts | 6 +-- .../common/default/core/bodySerializer.gen.ts | 8 ++-- .../common/default/core/params.gen.ts | 12 +++--- .../common/default/core/pathSerializer.gen.ts | 2 +- .../default/core/serverSentEvents.gen.ts | 26 +++++------ .../@angular/common/default/core/types.gen.ts | 20 +++++---- .../@angular/common/default/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../sdk-nested-classes/client/client.gen.ts | 11 ++--- .../sdk-nested-classes/client/types.gen.ts | 43 ++++++++++--------- .../sdk-nested-classes/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-nested-classes/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-nested-classes/core/types.gen.ts | 20 +++++---- .../sdk-nested-classes/core/utils.gen.ts | 6 +-- .../@hey-api/sdk/default/client/client.gen.ts | 11 ++--- .../@hey-api/sdk/default/client/types.gen.ts | 43 ++++++++++--------- .../@hey-api/sdk/default/core/auth.gen.ts | 6 +-- .../sdk/default/core/bodySerializer.gen.ts | 8 ++-- .../@hey-api/sdk/default/core/params.gen.ts | 12 +++--- .../sdk/default/core/pathSerializer.gen.ts | 2 +- .../sdk/default/core/serverSentEvents.gen.ts | 26 +++++------ .../@hey-api/sdk/default/core/types.gen.ts | 20 +++++---- .../@hey-api/sdk/default/core/utils.gen.ts | 6 +-- .../sdk/instance/client/client.gen.ts | 11 ++--- .../@hey-api/sdk/instance/client/types.gen.ts | 43 ++++++++++--------- .../@hey-api/sdk/instance/core/auth.gen.ts | 6 +-- .../sdk/instance/core/bodySerializer.gen.ts | 8 ++-- .../@hey-api/sdk/instance/core/params.gen.ts | 12 +++--- .../sdk/instance/core/pathSerializer.gen.ts | 2 +- .../sdk/instance/core/serverSentEvents.gen.ts | 26 +++++------ .../@hey-api/sdk/instance/core/types.gen.ts | 20 +++++---- .../@hey-api/sdk/instance/core/utils.gen.ts | 6 +-- .../sdk/throwOnError/client/client.gen.ts | 11 ++--- .../sdk/throwOnError/client/types.gen.ts | 43 ++++++++++--------- .../sdk/throwOnError/core/auth.gen.ts | 6 +-- .../throwOnError/core/bodySerializer.gen.ts | 8 ++-- .../sdk/throwOnError/core/params.gen.ts | 12 +++--- .../throwOnError/core/pathSerializer.gen.ts | 2 +- .../throwOnError/core/serverSentEvents.gen.ts | 26 +++++------ .../sdk/throwOnError/core/types.gen.ts | 20 +++++---- .../sdk/throwOnError/core/utils.gen.ts | 6 +-- .../type-format-valibot/client/client.gen.ts | 11 ++--- .../type-format-valibot/client/types.gen.ts | 43 ++++++++++--------- .../type-format-valibot/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../type-format-valibot/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../type-format-valibot/core/types.gen.ts | 20 +++++---- .../type-format-valibot/core/utils.gen.ts | 6 +-- .../type-format-zod/client/client.gen.ts | 11 ++--- .../type-format-zod/client/types.gen.ts | 43 ++++++++++--------- .../type-format-zod/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../type-format-zod/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../type-format-zod/core/types.gen.ts | 20 +++++---- .../type-format-zod/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../colada/asClass/client/client.gen.ts | 11 ++--- .../@pinia/colada/asClass/client/types.gen.ts | 43 ++++++++++--------- .../@pinia/colada/asClass/core/auth.gen.ts | 6 +-- .../colada/asClass/core/bodySerializer.gen.ts | 8 ++-- .../@pinia/colada/asClass/core/params.gen.ts | 12 +++--- .../colada/asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../@pinia/colada/asClass/core/types.gen.ts | 20 +++++---- .../@pinia/colada/asClass/core/utils.gen.ts | 6 +-- .../@pinia/colada/fetch/client/client.gen.ts | 11 ++--- .../@pinia/colada/fetch/client/types.gen.ts | 43 ++++++++++--------- .../@pinia/colada/fetch/core/auth.gen.ts | 6 +-- .../colada/fetch/core/bodySerializer.gen.ts | 8 ++-- .../@pinia/colada/fetch/core/params.gen.ts | 12 +++--- .../colada/fetch/core/pathSerializer.gen.ts | 2 +- .../colada/fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../@pinia/colada/fetch/core/types.gen.ts | 20 +++++---- .../@pinia/colada/fetch/core/utils.gen.ts | 6 +-- .../asClass/client/client.gen.ts | 11 ++--- .../asClass/client/types.gen.ts | 43 ++++++++++--------- .../asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../asClass/core/types.gen.ts | 20 +++++---- .../asClass/core/utils.gen.ts | 6 +-- .../axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../axios/core/types.gen.ts | 20 +++++---- .../axios/core/utils.gen.ts | 6 +-- .../fetch/client/client.gen.ts | 11 ++--- .../fetch/client/types.gen.ts | 43 ++++++++++--------- .../fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../fetch/core/types.gen.ts | 20 +++++---- .../fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../name-builder/core/types.gen.ts | 20 +++++---- .../name-builder/core/utils.gen.ts | 6 +-- .../react-query/asClass/client/client.gen.ts | 11 ++--- .../react-query/asClass/client/types.gen.ts | 43 ++++++++++--------- .../react-query/asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../react-query/asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../react-query/asClass/core/types.gen.ts | 20 +++++---- .../react-query/asClass/core/utils.gen.ts | 6 +-- .../react-query/axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../react-query/axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../react-query/axios/core/types.gen.ts | 20 +++++---- .../react-query/axios/core/utils.gen.ts | 6 +-- .../react-query/fetch/client/client.gen.ts | 11 ++--- .../react-query/fetch/client/types.gen.ts | 43 ++++++++++--------- .../react-query/fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../react-query/fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../react-query/fetch/core/types.gen.ts | 20 +++++---- .../react-query/fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../react-query/name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../name-builder/core/types.gen.ts | 20 +++++---- .../name-builder/core/utils.gen.ts | 6 +-- .../solid-query/asClass/client/client.gen.ts | 11 ++--- .../solid-query/asClass/client/types.gen.ts | 43 ++++++++++--------- .../solid-query/asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../solid-query/asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../solid-query/asClass/core/types.gen.ts | 20 +++++---- .../solid-query/asClass/core/utils.gen.ts | 6 +-- .../solid-query/axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../solid-query/axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../solid-query/axios/core/types.gen.ts | 20 +++++---- .../solid-query/axios/core/utils.gen.ts | 6 +-- .../solid-query/fetch/client/client.gen.ts | 11 ++--- .../solid-query/fetch/client/types.gen.ts | 43 ++++++++++--------- .../solid-query/fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../solid-query/fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../solid-query/fetch/core/types.gen.ts | 20 +++++---- .../solid-query/fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../solid-query/name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../name-builder/core/types.gen.ts | 20 +++++---- .../name-builder/core/utils.gen.ts | 6 +-- .../svelte-query/asClass/client/client.gen.ts | 11 ++--- .../svelte-query/asClass/client/types.gen.ts | 43 ++++++++++--------- .../svelte-query/asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../svelte-query/asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../svelte-query/asClass/core/types.gen.ts | 20 +++++---- .../svelte-query/asClass/core/utils.gen.ts | 6 +-- .../svelte-query/axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../svelte-query/axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../svelte-query/axios/core/types.gen.ts | 20 +++++---- .../svelte-query/axios/core/utils.gen.ts | 6 +-- .../svelte-query/fetch/client/client.gen.ts | 11 ++--- .../svelte-query/fetch/client/types.gen.ts | 43 ++++++++++--------- .../svelte-query/fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../svelte-query/fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../svelte-query/fetch/core/types.gen.ts | 20 +++++---- .../svelte-query/fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../name-builder/core/types.gen.ts | 20 +++++---- .../name-builder/core/utils.gen.ts | 6 +-- .../vue-query/asClass/client/client.gen.ts | 11 ++--- .../vue-query/asClass/client/types.gen.ts | 43 ++++++++++--------- .../vue-query/asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../vue-query/asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../vue-query/asClass/core/types.gen.ts | 20 +++++---- .../vue-query/asClass/core/utils.gen.ts | 6 +-- .../vue-query/axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../vue-query/axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../vue-query/axios/core/types.gen.ts | 20 +++++---- .../vue-query/axios/core/utils.gen.ts | 6 +-- .../vue-query/fetch/client/client.gen.ts | 11 ++--- .../vue-query/fetch/client/types.gen.ts | 43 ++++++++++--------- .../vue-query/fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../vue-query/fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../vue-query/fetch/core/types.gen.ts | 20 +++++---- .../vue-query/fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../vue-query/name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../vue-query/name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../vue-query/name-builder/core/types.gen.ts | 20 +++++---- .../vue-query/name-builder/core/utils.gen.ts | 6 +-- .../security-api-key/client/client.gen.ts | 11 ++--- .../security-api-key/client/types.gen.ts | 43 ++++++++++--------- .../3.0.x/security-api-key/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../3.0.x/security-api-key/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../3.0.x/security-api-key/core/types.gen.ts | 20 +++++---- .../3.0.x/security-api-key/core/utils.gen.ts | 6 +-- .../3.0.x/security-false/client/client.gen.ts | 11 ++--- .../3.0.x/security-false/client/types.gen.ts | 43 ++++++++++--------- .../3.0.x/security-false/core/auth.gen.ts | 6 +-- .../security-false/core/bodySerializer.gen.ts | 8 ++-- .../3.0.x/security-false/core/params.gen.ts | 12 +++--- .../security-false/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../3.0.x/security-false/core/types.gen.ts | 20 +++++---- .../3.0.x/security-false/core/utils.gen.ts | 6 +-- .../security-http-bearer/client/client.gen.ts | 11 ++--- .../security-http-bearer/client/types.gen.ts | 43 ++++++++++--------- .../security-http-bearer/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../security-http-bearer/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../security-http-bearer/core/types.gen.ts | 20 +++++---- .../security-http-bearer/core/utils.gen.ts | 6 +-- .../security-oauth2/client/client.gen.ts | 11 ++--- .../3.0.x/security-oauth2/client/types.gen.ts | 43 ++++++++++--------- .../3.0.x/security-oauth2/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../3.0.x/security-oauth2/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../3.0.x/security-oauth2/core/types.gen.ts | 20 +++++---- .../3.0.x/security-oauth2/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../security-open-id-connect/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../3.0.x/servers/client/client.gen.ts | 11 ++--- .../3.0.x/servers/client/types.gen.ts | 43 ++++++++++--------- .../3.0.x/servers/core/auth.gen.ts | 6 +-- .../3.0.x/servers/core/bodySerializer.gen.ts | 8 ++-- .../3.0.x/servers/core/params.gen.ts | 12 +++--- .../3.0.x/servers/core/pathSerializer.gen.ts | 2 +- .../servers/core/serverSentEvents.gen.ts | 26 +++++------ .../3.0.x/servers/core/types.gen.ts | 20 +++++---- .../3.0.x/servers/core/utils.gen.ts | 6 +-- .../transformers-all-of/client/client.gen.ts | 11 ++--- .../transformers-all-of/client/types.gen.ts | 43 ++++++++++--------- .../transformers-all-of/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../transformers-all-of/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../transformers-all-of/core/types.gen.ts | 20 +++++---- .../transformers-all-of/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../transformers-any-of-null/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../transformers-array/client/client.gen.ts | 11 ++--- .../transformers-array/client/types.gen.ts | 43 ++++++++++--------- .../3.0.x/transformers-array/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../transformers-array/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../transformers-array/core/types.gen.ts | 20 +++++---- .../transformers-array/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../transformers-recursive/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../transformers-recursive/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../transformers-recursive/core/types.gen.ts | 20 +++++---- .../transformers-recursive/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../transforms-read-write/client/types.gen.ts | 43 ++++++++++--------- .../transforms-read-write/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../transforms-read-write/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../transforms-read-write/core/types.gen.ts | 20 +++++---- .../transforms-read-write/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../body-response-text-plain/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../base-url-false/client/types.gen.ts | 2 +- .../base-url-false/core/auth.gen.ts | 6 +-- .../base-url-false/core/bodySerializer.gen.ts | 8 ++-- .../base-url-false/core/params.gen.ts | 12 +++--- .../base-url-false/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-false/core/types.gen.ts | 20 +++++---- .../base-url-false/core/utils.gen.ts | 6 +-- .../base-url-number/client/types.gen.ts | 2 +- .../base-url-number/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-number/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-number/core/types.gen.ts | 20 +++++---- .../base-url-number/core/utils.gen.ts | 6 +-- .../base-url-strict/client/types.gen.ts | 2 +- .../base-url-strict/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-strict/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-strict/core/types.gen.ts | 20 +++++---- .../base-url-strict/core/utils.gen.ts | 6 +-- .../base-url-string/client/types.gen.ts | 2 +- .../base-url-string/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-string/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-string/core/types.gen.ts | 20 +++++---- .../base-url-string/core/utils.gen.ts | 6 +-- .../clean-false/client/types.gen.ts | 2 +- .../clean-false/core/auth.gen.ts | 6 +-- .../clean-false/core/bodySerializer.gen.ts | 8 ++-- .../clean-false/core/params.gen.ts | 12 +++--- .../clean-false/core/pathSerializer.gen.ts | 2 +- .../clean-false/core/serverSentEvents.gen.ts | 26 +++++------ .../clean-false/core/types.gen.ts | 20 +++++---- .../clean-false/core/utils.gen.ts | 6 +-- .../default/client/types.gen.ts | 2 +- .../client-angular/default/core/auth.gen.ts | 6 +-- .../default/core/bodySerializer.gen.ts | 8 ++-- .../client-angular/default/core/params.gen.ts | 12 +++--- .../default/core/pathSerializer.gen.ts | 2 +- .../default/core/serverSentEvents.gen.ts | 26 +++++------ .../client-angular/default/core/types.gen.ts | 20 +++++---- .../client-angular/default/core/utils.gen.ts | 6 +-- .../client/types.gen.ts | 2 +- .../import-file-extension-ts/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../sdk-client-optional/client/types.gen.ts | 2 +- .../sdk-client-optional/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-optional/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-optional/core/types.gen.ts | 20 +++++---- .../sdk-client-optional/core/utils.gen.ts | 6 +-- .../sdk-client-required/client/types.gen.ts | 2 +- .../sdk-client-required/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-required/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-required/core/types.gen.ts | 20 +++++---- .../sdk-client-required/core/utils.gen.ts | 6 +-- .../tsconfig-node16-sdk/client/types.gen.ts | 2 +- .../tsconfig-node16-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-node16-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-node16-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-node16-sdk/core/utils.gen.ts | 6 +-- .../tsconfig-nodenext-sdk/client/types.gen.ts | 2 +- .../tsconfig-nodenext-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-nodenext-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-nodenext-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-nodenext-sdk/core/utils.gen.ts | 6 +-- .../base-url-false/core/auth.gen.ts | 6 +-- .../base-url-false/core/bodySerializer.gen.ts | 8 ++-- .../base-url-false/core/params.gen.ts | 12 +++--- .../base-url-false/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-false/core/types.gen.ts | 20 +++++---- .../base-url-false/core/utils.gen.ts | 6 +-- .../base-url-number/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-number/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-number/core/types.gen.ts | 20 +++++---- .../base-url-number/core/utils.gen.ts | 6 +-- .../base-url-strict/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-strict/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-strict/core/types.gen.ts | 20 +++++---- .../base-url-strict/core/utils.gen.ts | 6 +-- .../base-url-string/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-string/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-string/core/types.gen.ts | 20 +++++---- .../base-url-string/core/utils.gen.ts | 6 +-- .../client-axios/clean-false/core/auth.gen.ts | 6 +-- .../clean-false/core/bodySerializer.gen.ts | 8 ++-- .../clean-false/core/params.gen.ts | 12 +++--- .../clean-false/core/pathSerializer.gen.ts | 2 +- .../clean-false/core/serverSentEvents.gen.ts | 26 +++++------ .../clean-false/core/types.gen.ts | 20 +++++---- .../clean-false/core/utils.gen.ts | 6 +-- .../client-axios/default/core/auth.gen.ts | 6 +-- .../default/core/bodySerializer.gen.ts | 8 ++-- .../client-axios/default/core/params.gen.ts | 12 +++--- .../default/core/pathSerializer.gen.ts | 2 +- .../default/core/serverSentEvents.gen.ts | 26 +++++------ .../client-axios/default/core/types.gen.ts | 20 +++++---- .../client-axios/default/core/utils.gen.ts | 6 +-- .../import-file-extension-ts/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../sdk-client-optional/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-optional/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-optional/core/types.gen.ts | 20 +++++---- .../sdk-client-optional/core/utils.gen.ts | 6 +-- .../sdk-client-required/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-required/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-required/core/types.gen.ts | 20 +++++---- .../sdk-client-required/core/utils.gen.ts | 6 +-- .../tsconfig-node16-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-node16-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-node16-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-node16-sdk/core/utils.gen.ts | 6 +-- .../tsconfig-nodenext-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-nodenext-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-nodenext-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-nodenext-sdk/core/utils.gen.ts | 6 +-- .../base-url-false/client/client.gen.ts | 11 ++--- .../base-url-false/client/types.gen.ts | 43 ++++++++++--------- .../base-url-false/core/auth.gen.ts | 6 +-- .../base-url-false/core/bodySerializer.gen.ts | 8 ++-- .../base-url-false/core/params.gen.ts | 12 +++--- .../base-url-false/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-false/core/types.gen.ts | 20 +++++---- .../base-url-false/core/utils.gen.ts | 6 +-- .../base-url-number/client/client.gen.ts | 11 ++--- .../base-url-number/client/types.gen.ts | 43 ++++++++++--------- .../base-url-number/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-number/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-number/core/types.gen.ts | 20 +++++---- .../base-url-number/core/utils.gen.ts | 6 +-- .../base-url-strict/client/client.gen.ts | 11 ++--- .../base-url-strict/client/types.gen.ts | 43 ++++++++++--------- .../base-url-strict/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-strict/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-strict/core/types.gen.ts | 20 +++++---- .../base-url-strict/core/utils.gen.ts | 6 +-- .../base-url-string/client/client.gen.ts | 11 ++--- .../base-url-string/client/types.gen.ts | 43 ++++++++++--------- .../base-url-string/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-string/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-string/core/types.gen.ts | 20 +++++---- .../base-url-string/core/utils.gen.ts | 6 +-- .../clean-false/client/client.gen.ts | 11 ++--- .../clean-false/client/types.gen.ts | 43 ++++++++++--------- .../client-fetch/clean-false/core/auth.gen.ts | 6 +-- .../clean-false/core/bodySerializer.gen.ts | 8 ++-- .../clean-false/core/params.gen.ts | 12 +++--- .../clean-false/core/pathSerializer.gen.ts | 2 +- .../clean-false/core/serverSentEvents.gen.ts | 26 +++++------ .../clean-false/core/types.gen.ts | 20 +++++---- .../clean-false/core/utils.gen.ts | 6 +-- .../client-fetch/default/client/client.gen.ts | 11 ++--- .../client-fetch/default/client/types.gen.ts | 43 ++++++++++--------- .../client-fetch/default/core/auth.gen.ts | 6 +-- .../default/core/bodySerializer.gen.ts | 8 ++-- .../client-fetch/default/core/params.gen.ts | 12 +++--- .../default/core/pathSerializer.gen.ts | 2 +- .../default/core/serverSentEvents.gen.ts | 26 +++++------ .../client-fetch/default/core/types.gen.ts | 20 +++++---- .../client-fetch/default/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../import-file-extension-ts/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../sdk-client-optional/client/client.gen.ts | 11 ++--- .../sdk-client-optional/client/types.gen.ts | 43 ++++++++++--------- .../sdk-client-optional/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-optional/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-optional/core/types.gen.ts | 20 +++++---- .../sdk-client-optional/core/utils.gen.ts | 6 +-- .../sdk-client-required/client/client.gen.ts | 11 ++--- .../sdk-client-required/client/types.gen.ts | 43 ++++++++++--------- .../sdk-client-required/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-required/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-required/core/types.gen.ts | 20 +++++---- .../sdk-client-required/core/utils.gen.ts | 6 +-- .../tsconfig-node16-sdk/client/client.gen.ts | 11 ++--- .../tsconfig-node16-sdk/client/types.gen.ts | 43 ++++++++++--------- .../tsconfig-node16-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-node16-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-node16-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-node16-sdk/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../tsconfig-nodenext-sdk/client/types.gen.ts | 43 ++++++++++--------- .../tsconfig-nodenext-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-nodenext-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-nodenext-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-nodenext-sdk/core/utils.gen.ts | 6 +-- .../base-url-false/client/types.gen.ts | 2 +- .../client-ky/base-url-false/core/auth.gen.ts | 6 +-- .../base-url-false/core/bodySerializer.gen.ts | 8 ++-- .../base-url-false/core/params.gen.ts | 12 +++--- .../base-url-false/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-false/core/types.gen.ts | 20 +++++---- .../base-url-false/core/utils.gen.ts | 6 +-- .../base-url-number/client/types.gen.ts | 2 +- .../base-url-number/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-number/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-number/core/types.gen.ts | 20 +++++---- .../base-url-number/core/utils.gen.ts | 6 +-- .../base-url-strict/client/types.gen.ts | 2 +- .../base-url-strict/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-strict/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-strict/core/types.gen.ts | 20 +++++---- .../base-url-strict/core/utils.gen.ts | 6 +-- .../base-url-string/client/types.gen.ts | 2 +- .../base-url-string/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-string/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-string/core/types.gen.ts | 20 +++++---- .../base-url-string/core/utils.gen.ts | 6 +-- .../client-ky/clean-false/client/types.gen.ts | 2 +- .../client-ky/clean-false/core/auth.gen.ts | 6 +-- .../clean-false/core/bodySerializer.gen.ts | 8 ++-- .../client-ky/clean-false/core/params.gen.ts | 12 +++--- .../clean-false/core/pathSerializer.gen.ts | 2 +- .../clean-false/core/serverSentEvents.gen.ts | 26 +++++------ .../client-ky/clean-false/core/types.gen.ts | 20 +++++---- .../client-ky/clean-false/core/utils.gen.ts | 6 +-- .../client-ky/default/client/types.gen.ts | 2 +- .../client-ky/default/core/auth.gen.ts | 6 +-- .../default/core/bodySerializer.gen.ts | 8 ++-- .../client-ky/default/core/params.gen.ts | 12 +++--- .../default/core/pathSerializer.gen.ts | 2 +- .../default/core/serverSentEvents.gen.ts | 26 +++++------ .../client-ky/default/core/types.gen.ts | 20 +++++---- .../client-ky/default/core/utils.gen.ts | 6 +-- .../client/types.gen.ts | 2 +- .../import-file-extension-ts/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../sdk-client-optional/client/types.gen.ts | 2 +- .../sdk-client-optional/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-optional/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-optional/core/types.gen.ts | 20 +++++---- .../sdk-client-optional/core/utils.gen.ts | 6 +-- .../sdk-client-required/client/types.gen.ts | 2 +- .../sdk-client-required/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-required/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-required/core/types.gen.ts | 20 +++++---- .../sdk-client-required/core/utils.gen.ts | 6 +-- .../tsconfig-node16-sdk/client/types.gen.ts | 2 +- .../tsconfig-node16-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-node16-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-node16-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-node16-sdk/core/utils.gen.ts | 6 +-- .../tsconfig-nodenext-sdk/client/types.gen.ts | 2 +- .../tsconfig-nodenext-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-nodenext-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-nodenext-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-nodenext-sdk/core/utils.gen.ts | 6 +-- .../base-url-false/client/client.gen.ts | 9 +--- .../base-url-false/client/types.gen.ts | 2 +- .../base-url-false/core/auth.gen.ts | 6 +-- .../base-url-false/core/bodySerializer.gen.ts | 8 ++-- .../base-url-false/core/params.gen.ts | 12 +++--- .../base-url-false/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-false/core/types.gen.ts | 20 +++++---- .../base-url-false/core/utils.gen.ts | 6 +-- .../base-url-number/client/client.gen.ts | 9 +--- .../base-url-number/client/types.gen.ts | 2 +- .../base-url-number/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-number/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-number/core/types.gen.ts | 20 +++++---- .../base-url-number/core/utils.gen.ts | 6 +-- .../base-url-strict/client/client.gen.ts | 9 +--- .../base-url-strict/client/types.gen.ts | 2 +- .../base-url-strict/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-strict/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-strict/core/types.gen.ts | 20 +++++---- .../base-url-strict/core/utils.gen.ts | 6 +-- .../base-url-string/client/client.gen.ts | 9 +--- .../base-url-string/client/types.gen.ts | 2 +- .../base-url-string/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-string/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-string/core/types.gen.ts | 20 +++++---- .../base-url-string/core/utils.gen.ts | 6 +-- .../clean-false/client/client.gen.ts | 9 +--- .../clean-false/client/types.gen.ts | 2 +- .../client-next/clean-false/core/auth.gen.ts | 6 +-- .../clean-false/core/bodySerializer.gen.ts | 8 ++-- .../clean-false/core/params.gen.ts | 12 +++--- .../clean-false/core/pathSerializer.gen.ts | 2 +- .../clean-false/core/serverSentEvents.gen.ts | 26 +++++------ .../client-next/clean-false/core/types.gen.ts | 20 +++++---- .../client-next/clean-false/core/utils.gen.ts | 6 +-- .../client-next/default/client/client.gen.ts | 9 +--- .../client-next/default/client/types.gen.ts | 2 +- .../client-next/default/core/auth.gen.ts | 6 +-- .../default/core/bodySerializer.gen.ts | 8 ++-- .../client-next/default/core/params.gen.ts | 12 +++--- .../default/core/pathSerializer.gen.ts | 2 +- .../default/core/serverSentEvents.gen.ts | 26 +++++------ .../client-next/default/core/types.gen.ts | 20 +++++---- .../client-next/default/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 9 +--- .../client/types.gen.ts | 2 +- .../import-file-extension-ts/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../sdk-client-optional/client/client.gen.ts | 9 +--- .../sdk-client-optional/client/types.gen.ts | 2 +- .../sdk-client-optional/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-optional/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-optional/core/types.gen.ts | 20 +++++---- .../sdk-client-optional/core/utils.gen.ts | 6 +-- .../sdk-client-required/client/client.gen.ts | 9 +--- .../sdk-client-required/client/types.gen.ts | 2 +- .../sdk-client-required/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-required/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-required/core/types.gen.ts | 20 +++++---- .../sdk-client-required/core/utils.gen.ts | 6 +-- .../tsconfig-node16-sdk/client/client.gen.ts | 9 +--- .../tsconfig-node16-sdk/client/types.gen.ts | 2 +- .../tsconfig-node16-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-node16-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-node16-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-node16-sdk/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 9 +--- .../tsconfig-nodenext-sdk/client/types.gen.ts | 2 +- .../tsconfig-nodenext-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-nodenext-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-nodenext-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-nodenext-sdk/core/utils.gen.ts | 6 +-- .../base-url-false/core/auth.gen.ts | 6 +-- .../base-url-false/core/bodySerializer.gen.ts | 8 ++-- .../base-url-false/core/params.gen.ts | 12 +++--- .../base-url-false/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-false/core/types.gen.ts | 20 +++++---- .../base-url-false/core/utils.gen.ts | 6 +-- .../base-url-number/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-number/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-number/core/types.gen.ts | 20 +++++---- .../base-url-number/core/utils.gen.ts | 6 +-- .../base-url-strict/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-strict/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-strict/core/types.gen.ts | 20 +++++---- .../base-url-strict/core/utils.gen.ts | 6 +-- .../base-url-string/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-string/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-string/core/types.gen.ts | 20 +++++---- .../base-url-string/core/utils.gen.ts | 6 +-- .../client-nuxt/clean-false/core/auth.gen.ts | 6 +-- .../clean-false/core/bodySerializer.gen.ts | 8 ++-- .../clean-false/core/params.gen.ts | 12 +++--- .../clean-false/core/pathSerializer.gen.ts | 2 +- .../clean-false/core/serverSentEvents.gen.ts | 26 +++++------ .../client-nuxt/clean-false/core/types.gen.ts | 20 +++++---- .../client-nuxt/clean-false/core/utils.gen.ts | 6 +-- .../client-nuxt/default/core/auth.gen.ts | 6 +-- .../default/core/bodySerializer.gen.ts | 8 ++-- .../client-nuxt/default/core/params.gen.ts | 12 +++--- .../default/core/pathSerializer.gen.ts | 2 +- .../default/core/serverSentEvents.gen.ts | 26 +++++------ .../client-nuxt/default/core/types.gen.ts | 20 +++++---- .../client-nuxt/default/core/utils.gen.ts | 6 +-- .../import-file-extension-ts/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../sdk-client-optional/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-optional/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-optional/core/types.gen.ts | 20 +++++---- .../sdk-client-optional/core/utils.gen.ts | 6 +-- .../sdk-client-required/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-required/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-required/core/types.gen.ts | 20 +++++---- .../sdk-client-required/core/utils.gen.ts | 6 +-- .../tsconfig-node16-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-node16-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-node16-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-node16-sdk/core/utils.gen.ts | 6 +-- .../tsconfig-nodenext-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-nodenext-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-nodenext-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-nodenext-sdk/core/utils.gen.ts | 6 +-- .../base-url-false/client/types.gen.ts | 2 +- .../base-url-false/core/auth.gen.ts | 6 +-- .../base-url-false/core/bodySerializer.gen.ts | 8 ++-- .../base-url-false/core/params.gen.ts | 12 +++--- .../base-url-false/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-false/core/types.gen.ts | 20 +++++---- .../base-url-false/core/utils.gen.ts | 6 +-- .../base-url-number/client/types.gen.ts | 2 +- .../base-url-number/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-number/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-number/core/types.gen.ts | 20 +++++---- .../base-url-number/core/utils.gen.ts | 6 +-- .../base-url-strict/client/types.gen.ts | 2 +- .../base-url-strict/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-strict/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-strict/core/types.gen.ts | 20 +++++---- .../base-url-strict/core/utils.gen.ts | 6 +-- .../base-url-string/client/types.gen.ts | 2 +- .../base-url-string/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../base-url-string/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../base-url-string/core/types.gen.ts | 20 +++++---- .../base-url-string/core/utils.gen.ts | 6 +-- .../clean-false/client/types.gen.ts | 2 +- .../clean-false/core/auth.gen.ts | 6 +-- .../clean-false/core/bodySerializer.gen.ts | 8 ++-- .../clean-false/core/params.gen.ts | 12 +++--- .../clean-false/core/pathSerializer.gen.ts | 2 +- .../clean-false/core/serverSentEvents.gen.ts | 26 +++++------ .../clean-false/core/types.gen.ts | 20 +++++---- .../clean-false/core/utils.gen.ts | 6 +-- .../client-ofetch/default/client/types.gen.ts | 2 +- .../client-ofetch/default/core/auth.gen.ts | 6 +-- .../default/core/bodySerializer.gen.ts | 8 ++-- .../client-ofetch/default/core/params.gen.ts | 12 +++--- .../default/core/pathSerializer.gen.ts | 2 +- .../default/core/serverSentEvents.gen.ts | 26 +++++------ .../client-ofetch/default/core/types.gen.ts | 20 +++++---- .../client-ofetch/default/core/utils.gen.ts | 6 +-- .../client/types.gen.ts | 2 +- .../import-file-extension-ts/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../sdk-client-optional/client/types.gen.ts | 2 +- .../sdk-client-optional/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-optional/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-optional/core/types.gen.ts | 20 +++++---- .../sdk-client-optional/core/utils.gen.ts | 6 +-- .../sdk-client-required/client/types.gen.ts | 2 +- .../sdk-client-required/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-client-required/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-client-required/core/types.gen.ts | 20 +++++---- .../sdk-client-required/core/utils.gen.ts | 6 +-- .../tsconfig-node16-sdk/client/types.gen.ts | 2 +- .../tsconfig-node16-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-node16-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-node16-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-node16-sdk/core/utils.gen.ts | 6 +-- .../tsconfig-nodenext-sdk/client/types.gen.ts | 2 +- .../tsconfig-nodenext-sdk/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../tsconfig-nodenext-sdk/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../tsconfig-nodenext-sdk/core/types.gen.ts | 20 +++++---- .../tsconfig-nodenext-sdk/core/utils.gen.ts | 6 +-- .../client-custom/bundle/client/index.d.cts | 34 +++++++-------- .../client-custom/bundle/client/index.d.mts | 34 +++++++-------- .../3.1.x/content-types/core/auth.gen.ts | 6 +-- .../content-types/core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/content-types/core/params.gen.ts | 12 +++--- .../content-types/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/content-types/core/types.gen.ts | 20 +++++---- .../3.1.x/content-types/core/utils.gen.ts | 6 +-- .../3.1.x/headers/client/client.gen.ts | 11 ++--- .../3.1.x/headers/client/types.gen.ts | 43 ++++++++++--------- .../3.1.x/headers/core/auth.gen.ts | 6 +-- .../3.1.x/headers/core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/headers/core/params.gen.ts | 12 +++--- .../3.1.x/headers/core/pathSerializer.gen.ts | 2 +- .../headers/core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/headers/core/types.gen.ts | 20 +++++---- .../3.1.x/headers/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../internal-name-conflict/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../internal-name-conflict/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../internal-name-conflict/core/types.gen.ts | 20 +++++---- .../internal-name-conflict/core/utils.gen.ts | 6 +-- .../3.1.x/pagination-ref/client/client.gen.ts | 11 ++--- .../3.1.x/pagination-ref/client/types.gen.ts | 43 ++++++++++--------- .../3.1.x/pagination-ref/core/auth.gen.ts | 6 +-- .../pagination-ref/core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/pagination-ref/core/params.gen.ts | 12 +++--- .../pagination-ref/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/pagination-ref/core/types.gen.ts | 20 +++++---- .../3.1.x/pagination-ref/core/utils.gen.ts | 6 +-- .../core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../parameter-explode-false/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../parameter-explode-false/core/types.gen.ts | 20 +++++---- .../parameter-explode-false/core/utils.gen.ts | 6 +-- .../common/default-class/client/types.gen.ts | 2 +- .../common/default-class/core/auth.gen.ts | 6 +-- .../default-class/core/bodySerializer.gen.ts | 8 ++-- .../common/default-class/core/params.gen.ts | 12 +++--- .../default-class/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../common/default-class/core/types.gen.ts | 20 +++++---- .../common/default-class/core/utils.gen.ts | 6 +-- .../common/default/client/types.gen.ts | 2 +- .../@angular/common/default/core/auth.gen.ts | 6 +-- .../common/default/core/bodySerializer.gen.ts | 8 ++-- .../common/default/core/params.gen.ts | 12 +++--- .../common/default/core/pathSerializer.gen.ts | 2 +- .../default/core/serverSentEvents.gen.ts | 26 +++++------ .../@angular/common/default/core/types.gen.ts | 20 +++++---- .../@angular/common/default/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../sdk-nested-classes/client/client.gen.ts | 11 ++--- .../sdk-nested-classes/client/types.gen.ts | 43 ++++++++++--------- .../sdk-nested-classes/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../sdk-nested-classes/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../sdk-nested-classes/core/types.gen.ts | 20 +++++---- .../sdk-nested-classes/core/utils.gen.ts | 6 +-- .../@hey-api/sdk/default/client/client.gen.ts | 11 ++--- .../@hey-api/sdk/default/client/types.gen.ts | 43 ++++++++++--------- .../@hey-api/sdk/default/core/auth.gen.ts | 6 +-- .../sdk/default/core/bodySerializer.gen.ts | 8 ++-- .../@hey-api/sdk/default/core/params.gen.ts | 12 +++--- .../sdk/default/core/pathSerializer.gen.ts | 2 +- .../sdk/default/core/serverSentEvents.gen.ts | 26 +++++------ .../@hey-api/sdk/default/core/types.gen.ts | 20 +++++---- .../@hey-api/sdk/default/core/utils.gen.ts | 6 +-- .../sdk/instance/client/client.gen.ts | 11 ++--- .../@hey-api/sdk/instance/client/types.gen.ts | 43 ++++++++++--------- .../@hey-api/sdk/instance/core/auth.gen.ts | 6 +-- .../sdk/instance/core/bodySerializer.gen.ts | 8 ++-- .../@hey-api/sdk/instance/core/params.gen.ts | 12 +++--- .../sdk/instance/core/pathSerializer.gen.ts | 2 +- .../sdk/instance/core/serverSentEvents.gen.ts | 26 +++++------ .../@hey-api/sdk/instance/core/types.gen.ts | 20 +++++---- .../@hey-api/sdk/instance/core/utils.gen.ts | 6 +-- .../sdk/throwOnError/client/client.gen.ts | 11 ++--- .../sdk/throwOnError/client/types.gen.ts | 43 ++++++++++--------- .../sdk/throwOnError/core/auth.gen.ts | 6 +-- .../throwOnError/core/bodySerializer.gen.ts | 8 ++-- .../sdk/throwOnError/core/params.gen.ts | 12 +++--- .../throwOnError/core/pathSerializer.gen.ts | 2 +- .../throwOnError/core/serverSentEvents.gen.ts | 26 +++++------ .../sdk/throwOnError/core/types.gen.ts | 20 +++++---- .../sdk/throwOnError/core/utils.gen.ts | 6 +-- .../type-format-valibot/client/client.gen.ts | 11 ++--- .../type-format-valibot/client/types.gen.ts | 43 ++++++++++--------- .../type-format-valibot/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../type-format-valibot/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../type-format-valibot/core/types.gen.ts | 20 +++++---- .../type-format-valibot/core/utils.gen.ts | 6 +-- .../type-format-zod/client/client.gen.ts | 11 ++--- .../type-format-zod/client/types.gen.ts | 43 ++++++++++--------- .../type-format-zod/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../type-format-zod/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../type-format-zod/core/types.gen.ts | 20 +++++---- .../type-format-zod/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../colada/asClass/client/client.gen.ts | 11 ++--- .../@pinia/colada/asClass/client/types.gen.ts | 43 ++++++++++--------- .../@pinia/colada/asClass/core/auth.gen.ts | 6 +-- .../colada/asClass/core/bodySerializer.gen.ts | 8 ++-- .../@pinia/colada/asClass/core/params.gen.ts | 12 +++--- .../colada/asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../@pinia/colada/asClass/core/types.gen.ts | 20 +++++---- .../@pinia/colada/asClass/core/utils.gen.ts | 6 +-- .../@pinia/colada/fetch/client/client.gen.ts | 11 ++--- .../@pinia/colada/fetch/client/types.gen.ts | 43 ++++++++++--------- .../@pinia/colada/fetch/core/auth.gen.ts | 6 +-- .../colada/fetch/core/bodySerializer.gen.ts | 8 ++-- .../@pinia/colada/fetch/core/params.gen.ts | 12 +++--- .../colada/fetch/core/pathSerializer.gen.ts | 2 +- .../colada/fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../@pinia/colada/fetch/core/types.gen.ts | 20 +++++---- .../@pinia/colada/fetch/core/utils.gen.ts | 6 +-- .../asClass/client/client.gen.ts | 11 ++--- .../asClass/client/types.gen.ts | 43 ++++++++++--------- .../asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../asClass/core/types.gen.ts | 20 +++++---- .../asClass/core/utils.gen.ts | 6 +-- .../axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../axios/core/types.gen.ts | 20 +++++---- .../axios/core/utils.gen.ts | 6 +-- .../fetch/client/client.gen.ts | 11 ++--- .../fetch/client/types.gen.ts | 43 ++++++++++--------- .../fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../fetch/core/types.gen.ts | 20 +++++---- .../fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../name-builder/core/types.gen.ts | 20 +++++---- .../name-builder/core/utils.gen.ts | 6 +-- .../react-query/asClass/client/client.gen.ts | 11 ++--- .../react-query/asClass/client/types.gen.ts | 43 ++++++++++--------- .../react-query/asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../react-query/asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../react-query/asClass/core/types.gen.ts | 20 +++++---- .../react-query/asClass/core/utils.gen.ts | 6 +-- .../react-query/axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../react-query/axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../react-query/axios/core/types.gen.ts | 20 +++++---- .../react-query/axios/core/utils.gen.ts | 6 +-- .../react-query/fetch/client/client.gen.ts | 11 ++--- .../react-query/fetch/client/types.gen.ts | 43 ++++++++++--------- .../react-query/fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../react-query/fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../react-query/fetch/core/types.gen.ts | 20 +++++---- .../react-query/fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../react-query/name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../name-builder/core/types.gen.ts | 20 +++++---- .../name-builder/core/utils.gen.ts | 6 +-- .../solid-query/asClass/client/client.gen.ts | 11 ++--- .../solid-query/asClass/client/types.gen.ts | 43 ++++++++++--------- .../solid-query/asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../solid-query/asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../solid-query/asClass/core/types.gen.ts | 20 +++++---- .../solid-query/asClass/core/utils.gen.ts | 6 +-- .../solid-query/axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../solid-query/axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../solid-query/axios/core/types.gen.ts | 20 +++++---- .../solid-query/axios/core/utils.gen.ts | 6 +-- .../solid-query/fetch/client/client.gen.ts | 11 ++--- .../solid-query/fetch/client/types.gen.ts | 43 ++++++++++--------- .../solid-query/fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../solid-query/fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../solid-query/fetch/core/types.gen.ts | 20 +++++---- .../solid-query/fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../solid-query/name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../name-builder/core/types.gen.ts | 20 +++++---- .../name-builder/core/utils.gen.ts | 6 +-- .../svelte-query/asClass/client/client.gen.ts | 11 ++--- .../svelte-query/asClass/client/types.gen.ts | 43 ++++++++++--------- .../svelte-query/asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../svelte-query/asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../svelte-query/asClass/core/types.gen.ts | 20 +++++---- .../svelte-query/asClass/core/utils.gen.ts | 6 +-- .../svelte-query/axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../svelte-query/axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../svelte-query/axios/core/types.gen.ts | 20 +++++---- .../svelte-query/axios/core/utils.gen.ts | 6 +-- .../svelte-query/fetch/client/client.gen.ts | 11 ++--- .../svelte-query/fetch/client/types.gen.ts | 43 ++++++++++--------- .../svelte-query/fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../svelte-query/fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../svelte-query/fetch/core/types.gen.ts | 20 +++++---- .../svelte-query/fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../name-builder/core/types.gen.ts | 20 +++++---- .../name-builder/core/utils.gen.ts | 6 +-- .../vue-query/asClass/client/client.gen.ts | 11 ++--- .../vue-query/asClass/client/types.gen.ts | 43 ++++++++++--------- .../vue-query/asClass/core/auth.gen.ts | 6 +-- .../asClass/core/bodySerializer.gen.ts | 8 ++-- .../vue-query/asClass/core/params.gen.ts | 12 +++--- .../asClass/core/pathSerializer.gen.ts | 2 +- .../asClass/core/serverSentEvents.gen.ts | 26 +++++------ .../vue-query/asClass/core/types.gen.ts | 20 +++++---- .../vue-query/asClass/core/utils.gen.ts | 6 +-- .../vue-query/axios/core/auth.gen.ts | 6 +-- .../axios/core/bodySerializer.gen.ts | 8 ++-- .../vue-query/axios/core/params.gen.ts | 12 +++--- .../axios/core/pathSerializer.gen.ts | 2 +- .../axios/core/serverSentEvents.gen.ts | 26 +++++------ .../vue-query/axios/core/types.gen.ts | 20 +++++---- .../vue-query/axios/core/utils.gen.ts | 6 +-- .../vue-query/fetch/client/client.gen.ts | 11 ++--- .../vue-query/fetch/client/types.gen.ts | 43 ++++++++++--------- .../vue-query/fetch/core/auth.gen.ts | 6 +-- .../fetch/core/bodySerializer.gen.ts | 8 ++-- .../vue-query/fetch/core/params.gen.ts | 12 +++--- .../fetch/core/pathSerializer.gen.ts | 2 +- .../fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../vue-query/fetch/core/types.gen.ts | 20 +++++---- .../vue-query/fetch/core/utils.gen.ts | 6 +-- .../name-builder/client/client.gen.ts | 11 ++--- .../name-builder/client/types.gen.ts | 43 ++++++++++--------- .../vue-query/name-builder/core/auth.gen.ts | 6 +-- .../name-builder/core/bodySerializer.gen.ts | 8 ++-- .../vue-query/name-builder/core/params.gen.ts | 12 +++--- .../name-builder/core/pathSerializer.gen.ts | 2 +- .../name-builder/core/serverSentEvents.gen.ts | 26 +++++------ .../vue-query/name-builder/core/types.gen.ts | 20 +++++---- .../vue-query/name-builder/core/utils.gen.ts | 6 +-- .../security-api-key/client/client.gen.ts | 11 ++--- .../security-api-key/client/types.gen.ts | 43 ++++++++++--------- .../3.1.x/security-api-key/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/security-api-key/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/security-api-key/core/types.gen.ts | 20 +++++---- .../3.1.x/security-api-key/core/utils.gen.ts | 6 +-- .../3.1.x/security-false/client/client.gen.ts | 11 ++--- .../3.1.x/security-false/client/types.gen.ts | 43 ++++++++++--------- .../3.1.x/security-false/core/auth.gen.ts | 6 +-- .../security-false/core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/security-false/core/params.gen.ts | 12 +++--- .../security-false/core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/security-false/core/types.gen.ts | 20 +++++---- .../3.1.x/security-false/core/utils.gen.ts | 6 +-- .../security-http-bearer/client/client.gen.ts | 11 ++--- .../security-http-bearer/client/types.gen.ts | 43 ++++++++++--------- .../security-http-bearer/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../security-http-bearer/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../security-http-bearer/core/types.gen.ts | 20 +++++---- .../security-http-bearer/core/utils.gen.ts | 6 +-- .../security-oauth2/client/client.gen.ts | 11 ++--- .../3.1.x/security-oauth2/client/types.gen.ts | 43 ++++++++++--------- .../3.1.x/security-oauth2/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/security-oauth2/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/security-oauth2/core/types.gen.ts | 20 +++++---- .../3.1.x/security-oauth2/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../security-open-id-connect/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../3.1.x/servers/client/client.gen.ts | 11 ++--- .../3.1.x/servers/client/types.gen.ts | 43 ++++++++++--------- .../3.1.x/servers/core/auth.gen.ts | 6 +-- .../3.1.x/servers/core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/servers/core/params.gen.ts | 12 +++--- .../3.1.x/servers/core/pathSerializer.gen.ts | 2 +- .../servers/core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/servers/core/types.gen.ts | 20 +++++---- .../3.1.x/servers/core/utils.gen.ts | 6 +-- .../3.1.x/sse-angular/client/types.gen.ts | 2 +- .../3.1.x/sse-angular/core/auth.gen.ts | 6 +-- .../sse-angular/core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/sse-angular/core/params.gen.ts | 12 +++--- .../sse-angular/core/pathSerializer.gen.ts | 2 +- .../sse-angular/core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/sse-angular/core/types.gen.ts | 20 +++++---- .../3.1.x/sse-angular/core/utils.gen.ts | 6 +-- .../3.1.x/sse-axios/core/auth.gen.ts | 6 +-- .../sse-axios/core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/sse-axios/core/params.gen.ts | 12 +++--- .../sse-axios/core/pathSerializer.gen.ts | 2 +- .../sse-axios/core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/sse-axios/core/types.gen.ts | 20 +++++---- .../3.1.x/sse-axios/core/utils.gen.ts | 6 +-- .../3.1.x/sse-fetch/client/client.gen.ts | 11 ++--- .../3.1.x/sse-fetch/client/types.gen.ts | 43 ++++++++++--------- .../3.1.x/sse-fetch/core/auth.gen.ts | 6 +-- .../sse-fetch/core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/sse-fetch/core/params.gen.ts | 12 +++--- .../sse-fetch/core/pathSerializer.gen.ts | 2 +- .../sse-fetch/core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/sse-fetch/core/types.gen.ts | 20 +++++---- .../3.1.x/sse-fetch/core/utils.gen.ts | 6 +-- .../3.1.x/sse-next/client/client.gen.ts | 9 +--- .../3.1.x/sse-next/client/types.gen.ts | 2 +- .../3.1.x/sse-next/core/auth.gen.ts | 6 +-- .../3.1.x/sse-next/core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/sse-next/core/params.gen.ts | 12 +++--- .../3.1.x/sse-next/core/pathSerializer.gen.ts | 2 +- .../sse-next/core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/sse-next/core/types.gen.ts | 20 +++++---- .../3.1.x/sse-next/core/utils.gen.ts | 6 +-- .../3.1.x/sse-nuxt/core/auth.gen.ts | 6 +-- .../3.1.x/sse-nuxt/core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/sse-nuxt/core/params.gen.ts | 12 +++--- .../3.1.x/sse-nuxt/core/pathSerializer.gen.ts | 2 +- .../sse-nuxt/core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/sse-nuxt/core/types.gen.ts | 20 +++++---- .../3.1.x/sse-nuxt/core/utils.gen.ts | 6 +-- .../3.1.x/sse-ofetch/client/types.gen.ts | 2 +- .../3.1.x/sse-ofetch/core/auth.gen.ts | 6 +-- .../sse-ofetch/core/bodySerializer.gen.ts | 8 ++-- .../3.1.x/sse-ofetch/core/params.gen.ts | 12 +++--- .../sse-ofetch/core/pathSerializer.gen.ts | 2 +- .../sse-ofetch/core/serverSentEvents.gen.ts | 26 +++++------ .../3.1.x/sse-ofetch/core/types.gen.ts | 20 +++++---- .../3.1.x/sse-ofetch/core/utils.gen.ts | 6 +-- .../transformers-all-of/client/client.gen.ts | 11 ++--- .../transformers-all-of/client/types.gen.ts | 43 ++++++++++--------- .../transformers-all-of/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../transformers-all-of/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../transformers-all-of/core/types.gen.ts | 20 +++++---- .../transformers-all-of/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../transformers-any-of-null/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../core/types.gen.ts | 20 +++++---- .../core/utils.gen.ts | 6 +-- .../transformers-array/client/client.gen.ts | 11 ++--- .../transformers-array/client/types.gen.ts | 43 ++++++++++--------- .../3.1.x/transformers-array/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../transformers-array/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../transformers-array/core/types.gen.ts | 20 +++++---- .../transformers-array/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../client/types.gen.ts | 43 ++++++++++--------- .../transformers-recursive/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../transformers-recursive/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../transformers-recursive/core/types.gen.ts | 20 +++++---- .../transformers-recursive/core/utils.gen.ts | 6 +-- .../client/client.gen.ts | 11 ++--- .../transforms-read-write/client/types.gen.ts | 43 ++++++++++--------- .../transforms-read-write/core/auth.gen.ts | 6 +-- .../core/bodySerializer.gen.ts | 8 ++-- .../transforms-read-write/core/params.gen.ts | 12 +++--- .../core/pathSerializer.gen.ts | 2 +- .../core/serverSentEvents.gen.ts | 26 +++++------ .../transforms-read-write/core/types.gen.ts | 20 +++++---- .../transforms-read-write/core/utils.gen.ts | 6 +-- .../class/client/client.gen.ts | 11 ++--- .../class/client/types.gen.ts | 43 ++++++++++--------- .../class/core/auth.gen.ts | 6 +-- .../class/core/bodySerializer.gen.ts | 8 ++-- .../class/core/params.gen.ts | 12 +++--- .../class/core/pathSerializer.gen.ts | 2 +- .../class/core/serverSentEvents.gen.ts | 26 +++++------ .../class/core/types.gen.ts | 20 +++++---- .../class/core/utils.gen.ts | 6 +-- .../flat/client/client.gen.ts | 11 ++--- .../flat/client/types.gen.ts | 43 ++++++++++--------- .../flat/core/auth.gen.ts | 6 +-- .../flat/core/bodySerializer.gen.ts | 8 ++-- .../flat/core/params.gen.ts | 12 +++--- .../flat/core/pathSerializer.gen.ts | 2 +- .../flat/core/serverSentEvents.gen.ts | 26 +++++------ .../flat/core/types.gen.ts | 20 +++++---- .../flat/core/utils.gen.ts | 6 +-- .../instance/client/client.gen.ts | 11 ++--- .../instance/client/types.gen.ts | 43 ++++++++++--------- .../instance/core/auth.gen.ts | 6 +-- .../instance/core/bodySerializer.gen.ts | 8 ++-- .../instance/core/params.gen.ts | 12 +++--- .../instance/core/pathSerializer.gen.ts | 2 +- .../instance/core/serverSentEvents.gen.ts | 26 +++++------ .../instance/core/types.gen.ts | 20 +++++---- .../instance/core/utils.gen.ts | 6 +-- .../opencode/export-all/client/client.gen.ts | 11 ++--- .../opencode/export-all/client/types.gen.ts | 43 ++++++++++--------- .../opencode/export-all/core/auth.gen.ts | 6 +-- .../export-all/core/bodySerializer.gen.ts | 8 ++-- .../opencode/export-all/core/params.gen.ts | 12 +++--- .../export-all/core/pathSerializer.gen.ts | 2 +- .../export-all/core/serverSentEvents.gen.ts | 26 +++++------ .../opencode/export-all/core/types.gen.ts | 20 +++++---- .../opencode/export-all/core/utils.gen.ts | 6 +-- .../opencode/flat/client/client.gen.ts | 11 ++--- .../opencode/flat/client/types.gen.ts | 43 ++++++++++--------- .../opencode/flat/core/auth.gen.ts | 6 +-- .../opencode/flat/core/bodySerializer.gen.ts | 8 ++-- .../opencode/flat/core/params.gen.ts | 12 +++--- .../opencode/flat/core/pathSerializer.gen.ts | 2 +- .../flat/core/serverSentEvents.gen.ts | 26 +++++------ .../opencode/flat/core/types.gen.ts | 20 +++++---- .../opencode/flat/core/utils.gen.ts | 6 +-- .../opencode/grouped/client/client.gen.ts | 11 ++--- .../opencode/grouped/client/types.gen.ts | 43 ++++++++++--------- .../opencode/grouped/core/auth.gen.ts | 6 +-- .../grouped/core/bodySerializer.gen.ts | 8 ++-- .../opencode/grouped/core/params.gen.ts | 12 +++--- .../grouped/core/pathSerializer.gen.ts | 2 +- .../grouped/core/serverSentEvents.gen.ts | 26 +++++------ .../opencode/grouped/core/types.gen.ts | 20 +++++---- .../opencode/grouped/core/utils.gen.ts | 6 +-- .../@hey-api/client-angular/bundle/types.ts | 2 +- .../@hey-api/client-core/bundle/auth.ts | 6 +-- .../client-core/bundle/bodySerializer.ts | 8 ++-- .../@hey-api/client-core/bundle/params.ts | 12 +++--- .../client-core/bundle/pathSerializer.ts | 2 +- .../client-core/bundle/serverSentEvents.ts | 26 +++++------ .../@hey-api/client-core/bundle/types.ts | 20 +++++---- .../@hey-api/client-core/bundle/utils.ts | 6 +-- .../@hey-api/client-fetch/bundle/client.ts | 11 ++--- .../@hey-api/client-fetch/bundle/types.ts | 43 ++++++++++--------- .../@hey-api/client-ky/bundle/types.ts | 2 +- .../@hey-api/client-next/bundle/client.ts | 9 +--- .../@hey-api/client-next/bundle/types.ts | 2 +- .../@hey-api/client-ofetch/bundle/types.ts | 2 +- .../@hey-api/typescript/shared/types.d.ts | 1 + .../plugins/@hey-api/typescript/v1/plugin.ts | 7 +++ .../@hey-api/typescript/v1/toAst/object.ts | 1 + 2119 files changed, 14500 insertions(+), 13657 deletions(-) create mode 100644 .changeset/fluffy-guests-train.md diff --git a/.changeset/fluffy-guests-train.md b/.changeset/fluffy-guests-train.md new file mode 100644 index 0000000000..8ba5352b31 --- /dev/null +++ b/.changeset/fluffy-guests-train.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +Support `exactOptionalPropertyTypes` diff --git a/examples/openapi-ts-angular-common/src/client/client/types.gen.ts b/examples/openapi-ts-angular-common/src/client/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/examples/openapi-ts-angular-common/src/client/client/types.gen.ts +++ b/examples/openapi-ts-angular-common/src/client/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/examples/openapi-ts-angular-common/src/client/core/auth.gen.ts b/examples/openapi-ts-angular-common/src/client/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/examples/openapi-ts-angular-common/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-angular-common/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/examples/openapi-ts-angular-common/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-angular-common/src/client/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/examples/openapi-ts-angular-common/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-angular-common/src/client/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/examples/openapi-ts-angular-common/src/client/core/params.gen.ts b/examples/openapi-ts-angular-common/src/client/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/examples/openapi-ts-angular-common/src/client/core/params.gen.ts +++ b/examples/openapi-ts-angular-common/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/examples/openapi-ts-angular-common/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-angular-common/src/client/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/examples/openapi-ts-angular-common/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-angular-common/src/client/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/examples/openapi-ts-angular-common/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-angular-common/src/client/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/examples/openapi-ts-angular-common/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-angular-common/src/client/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/examples/openapi-ts-angular-common/src/client/core/types.gen.ts b/examples/openapi-ts-angular-common/src/client/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/examples/openapi-ts-angular-common/src/client/core/types.gen.ts +++ b/examples/openapi-ts-angular-common/src/client/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-angular-common/src/client/core/utils.gen.ts b/examples/openapi-ts-angular-common/src/client/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/examples/openapi-ts-angular-common/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-angular-common/src/client/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/examples/openapi-ts-angular/src/client/client/types.gen.ts b/examples/openapi-ts-angular/src/client/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/examples/openapi-ts-angular/src/client/client/types.gen.ts +++ b/examples/openapi-ts-angular/src/client/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/examples/openapi-ts-angular/src/client/core/auth.gen.ts b/examples/openapi-ts-angular/src/client/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/examples/openapi-ts-angular/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-angular/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/examples/openapi-ts-angular/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-angular/src/client/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/examples/openapi-ts-angular/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-angular/src/client/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/examples/openapi-ts-angular/src/client/core/params.gen.ts b/examples/openapi-ts-angular/src/client/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/examples/openapi-ts-angular/src/client/core/params.gen.ts +++ b/examples/openapi-ts-angular/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/examples/openapi-ts-angular/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-angular/src/client/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/examples/openapi-ts-angular/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-angular/src/client/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/examples/openapi-ts-angular/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-angular/src/client/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/examples/openapi-ts-angular/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-angular/src/client/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/examples/openapi-ts-angular/src/client/core/types.gen.ts b/examples/openapi-ts-angular/src/client/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/examples/openapi-ts-angular/src/client/core/types.gen.ts +++ b/examples/openapi-ts-angular/src/client/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-angular/src/client/core/utils.gen.ts b/examples/openapi-ts-angular/src/client/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/examples/openapi-ts-angular/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-angular/src/client/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/examples/openapi-ts-axios/src/client/core/auth.gen.ts b/examples/openapi-ts-axios/src/client/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/examples/openapi-ts-axios/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-axios/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/examples/openapi-ts-axios/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-axios/src/client/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/examples/openapi-ts-axios/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-axios/src/client/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/examples/openapi-ts-axios/src/client/core/params.gen.ts b/examples/openapi-ts-axios/src/client/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/examples/openapi-ts-axios/src/client/core/params.gen.ts +++ b/examples/openapi-ts-axios/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/examples/openapi-ts-axios/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-axios/src/client/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/examples/openapi-ts-axios/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-axios/src/client/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/examples/openapi-ts-axios/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-axios/src/client/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/examples/openapi-ts-axios/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-axios/src/client/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/examples/openapi-ts-axios/src/client/core/types.gen.ts b/examples/openapi-ts-axios/src/client/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/examples/openapi-ts-axios/src/client/core/types.gen.ts +++ b/examples/openapi-ts-axios/src/client/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-axios/src/client/core/utils.gen.ts b/examples/openapi-ts-axios/src/client/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/examples/openapi-ts-axios/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-axios/src/client/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/examples/openapi-ts-fastify/src/client/client/client.gen.ts b/examples/openapi-ts-fastify/src/client/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/examples/openapi-ts-fastify/src/client/client/client.gen.ts +++ b/examples/openapi-ts-fastify/src/client/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/examples/openapi-ts-fastify/src/client/client/types.gen.ts b/examples/openapi-ts-fastify/src/client/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/examples/openapi-ts-fastify/src/client/client/types.gen.ts +++ b/examples/openapi-ts-fastify/src/client/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/examples/openapi-ts-fastify/src/client/core/auth.gen.ts b/examples/openapi-ts-fastify/src/client/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/examples/openapi-ts-fastify/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-fastify/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/examples/openapi-ts-fastify/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-fastify/src/client/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/examples/openapi-ts-fastify/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-fastify/src/client/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/examples/openapi-ts-fastify/src/client/core/params.gen.ts b/examples/openapi-ts-fastify/src/client/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/examples/openapi-ts-fastify/src/client/core/params.gen.ts +++ b/examples/openapi-ts-fastify/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/examples/openapi-ts-fastify/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-fastify/src/client/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/examples/openapi-ts-fastify/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-fastify/src/client/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/examples/openapi-ts-fastify/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-fastify/src/client/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/examples/openapi-ts-fastify/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-fastify/src/client/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/examples/openapi-ts-fastify/src/client/core/types.gen.ts b/examples/openapi-ts-fastify/src/client/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/examples/openapi-ts-fastify/src/client/core/types.gen.ts +++ b/examples/openapi-ts-fastify/src/client/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-fastify/src/client/core/utils.gen.ts b/examples/openapi-ts-fastify/src/client/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/examples/openapi-ts-fastify/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-fastify/src/client/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/examples/openapi-ts-fetch/src/client/client/client.gen.ts b/examples/openapi-ts-fetch/src/client/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/examples/openapi-ts-fetch/src/client/client/client.gen.ts +++ b/examples/openapi-ts-fetch/src/client/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/examples/openapi-ts-fetch/src/client/client/types.gen.ts b/examples/openapi-ts-fetch/src/client/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/examples/openapi-ts-fetch/src/client/client/types.gen.ts +++ b/examples/openapi-ts-fetch/src/client/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/examples/openapi-ts-fetch/src/client/core/auth.gen.ts b/examples/openapi-ts-fetch/src/client/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/examples/openapi-ts-fetch/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-fetch/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/examples/openapi-ts-fetch/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-fetch/src/client/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/examples/openapi-ts-fetch/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-fetch/src/client/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/examples/openapi-ts-fetch/src/client/core/params.gen.ts b/examples/openapi-ts-fetch/src/client/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/examples/openapi-ts-fetch/src/client/core/params.gen.ts +++ b/examples/openapi-ts-fetch/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/examples/openapi-ts-fetch/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-fetch/src/client/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/examples/openapi-ts-fetch/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-fetch/src/client/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/examples/openapi-ts-fetch/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-fetch/src/client/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/examples/openapi-ts-fetch/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-fetch/src/client/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/examples/openapi-ts-fetch/src/client/core/types.gen.ts b/examples/openapi-ts-fetch/src/client/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/examples/openapi-ts-fetch/src/client/core/types.gen.ts +++ b/examples/openapi-ts-fetch/src/client/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-fetch/src/client/core/utils.gen.ts b/examples/openapi-ts-fetch/src/client/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/examples/openapi-ts-fetch/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-fetch/src/client/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/examples/openapi-ts-ky/src/client/client/types.gen.ts b/examples/openapi-ts-ky/src/client/client/types.gen.ts index 62d18352cc..8c621e72fc 100644 --- a/examples/openapi-ts-ky/src/client/client/types.gen.ts +++ b/examples/openapi-ts-ky/src/client/client/types.gen.ts @@ -133,7 +133,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/examples/openapi-ts-ky/src/client/core/auth.gen.ts b/examples/openapi-ts-ky/src/client/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/examples/openapi-ts-ky/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-ky/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/examples/openapi-ts-ky/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-ky/src/client/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/examples/openapi-ts-ky/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-ky/src/client/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/examples/openapi-ts-ky/src/client/core/params.gen.ts b/examples/openapi-ts-ky/src/client/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/examples/openapi-ts-ky/src/client/core/params.gen.ts +++ b/examples/openapi-ts-ky/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/examples/openapi-ts-ky/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-ky/src/client/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/examples/openapi-ts-ky/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-ky/src/client/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/examples/openapi-ts-ky/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-ky/src/client/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/examples/openapi-ts-ky/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-ky/src/client/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/examples/openapi-ts-ky/src/client/core/types.gen.ts b/examples/openapi-ts-ky/src/client/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/examples/openapi-ts-ky/src/client/core/types.gen.ts +++ b/examples/openapi-ts-ky/src/client/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-ky/src/client/core/utils.gen.ts b/examples/openapi-ts-ky/src/client/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/examples/openapi-ts-ky/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-ky/src/client/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/examples/openapi-ts-next/src/client/client/client.gen.ts b/examples/openapi-ts-next/src/client/client/client.gen.ts index 53d0433b91..3721f4a054 100644 --- a/examples/openapi-ts-next/src/client/client/client.gen.ts +++ b/examples/openapi-ts-next/src/client/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/examples/openapi-ts-next/src/client/client/types.gen.ts b/examples/openapi-ts-next/src/client/client/types.gen.ts index 9309ceeb74..531b1d8575 100644 --- a/examples/openapi-ts-next/src/client/client/types.gen.ts +++ b/examples/openapi-ts-next/src/client/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/examples/openapi-ts-next/src/client/core/auth.gen.ts b/examples/openapi-ts-next/src/client/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/examples/openapi-ts-next/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-next/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/examples/openapi-ts-next/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-next/src/client/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/examples/openapi-ts-next/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-next/src/client/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/examples/openapi-ts-next/src/client/core/params.gen.ts b/examples/openapi-ts-next/src/client/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/examples/openapi-ts-next/src/client/core/params.gen.ts +++ b/examples/openapi-ts-next/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/examples/openapi-ts-next/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-next/src/client/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/examples/openapi-ts-next/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-next/src/client/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/examples/openapi-ts-next/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-next/src/client/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/examples/openapi-ts-next/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-next/src/client/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/examples/openapi-ts-next/src/client/core/types.gen.ts b/examples/openapi-ts-next/src/client/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/examples/openapi-ts-next/src/client/core/types.gen.ts +++ b/examples/openapi-ts-next/src/client/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-next/src/client/core/utils.gen.ts b/examples/openapi-ts-next/src/client/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/examples/openapi-ts-next/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-next/src/client/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/examples/openapi-ts-ofetch/src/client/client/types.gen.ts b/examples/openapi-ts-ofetch/src/client/client/types.gen.ts index 76d3c1c36d..170a4cca0b 100644 --- a/examples/openapi-ts-ofetch/src/client/client/types.gen.ts +++ b/examples/openapi-ts-ofetch/src/client/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/examples/openapi-ts-ofetch/src/client/core/auth.gen.ts b/examples/openapi-ts-ofetch/src/client/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/examples/openapi-ts-ofetch/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-ofetch/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/examples/openapi-ts-ofetch/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-ofetch/src/client/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/examples/openapi-ts-ofetch/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-ofetch/src/client/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/examples/openapi-ts-ofetch/src/client/core/params.gen.ts b/examples/openapi-ts-ofetch/src/client/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/examples/openapi-ts-ofetch/src/client/core/params.gen.ts +++ b/examples/openapi-ts-ofetch/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/examples/openapi-ts-ofetch/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-ofetch/src/client/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/examples/openapi-ts-ofetch/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-ofetch/src/client/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/examples/openapi-ts-ofetch/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-ofetch/src/client/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/examples/openapi-ts-ofetch/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-ofetch/src/client/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/examples/openapi-ts-ofetch/src/client/core/types.gen.ts b/examples/openapi-ts-ofetch/src/client/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/examples/openapi-ts-ofetch/src/client/core/types.gen.ts +++ b/examples/openapi-ts-ofetch/src/client/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-ofetch/src/client/core/utils.gen.ts b/examples/openapi-ts-ofetch/src/client/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/examples/openapi-ts-ofetch/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-ofetch/src/client/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/examples/openapi-ts-openai/src/client/client/client.gen.ts b/examples/openapi-ts-openai/src/client/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/examples/openapi-ts-openai/src/client/client/client.gen.ts +++ b/examples/openapi-ts-openai/src/client/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/examples/openapi-ts-openai/src/client/client/types.gen.ts b/examples/openapi-ts-openai/src/client/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/examples/openapi-ts-openai/src/client/client/types.gen.ts +++ b/examples/openapi-ts-openai/src/client/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/examples/openapi-ts-openai/src/client/core/auth.gen.ts b/examples/openapi-ts-openai/src/client/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/examples/openapi-ts-openai/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-openai/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/examples/openapi-ts-openai/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-openai/src/client/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/examples/openapi-ts-openai/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-openai/src/client/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/examples/openapi-ts-openai/src/client/core/params.gen.ts b/examples/openapi-ts-openai/src/client/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/examples/openapi-ts-openai/src/client/core/params.gen.ts +++ b/examples/openapi-ts-openai/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/examples/openapi-ts-openai/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-openai/src/client/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/examples/openapi-ts-openai/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-openai/src/client/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/examples/openapi-ts-openai/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-openai/src/client/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/examples/openapi-ts-openai/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-openai/src/client/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/examples/openapi-ts-openai/src/client/core/types.gen.ts b/examples/openapi-ts-openai/src/client/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/examples/openapi-ts-openai/src/client/core/types.gen.ts +++ b/examples/openapi-ts-openai/src/client/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-openai/src/client/core/utils.gen.ts b/examples/openapi-ts-openai/src/client/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/examples/openapi-ts-openai/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-openai/src/client/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/examples/openapi-ts-pinia-colada/src/client/client/client.gen.ts b/examples/openapi-ts-pinia-colada/src/client/client/client.gen.ts index 00dbae3997..d2c3ae4a9d 100644 --- a/examples/openapi-ts-pinia-colada/src/client/client/client.gen.ts +++ b/examples/openapi-ts-pinia-colada/src/client/client/client.gen.ts @@ -14,11 +14,6 @@ import { setAuthParams } from './utils.gen' -type ReqInit = Omit & { - body?: any - headers: ReturnType -} - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config) @@ -68,10 +63,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options) - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts) + body: getValidRequestBody(opts) as RequestInit['body'] } let request = new Request(url, requestInit) diff --git a/examples/openapi-ts-pinia-colada/src/client/client/types.gen.ts b/examples/openapi-ts-pinia-colada/src/client/client/types.gen.ts index 7ebb04c8c4..1cd0acc691 100644 --- a/examples/openapi-ts-pinia-colada/src/client/client/types.gen.ts +++ b/examples/openapi-ts-pinia-colada/src/client/client/types.gen.ts @@ -13,14 +13,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl'] + baseUrl?: T['baseUrl'] | undefined /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch + fetch?: typeof fetch | undefined /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -36,19 +36,19 @@ export interface Config * * @default 'auto' */ - parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text' + parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text' | undefined /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle + responseStyle?: ResponseStyle | undefined /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError'] + throwOnError?: T['throwOnError'] | undefined } export interface RequestOptions< @@ -73,13 +73,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown - path?: Record - query?: Record + body?: unknown | undefined + path?: Record | undefined + query?: Record | undefined /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray + security?: ReadonlyArray | undefined url: Url } @@ -88,7 +88,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string > extends RequestOptions { - serializedBody?: string + serializedBody?: string | undefined } export type RequestResult< @@ -127,9 +127,9 @@ export type RequestResult< > export interface ClientOptions { - baseUrl?: string - responseStyle?: ResponseStyle - throwOnError?: boolean + baseUrl?: string | undefined + responseStyle?: ResponseStyle | undefined + throwOnError?: boolean | undefined } type MethodFn = < @@ -162,9 +162,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown - path?: Record - query?: Record + body?: unknown | undefined + path?: Record | undefined + query?: Record | undefined url: string } >( @@ -184,14 +184,14 @@ export type Client = CoreClient * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config + override?: Config | undefined ) => Config & T> export interface TDataShape { - body?: unknown - headers?: unknown - path?: unknown - query?: unknown + body?: unknown | undefined + headers?: unknown | undefined + path?: unknown | undefined + query?: unknown | undefined url: string } diff --git a/examples/openapi-ts-pinia-colada/src/client/core/auth.gen.ts b/examples/openapi-ts-pinia-colada/src/client/core/auth.gen.ts index dc8ff61977..1aa10b6330 100644 --- a/examples/openapi-ts-pinia-colada/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-pinia-colada/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie' + in?: 'header' | 'query' | 'cookie' | undefined /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string - scheme?: 'basic' | 'bearer' + name?: string | undefined + scheme?: 'basic' | 'bearer' | undefined type: 'apiKey' | 'http' } diff --git a/examples/openapi-ts-pinia-colada/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-pinia-colada/src/client/core/bodySerializer.gen.ts index 09ffeb02af..23130a6f49 100644 --- a/examples/openapi-ts-pinia-colada/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-pinia-colada/src/client/core/bodySerializer.gen.ts @@ -7,9 +7,9 @@ export type QuerySerializer = (query: Record) => string export type BodySerializer = (body: any) => any type QuerySerializerOptionsObject = { - allowReserved?: boolean - array?: Partial> - object?: Partial> + allowReserved?: boolean | undefined + array?: Partial> | undefined + object?: Partial> | undefined } export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -17,7 +17,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record + parameters?: Record | undefined } const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => { diff --git a/examples/openapi-ts-pinia-colada/src/client/core/params.gen.ts b/examples/openapi-ts-pinia-colada/src/client/core/params.gen.ts index 356b25dfc8..f88263ff0a 100644 --- a/examples/openapi-ts-pinia-colada/src/client/core/params.gen.ts +++ b/examples/openapi-ts-pinia-colada/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string + map?: string | undefined } | { in: Extract /** * Key isn't required for bodies. */ - key?: string - map?: string + key?: string | undefined + map?: string | undefined } | { /** @@ -36,8 +36,8 @@ export type Field = } export interface Fields { - allowExtra?: Partial> - args?: ReadonlyArray + allowExtra?: Partial> | undefined + args?: ReadonlyArray | undefined } export type FieldsConfig = ReadonlyArray @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot - map?: string + map?: string | undefined } | { in?: never diff --git a/examples/openapi-ts-pinia-colada/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-pinia-colada/src/client/core/pathSerializer.gen.ts index acc13672ee..bca89360c9 100644 --- a/examples/openapi-ts-pinia-colada/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-pinia-colada/src/client/core/pathSerializer.gen.ts @@ -3,7 +3,7 @@ interface SerializeOptions extends SerializePrimitiveOptions, SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean + allowReserved?: boolean | undefined name: string } diff --git a/examples/openapi-ts-pinia-colada/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-pinia-colada/src/client/core/serverSentEvents.gen.ts index fa6a2fb66b..3d0dbeed64 100644 --- a/examples/openapi-ts-pinia-colada/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-pinia-colada/src/client/core/serverSentEvents.gen.ts @@ -10,11 +10,11 @@ export type ServerSentEventsOptions = Omit Promise + onRequest?: ((url: string, init: RequestInit) => Promise) | undefined /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -22,7 +22,7 @@ export type ServerSentEventsOptions = Omit void + onSseError?: ((error: unknown) => void) | undefined /** * Callback invoked when an event is streamed from the server. * @@ -31,8 +31,8 @@ export type ServerSentEventsOptions = Omit) => void - serializedBody?: RequestInit['body'] + onSseEvent?: ((event: StreamEvent) => void) | undefined + serializedBody?: RequestInit['body'] | undefined /** * Default retry delay in milliseconds. * @@ -40,11 +40,11 @@ export type ServerSentEventsOptions = Omit = Omit Promise + sseSleepFn?: ((ms: number) => Promise) | undefined url: string } export interface StreamEvent { data: TData - event?: string - id?: string - retry?: number + event?: string | undefined + id?: string | undefined + retry?: number | undefined } export type ServerSentEventsResult = { diff --git a/examples/openapi-ts-pinia-colada/src/client/core/types.gen.ts b/examples/openapi-ts-pinia-colada/src/client/core/types.gen.ts index 647ffcc493..2abac4c4a2 100644 --- a/examples/openapi-ts-pinia-colada/src/client/core/types.gen.ts +++ b/examples/openapi-ts-pinia-colada/src/client/core/types.gen.ts @@ -37,12 +37,12 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken | undefined /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null + bodySerializer?: BodySerializer | null | undefined /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -55,12 +55,13 @@ export interface Config { string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown > + | undefined /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase + method?: Uppercase | undefined /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -71,24 +72,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise + requestValidator?: (data: unknown) => Promise | undefined /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise + responseTransformer?: (data: unknown) => Promise | undefined /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise + responseValidator?: (data: unknown) => Promise | undefined } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-pinia-colada/src/client/core/utils.gen.ts b/examples/openapi-ts-pinia-colada/src/client/core/utils.gen.ts index bd078be240..38dd8bc7b6 100644 --- a/examples/openapi-ts-pinia-colada/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-pinia-colada/src/client/core/utils.gen.ts @@ -111,9 +111,9 @@ export const getUrl = ({ } export function getValidRequestBody(options: { - body?: unknown - bodySerializer?: BodySerializer | null - serializedBody?: unknown + body?: unknown | undefined + bodySerializer?: BodySerializer | null | undefined + serializedBody?: unknown | undefined }) { const hasBody = options.body !== undefined const isSerializedBody = hasBody && options.bodySerializer diff --git a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/types.gen.ts b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/types.gen.ts +++ b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/auth.gen.ts b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/params.gen.ts b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/params.gen.ts +++ b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/types.gen.ts b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/types.gen.ts +++ b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/utils.gen.ts b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/examples/openapi-ts-tanstack-react-query/src/client/client/client.gen.ts b/examples/openapi-ts-tanstack-react-query/src/client/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/examples/openapi-ts-tanstack-react-query/src/client/client/client.gen.ts +++ b/examples/openapi-ts-tanstack-react-query/src/client/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/examples/openapi-ts-tanstack-react-query/src/client/client/types.gen.ts b/examples/openapi-ts-tanstack-react-query/src/client/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/examples/openapi-ts-tanstack-react-query/src/client/client/types.gen.ts +++ b/examples/openapi-ts-tanstack-react-query/src/client/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/examples/openapi-ts-tanstack-react-query/src/client/core/auth.gen.ts b/examples/openapi-ts-tanstack-react-query/src/client/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/examples/openapi-ts-tanstack-react-query/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-tanstack-react-query/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/examples/openapi-ts-tanstack-react-query/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-tanstack-react-query/src/client/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/examples/openapi-ts-tanstack-react-query/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-tanstack-react-query/src/client/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/examples/openapi-ts-tanstack-react-query/src/client/core/params.gen.ts b/examples/openapi-ts-tanstack-react-query/src/client/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/examples/openapi-ts-tanstack-react-query/src/client/core/params.gen.ts +++ b/examples/openapi-ts-tanstack-react-query/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/examples/openapi-ts-tanstack-react-query/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-tanstack-react-query/src/client/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/examples/openapi-ts-tanstack-react-query/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-tanstack-react-query/src/client/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/examples/openapi-ts-tanstack-react-query/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-tanstack-react-query/src/client/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/examples/openapi-ts-tanstack-react-query/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-tanstack-react-query/src/client/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/examples/openapi-ts-tanstack-react-query/src/client/core/types.gen.ts b/examples/openapi-ts-tanstack-react-query/src/client/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/examples/openapi-ts-tanstack-react-query/src/client/core/types.gen.ts +++ b/examples/openapi-ts-tanstack-react-query/src/client/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-tanstack-react-query/src/client/core/utils.gen.ts b/examples/openapi-ts-tanstack-react-query/src/client/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/examples/openapi-ts-tanstack-react-query/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-tanstack-react-query/src/client/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/examples/openapi-ts-tanstack-svelte-query/src/client/client/client.gen.ts b/examples/openapi-ts-tanstack-svelte-query/src/client/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/examples/openapi-ts-tanstack-svelte-query/src/client/client/client.gen.ts +++ b/examples/openapi-ts-tanstack-svelte-query/src/client/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/examples/openapi-ts-tanstack-svelte-query/src/client/client/types.gen.ts b/examples/openapi-ts-tanstack-svelte-query/src/client/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/examples/openapi-ts-tanstack-svelte-query/src/client/client/types.gen.ts +++ b/examples/openapi-ts-tanstack-svelte-query/src/client/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/examples/openapi-ts-tanstack-svelte-query/src/client/core/auth.gen.ts b/examples/openapi-ts-tanstack-svelte-query/src/client/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/examples/openapi-ts-tanstack-svelte-query/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-tanstack-svelte-query/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/examples/openapi-ts-tanstack-svelte-query/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-tanstack-svelte-query/src/client/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/examples/openapi-ts-tanstack-svelte-query/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-tanstack-svelte-query/src/client/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/examples/openapi-ts-tanstack-svelte-query/src/client/core/params.gen.ts b/examples/openapi-ts-tanstack-svelte-query/src/client/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/examples/openapi-ts-tanstack-svelte-query/src/client/core/params.gen.ts +++ b/examples/openapi-ts-tanstack-svelte-query/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/examples/openapi-ts-tanstack-svelte-query/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-tanstack-svelte-query/src/client/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/examples/openapi-ts-tanstack-svelte-query/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-tanstack-svelte-query/src/client/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/examples/openapi-ts-tanstack-svelte-query/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-tanstack-svelte-query/src/client/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/examples/openapi-ts-tanstack-svelte-query/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-tanstack-svelte-query/src/client/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/examples/openapi-ts-tanstack-svelte-query/src/client/core/types.gen.ts b/examples/openapi-ts-tanstack-svelte-query/src/client/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/examples/openapi-ts-tanstack-svelte-query/src/client/core/types.gen.ts +++ b/examples/openapi-ts-tanstack-svelte-query/src/client/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-tanstack-svelte-query/src/client/core/utils.gen.ts b/examples/openapi-ts-tanstack-svelte-query/src/client/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/examples/openapi-ts-tanstack-svelte-query/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-tanstack-svelte-query/src/client/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/examples/openapi-ts-tanstack-vue-query/src/client/client/client.gen.ts b/examples/openapi-ts-tanstack-vue-query/src/client/client/client.gen.ts index 00dbae3997..d2c3ae4a9d 100644 --- a/examples/openapi-ts-tanstack-vue-query/src/client/client/client.gen.ts +++ b/examples/openapi-ts-tanstack-vue-query/src/client/client/client.gen.ts @@ -14,11 +14,6 @@ import { setAuthParams } from './utils.gen' -type ReqInit = Omit & { - body?: any - headers: ReturnType -} - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config) @@ -68,10 +63,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options) - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts) + body: getValidRequestBody(opts) as RequestInit['body'] } let request = new Request(url, requestInit) diff --git a/examples/openapi-ts-tanstack-vue-query/src/client/client/types.gen.ts b/examples/openapi-ts-tanstack-vue-query/src/client/client/types.gen.ts index 7ebb04c8c4..1cd0acc691 100644 --- a/examples/openapi-ts-tanstack-vue-query/src/client/client/types.gen.ts +++ b/examples/openapi-ts-tanstack-vue-query/src/client/client/types.gen.ts @@ -13,14 +13,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl'] + baseUrl?: T['baseUrl'] | undefined /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch + fetch?: typeof fetch | undefined /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -36,19 +36,19 @@ export interface Config * * @default 'auto' */ - parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text' + parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text' | undefined /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle + responseStyle?: ResponseStyle | undefined /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError'] + throwOnError?: T['throwOnError'] | undefined } export interface RequestOptions< @@ -73,13 +73,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown - path?: Record - query?: Record + body?: unknown | undefined + path?: Record | undefined + query?: Record | undefined /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray + security?: ReadonlyArray | undefined url: Url } @@ -88,7 +88,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string > extends RequestOptions { - serializedBody?: string + serializedBody?: string | undefined } export type RequestResult< @@ -127,9 +127,9 @@ export type RequestResult< > export interface ClientOptions { - baseUrl?: string - responseStyle?: ResponseStyle - throwOnError?: boolean + baseUrl?: string | undefined + responseStyle?: ResponseStyle | undefined + throwOnError?: boolean | undefined } type MethodFn = < @@ -162,9 +162,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown - path?: Record - query?: Record + body?: unknown | undefined + path?: Record | undefined + query?: Record | undefined url: string } >( @@ -184,14 +184,14 @@ export type Client = CoreClient * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config + override?: Config | undefined ) => Config & T> export interface TDataShape { - body?: unknown - headers?: unknown - path?: unknown - query?: unknown + body?: unknown | undefined + headers?: unknown | undefined + path?: unknown | undefined + query?: unknown | undefined url: string } diff --git a/examples/openapi-ts-tanstack-vue-query/src/client/core/auth.gen.ts b/examples/openapi-ts-tanstack-vue-query/src/client/core/auth.gen.ts index dc8ff61977..1aa10b6330 100644 --- a/examples/openapi-ts-tanstack-vue-query/src/client/core/auth.gen.ts +++ b/examples/openapi-ts-tanstack-vue-query/src/client/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie' + in?: 'header' | 'query' | 'cookie' | undefined /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string - scheme?: 'basic' | 'bearer' + name?: string | undefined + scheme?: 'basic' | 'bearer' | undefined type: 'apiKey' | 'http' } diff --git a/examples/openapi-ts-tanstack-vue-query/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-tanstack-vue-query/src/client/core/bodySerializer.gen.ts index 09ffeb02af..23130a6f49 100644 --- a/examples/openapi-ts-tanstack-vue-query/src/client/core/bodySerializer.gen.ts +++ b/examples/openapi-ts-tanstack-vue-query/src/client/core/bodySerializer.gen.ts @@ -7,9 +7,9 @@ export type QuerySerializer = (query: Record) => string export type BodySerializer = (body: any) => any type QuerySerializerOptionsObject = { - allowReserved?: boolean - array?: Partial> - object?: Partial> + allowReserved?: boolean | undefined + array?: Partial> | undefined + object?: Partial> | undefined } export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -17,7 +17,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record + parameters?: Record | undefined } const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => { diff --git a/examples/openapi-ts-tanstack-vue-query/src/client/core/params.gen.ts b/examples/openapi-ts-tanstack-vue-query/src/client/core/params.gen.ts index 356b25dfc8..f88263ff0a 100644 --- a/examples/openapi-ts-tanstack-vue-query/src/client/core/params.gen.ts +++ b/examples/openapi-ts-tanstack-vue-query/src/client/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string + map?: string | undefined } | { in: Extract /** * Key isn't required for bodies. */ - key?: string - map?: string + key?: string | undefined + map?: string | undefined } | { /** @@ -36,8 +36,8 @@ export type Field = } export interface Fields { - allowExtra?: Partial> - args?: ReadonlyArray + allowExtra?: Partial> | undefined + args?: ReadonlyArray | undefined } export type FieldsConfig = ReadonlyArray @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot - map?: string + map?: string | undefined } | { in?: never diff --git a/examples/openapi-ts-tanstack-vue-query/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-tanstack-vue-query/src/client/core/pathSerializer.gen.ts index acc13672ee..bca89360c9 100644 --- a/examples/openapi-ts-tanstack-vue-query/src/client/core/pathSerializer.gen.ts +++ b/examples/openapi-ts-tanstack-vue-query/src/client/core/pathSerializer.gen.ts @@ -3,7 +3,7 @@ interface SerializeOptions extends SerializePrimitiveOptions, SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean + allowReserved?: boolean | undefined name: string } diff --git a/examples/openapi-ts-tanstack-vue-query/src/client/core/serverSentEvents.gen.ts b/examples/openapi-ts-tanstack-vue-query/src/client/core/serverSentEvents.gen.ts index fa6a2fb66b..3d0dbeed64 100644 --- a/examples/openapi-ts-tanstack-vue-query/src/client/core/serverSentEvents.gen.ts +++ b/examples/openapi-ts-tanstack-vue-query/src/client/core/serverSentEvents.gen.ts @@ -10,11 +10,11 @@ export type ServerSentEventsOptions = Omit Promise + onRequest?: ((url: string, init: RequestInit) => Promise) | undefined /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -22,7 +22,7 @@ export type ServerSentEventsOptions = Omit void + onSseError?: ((error: unknown) => void) | undefined /** * Callback invoked when an event is streamed from the server. * @@ -31,8 +31,8 @@ export type ServerSentEventsOptions = Omit) => void - serializedBody?: RequestInit['body'] + onSseEvent?: ((event: StreamEvent) => void) | undefined + serializedBody?: RequestInit['body'] | undefined /** * Default retry delay in milliseconds. * @@ -40,11 +40,11 @@ export type ServerSentEventsOptions = Omit = Omit Promise + sseSleepFn?: ((ms: number) => Promise) | undefined url: string } export interface StreamEvent { data: TData - event?: string - id?: string - retry?: number + event?: string | undefined + id?: string | undefined + retry?: number | undefined } export type ServerSentEventsResult = { diff --git a/examples/openapi-ts-tanstack-vue-query/src/client/core/types.gen.ts b/examples/openapi-ts-tanstack-vue-query/src/client/core/types.gen.ts index 647ffcc493..2abac4c4a2 100644 --- a/examples/openapi-ts-tanstack-vue-query/src/client/core/types.gen.ts +++ b/examples/openapi-ts-tanstack-vue-query/src/client/core/types.gen.ts @@ -37,12 +37,12 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken | undefined /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null + bodySerializer?: BodySerializer | null | undefined /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -55,12 +55,13 @@ export interface Config { string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown > + | undefined /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase + method?: Uppercase | undefined /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -71,24 +72,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise + requestValidator?: (data: unknown) => Promise | undefined /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise + responseTransformer?: (data: unknown) => Promise | undefined /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise + responseValidator?: (data: unknown) => Promise | undefined } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/examples/openapi-ts-tanstack-vue-query/src/client/core/utils.gen.ts b/examples/openapi-ts-tanstack-vue-query/src/client/core/utils.gen.ts index bd078be240..38dd8bc7b6 100644 --- a/examples/openapi-ts-tanstack-vue-query/src/client/core/utils.gen.ts +++ b/examples/openapi-ts-tanstack-vue-query/src/client/core/utils.gen.ts @@ -111,9 +111,9 @@ export const getUrl = ({ } export function getValidRequestBody(options: { - body?: unknown - bodySerializer?: BodySerializer | null - serializedBody?: unknown + body?: unknown | undefined + bodySerializer?: BodySerializer | null | undefined + serializedBody?: unknown | undefined }) { const hasBody = options.body !== undefined const isSerializedBody = hasBody && options.bodySerializer diff --git a/packages/custom-client/src/types.ts b/packages/custom-client/src/types.ts index bfb98b68d2..60fcc52b40 100644 --- a/packages/custom-client/src/types.ts +++ b/packages/custom-client/src/types.ts @@ -8,14 +8,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: (request: Request) => ReturnType; + fetch?: ((request: Request) => ReturnType) | undefined; /** * Return the response data parsed in a specified format. By default, `auto` * will infer the appropriate method from the `Content-Type` response header. @@ -31,13 +31,14 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -51,13 +52,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -82,8 +83,8 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - throwOnError?: boolean; + baseUrl?: string | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -105,9 +106,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -131,10 +132,10 @@ export type CreateClientConfig = ( ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts +++ b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/types.gen.ts b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/types.gen.ts +++ b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/auth.gen.ts b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/auth.gen.ts +++ b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/params.gen.ts b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/params.gen.ts +++ b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/types.gen.ts b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/types.gen.ts +++ b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/utils.gen.ts b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/utils.gen.ts +++ b/packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/client/types.gen.ts index e341dbe4f7..4b7f9e4eef 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/bodySerializer.gen.ts index f654b09cdc..98af9d5e4c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/serverSentEvents.gen.ts index 9fbf49d04e..61b25c29c8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/types.gen.ts index 5c9a758cc0..8a3add25de 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/utils.gen.ts index 030030821d..168b965972 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/client/types.gen.ts index f4095ad6be..c4a550fe45 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/client/types.gen.ts index f4095ad6be..c4a550fe45 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/bodySerializer.gen.ts index f654b09cdc..98af9d5e4c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/serverSentEvents.gen.ts index 9fbf49d04e..61b25c29c8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/types.gen.ts index 5c9a758cc0..8a3add25de 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/utils.gen.ts index 030030821d..168b965972 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/client/client.gen.ts index 8715da997d..74c72d612f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen.ts'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/client/types.gen.ts index ce67386ca6..72aadee8db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/bodySerializer.gen.ts index f654b09cdc..98af9d5e4c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/serverSentEvents.gen.ts index 9fbf49d04e..61b25c29c8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/types.gen.ts index 5c9a758cc0..8a3add25de 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/utils.gen.ts index 030030821d..168b965972 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/client/client.gen.ts index 0e4f3174bd..acb634c6aa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen.js'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/client/types.gen.ts index 21c8ee1fba..ad318c8503 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-node16-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts index 0e4f3174bd..acb634c6aa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen.js'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/types.gen.ts index 21c8ee1fba..ad318c8503 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/types.gen.ts index 62d18352cc..8c621e72fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/types.gen.ts @@ -133,7 +133,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/types.gen.ts index 62d18352cc..8c621e72fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/types.gen.ts @@ -133,7 +133,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/types.gen.ts index 62d18352cc..8c621e72fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/types.gen.ts @@ -133,7 +133,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/types.gen.ts index 62d18352cc..8c621e72fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/types.gen.ts @@ -133,7 +133,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/types.gen.ts index 62d18352cc..8c621e72fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/types.gen.ts @@ -133,7 +133,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/types.gen.ts index 62d18352cc..8c621e72fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/types.gen.ts @@ -133,7 +133,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/types.gen.ts index 4520427cb3..996fd1e918 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/types.gen.ts @@ -133,7 +133,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/bodySerializer.gen.ts index f654b09cdc..98af9d5e4c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/serverSentEvents.gen.ts index 9fbf49d04e..61b25c29c8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/types.gen.ts index 5c9a758cc0..8a3add25de 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/utils.gen.ts index 030030821d..168b965972 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/types.gen.ts index 62d18352cc..8c621e72fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/types.gen.ts @@ -133,7 +133,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/types.gen.ts index 62d18352cc..8c621e72fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/types.gen.ts @@ -133,7 +133,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/client/types.gen.ts index 10fc8799f7..e46ece43c4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/client/types.gen.ts @@ -133,7 +133,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-node16-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/types.gen.ts index 10fc8799f7..e46ece43c4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/types.gen.ts @@ -133,7 +133,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts index 53d0433b91..3721f4a054 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/types.gen.ts index 9309ceeb74..531b1d8575 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts index 53d0433b91..3721f4a054 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/types.gen.ts index 9309ceeb74..531b1d8575 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts index 53d0433b91..3721f4a054 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/types.gen.ts index 9309ceeb74..531b1d8575 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts index 53d0433b91..3721f4a054 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/types.gen.ts index 9309ceeb74..531b1d8575 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts index 53d0433b91..3721f4a054 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/types.gen.ts index 9309ceeb74..531b1d8575 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts index 53d0433b91..3721f4a054 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/types.gen.ts index 9309ceeb74..531b1d8575 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/client/client.gen.ts index 47abadca4c..f42aa62ab2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen.ts'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/client/types.gen.ts index 21ca95afbb..ba3e90b5ad 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/bodySerializer.gen.ts index f654b09cdc..98af9d5e4c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/serverSentEvents.gen.ts index 9fbf49d04e..61b25c29c8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/types.gen.ts index 5c9a758cc0..8a3add25de 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/utils.gen.ts index 030030821d..168b965972 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/import-file-extension-ts/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts index 53d0433b91..3721f4a054 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/types.gen.ts index 9309ceeb74..531b1d8575 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts index 53d0433b91..3721f4a054 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/types.gen.ts index 9309ceeb74..531b1d8575 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/client/client.gen.ts index 12468638a7..b2739fcfbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen.js'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/client/types.gen.ts index cfb6cb7a23..c63b9cab1c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-node16-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts index 12468638a7..b2739fcfbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen.js'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/types.gen.ts index cfb6cb7a23..c63b9cab1c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/bodySerializer.gen.ts index f654b09cdc..98af9d5e4c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/serverSentEvents.gen.ts index 9fbf49d04e..61b25c29c8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/types.gen.ts index 5c9a758cc0..8a3add25de 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/utils.gen.ts index 030030821d..168b965972 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/client/types.gen.ts index 76d3c1c36d..170a4cca0b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/client/types.gen.ts index 76d3c1c36d..170a4cca0b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/client/types.gen.ts index 76d3c1c36d..170a4cca0b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/client/types.gen.ts index 76d3c1c36d..170a4cca0b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/client/types.gen.ts index 76d3c1c36d..170a4cca0b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/client/types.gen.ts index 76d3c1c36d..170a4cca0b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/client/types.gen.ts index e163e08827..c1aa32518a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/bodySerializer.gen.ts index f654b09cdc..98af9d5e4c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/serverSentEvents.gen.ts index 9fbf49d04e..61b25c29c8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/types.gen.ts index 5c9a758cc0..8a3add25de 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/utils.gen.ts index 030030821d..168b965972 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/client/types.gen.ts index 76d3c1c36d..170a4cca0b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/client/types.gen.ts index 76d3c1c36d..170a4cca0b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/client/types.gen.ts index 067e3d14db..8aa16f08e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-node16-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/client/types.gen.ts index 067e3d14db..8aa16f08e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts index 886b401aef..e7a099bc3d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts index 4dd6ae9329..e1da69dcbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/types.gen.ts index cc8a9e60fa..a5ce4f53d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/utils.gen.ts index 3029f7b3cc..f89a5778ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.cts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.cts index c1ccfba823..11063103cf 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.cts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.cts @@ -151,14 +151,14 @@ interface Config extends Omit ReturnType; + fetch?: ((request: Request) => ReturnType) | undefined; /** * Return the response data parsed in a specified format. By default, `auto` * will infer the appropriate method from the `Content-Type` response header. @@ -167,13 +167,13 @@ interface Config extends Omit extends Config<{ throwOnError: ThrowOnError; @@ -183,13 +183,13 @@ interface RequestOptions; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } type RequestResult = ThrowOnError extends true ? Promise<{ @@ -207,15 +207,15 @@ type RequestResult; interface ClientOptions { - baseUrl?: string; - throwOnError?: boolean; + baseUrl?: string | undefined; + throwOnError?: boolean | undefined; } type MethodFn = (options: Omit, 'method'>) => RequestResult; type RequestFn = (options: Omit, 'method'> & Pick>, 'method'>) => RequestResult; type BuildUrlFn = ; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }>(options: Pick & Options) => string; type Client = Client$1 & { @@ -231,10 +231,10 @@ type Client = Client$1 & { */ type CreateClientConfig = (override?: Config) => Config & T>; interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } type OmitKeys = Pick>; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.mts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.mts index 7371b92b0b..7d60e53be0 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.mts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.mts @@ -151,14 +151,14 @@ interface Config extends Omit ReturnType; + fetch?: ((request: Request) => ReturnType) | undefined; /** * Return the response data parsed in a specified format. By default, `auto` * will infer the appropriate method from the `Content-Type` response header. @@ -167,13 +167,13 @@ interface Config extends Omit extends Config<{ throwOnError: ThrowOnError; @@ -183,13 +183,13 @@ interface RequestOptions; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } type RequestResult = ThrowOnError extends true ? Promise<{ @@ -207,15 +207,15 @@ type RequestResult; interface ClientOptions { - baseUrl?: string; - throwOnError?: boolean; + baseUrl?: string | undefined; + throwOnError?: boolean | undefined; } type MethodFn = (options: Omit, 'method'>) => RequestResult; type RequestFn = (options: Omit, 'method'> & Pick>, 'method'>) => RequestResult; type BuildUrlFn = ; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }>(options: Pick & Options) => string; type Client = Client$1 & { @@ -231,10 +231,10 @@ type Client = Client$1 & { */ type CreateClientConfig = (override?: Config) => Config & T>; interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } type OmitKeys = Pick>; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/types.gen.ts index c7b4e2e12d..99c420fa41 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/types.gen.ts @@ -107,7 +107,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts index 53d0433b91..3721f4a054 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -88,9 +83,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/types.gen.ts index 9309ceeb74..531b1d8575 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/types.gen.ts @@ -83,7 +83,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/client/types.gen.ts index 76d3c1c36d..170a4cca0b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/client/types.gen.ts @@ -168,7 +168,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/auth.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/params.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/client/client.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/client/client.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/client/types.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/client/types.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/auth.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/auth.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/params.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/params.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/types.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/types.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/utils.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/utils.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/client/client.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/client/client.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/client/types.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/client/types.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/auth.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/auth.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/params.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/params.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/types.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/types.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/utils.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/utils.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/client/client.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/client/types.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/client/types.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/auth.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/auth.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/params.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/params.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/types.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/utils.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/utils.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/client/client.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/client/client.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/client/types.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/client/types.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/auth.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/auth.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/params.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/params.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/types.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/types.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/utils.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/utils.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/export-all/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/client/client.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/client/client.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/client/types.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/client/types.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/auth.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/auth.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/params.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/params.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/types.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/types.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/utils.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/utils.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/client/client.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/client/client.gen.ts index c2a5190c22..73fc48d763 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/client/client.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/client/client.gen.ts @@ -19,11 +19,6 @@ import { setAuthParams, } from './utils.gen'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -78,10 +73,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/client/types.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/client/types.gen.ts index b4a499cc03..bb7805407b 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/client/types.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/client/types.gen.ts @@ -19,14 +19,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -49,19 +49,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -86,13 +87,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -101,7 +102,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -150,9 +151,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -188,9 +189,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -216,14 +217,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/auth.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/auth.gen.ts index f8a73266f9..58b604e0e2 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/auth.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/auth.gen.ts @@ -8,14 +8,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/bodySerializer.gen.ts index 552b50f7c8..a64f9f4565 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/bodySerializer.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/bodySerializer.gen.ts @@ -11,9 +11,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -21,7 +21,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/params.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/params.gen.ts index 602715c46c..82a3ecc9d5 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/params.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/params.gen.ts @@ -13,15 +13,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -36,8 +36,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -54,7 +54,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/pathSerializer.gen.ts index 8d99931047..2d49bcd1db 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/pathSerializer.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/pathSerializer.gen.ts @@ -5,7 +5,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/serverSentEvents.gen.ts index 343d25af80..21640c7f83 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/serverSentEvents.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/serverSentEvents.gen.ts @@ -13,11 +13,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -25,7 +27,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -34,8 +36,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -43,11 +45,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -57,21 +59,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/types.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/types.gen.ts index 643c070c9d..49dd7a2615 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/types.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/types.gen.ts @@ -43,12 +43,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -66,13 +69,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -83,24 +87,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/utils.gen.ts b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/utils.gen.ts index 0b5389d089..052eb989e3 100644 --- a/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/utils.gen.ts +++ b/packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/core/utils.gen.ts @@ -114,9 +114,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/types.ts index 781c8832d0..7b17edc57e 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/types.ts @@ -105,7 +105,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/auth.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/auth.ts index 451c7f30f9..8dda7f723f 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/auth.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/auth.ts @@ -6,14 +6,14 @@ export interface Auth { * * @default 'header' */ - in?: 'header' | 'query' | 'cookie'; + in?: 'header' | 'query' | 'cookie' | undefined; /** * Header or query parameter name. * * @default 'Authorization' */ - name?: string; - scheme?: 'basic' | 'bearer'; + name?: string | undefined; + scheme?: 'basic' | 'bearer' | undefined; type: 'apiKey' | 'http'; } diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/bodySerializer.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/bodySerializer.ts index a284ced46b..7af78b4f57 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/bodySerializer.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/bodySerializer.ts @@ -9,9 +9,9 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { - allowReserved?: boolean; - array?: Partial>; - object?: Partial>; + allowReserved?: boolean | undefined; + array?: Partial> | undefined; + object?: Partial> | undefined; }; export type QuerySerializerOptions = QuerySerializerOptionsObject & { @@ -19,7 +19,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & { * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ - parameters?: Record; + parameters?: Record | undefined; }; const serializeFormDataPair = ( diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/params.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/params.ts index 1a4512788f..2091215029 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/params.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/params.ts @@ -11,15 +11,15 @@ export type Field = * Field mapped name. This is the name we want to use in the request. * If omitted, we use the same value as `key`. */ - map?: string; + map?: string | undefined; } | { in: Extract; /** * Key isn't required for bodies. */ - key?: string; - map?: string; + key?: string | undefined; + map?: string | undefined; } | { /** @@ -34,8 +34,8 @@ export type Field = }; export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; + allowExtra?: Partial> | undefined; + args?: ReadonlyArray | undefined; } export type FieldsConfig = ReadonlyArray; @@ -52,7 +52,7 @@ type KeyMap = Map< string, | { in: Slot; - map?: string; + map?: string | undefined; } | { in?: never; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/pathSerializer.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/pathSerializer.ts index d692cf0a39..d28dfa91a2 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/pathSerializer.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/pathSerializer.ts @@ -3,7 +3,7 @@ interface SerializeOptions SerializerOptions {} interface SerializePrimitiveOptions { - allowReserved?: boolean; + allowReserved?: boolean | undefined; name: string; } diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/serverSentEvents.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/serverSentEvents.ts index ed4b02b2c5..dbdfc3b71e 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/serverSentEvents.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/serverSentEvents.ts @@ -11,11 +11,13 @@ export type ServerSentEventsOptions = Omit< * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Implementing clients can call request interceptors inside this hook. */ - onRequest?: (url: string, init: RequestInit) => Promise; + onRequest?: + | ((url: string, init: RequestInit) => Promise) + | undefined; /** * Callback invoked when a network or parsing error occurs during streaming. * @@ -23,7 +25,7 @@ export type ServerSentEventsOptions = Omit< * * @param error The error that occurred. */ - onSseError?: (error: unknown) => void; + onSseError?: ((error: unknown) => void) | undefined; /** * Callback invoked when an event is streamed from the server. * @@ -32,8 +34,8 @@ export type ServerSentEventsOptions = Omit< * @param event Event streamed from the server. * @returns Nothing (void). */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; + onSseEvent?: ((event: StreamEvent) => void) | undefined; + serializedBody?: RequestInit['body'] | undefined; /** * Default retry delay in milliseconds. * @@ -41,11 +43,11 @@ export type ServerSentEventsOptions = Omit< * * @default 3000 */ - sseDefaultRetryDelay?: number; + sseDefaultRetryDelay?: number | undefined; /** * Maximum number of retry attempts before giving up. */ - sseMaxRetryAttempts?: number; + sseMaxRetryAttempts?: number | undefined; /** * Maximum retry delay in milliseconds. * @@ -55,21 +57,21 @@ export type ServerSentEventsOptions = Omit< * * @default 30000 */ - sseMaxRetryDelay?: number; + sseMaxRetryDelay?: number | undefined; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ - sseSleepFn?: (ms: number) => Promise; + sseSleepFn?: ((ms: number) => Promise) | undefined; url: string; }; export interface StreamEvent { data: TData; - event?: string; - id?: string; - retry?: number; + event?: string | undefined; + id?: string | undefined; + retry?: number | undefined; } export type ServerSentEventsResult< diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/types.ts index 4afdb3589a..abde7f0ded 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/types.ts @@ -41,12 +41,15 @@ export interface Config { * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ - auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + auth?: + | ((auth: Auth) => Promise | AuthToken) + | AuthToken + | undefined; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ - bodySerializer?: BodySerializer | null; + bodySerializer?: BodySerializer | null | undefined; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. @@ -64,13 +67,14 @@ export interface Config { | null | undefined | unknown - >; + > + | undefined; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ - method?: Uppercase; + method?: Uppercase | undefined; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject @@ -81,24 +85,24 @@ export interface Config { * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ - querySerializer?: QuerySerializer | QuerySerializerOptions; + querySerializer?: QuerySerializer | QuerySerializerOptions | undefined; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ - requestValidator?: (data: unknown) => Promise; + requestValidator?: (data: unknown) => Promise | undefined; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ - responseTransformer?: (data: unknown) => Promise; + responseTransformer?: (data: unknown) => Promise | undefined; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ - responseValidator?: (data: unknown) => Promise; + responseValidator?: (data: unknown) => Promise | undefined; } type IsExactlyNeverOrNeverUndefined = [T] extends [never] diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/utils.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/utils.ts index 77c8f2401f..35c069e642 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/utils.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/utils.ts @@ -112,9 +112,9 @@ export const getUrl = ({ }; export function getValidRequestBody(options: { - body?: unknown; - bodySerializer?: BodySerializer | null; - serializedBody?: unknown; + body?: unknown | undefined; + bodySerializer?: BodySerializer | null | undefined; + serializedBody?: unknown | undefined; }) { const hasBody = options.body !== undefined; const isSerializedBody = hasBody && options.bodySerializer; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts index 96823e345e..8aa8368584 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts @@ -17,11 +17,6 @@ import { setAuthParams, } from './utils'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -76,10 +71,10 @@ export const createClient = (config: Config = {}): Client => { const request: Client['request'] = async (options) => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', + const requestInit = { + redirect: 'follow' as const, ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let request = new Request(url, requestInit); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/types.ts index 0a8d15009b..9229aa4f73 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/types.ts @@ -17,14 +17,14 @@ export interface Config /** * Base URL for all requests made by this client. */ - baseUrl?: T['baseUrl']; + baseUrl?: T['baseUrl'] | undefined; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ - fetch?: typeof fetch; + fetch?: typeof fetch | undefined; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. @@ -47,19 +47,20 @@ export interface Config | 'formData' | 'json' | 'stream' - | 'text'; + | 'text' + | undefined; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ - responseStyle?: ResponseStyle; + responseStyle?: ResponseStyle | undefined; /** * Throw an error instead of returning it in the response? * * @default false */ - throwOnError?: T['throwOnError']; + throwOnError?: T['throwOnError'] | undefined; } export interface RequestOptions< @@ -84,13 +85,13 @@ export interface RequestOptions< * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; /** * Security mechanism(s) to use for the request. */ - security?: ReadonlyArray; + security?: ReadonlyArray | undefined; url: Url; } @@ -99,7 +100,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< @@ -148,9 +149,9 @@ export type RequestResult< >; export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; + baseUrl?: string | undefined; + responseStyle?: ResponseStyle | undefined; + throwOnError?: boolean | undefined; } type MethodFn = < @@ -186,9 +187,9 @@ type RequestFn = < type BuildUrlFn = < TData extends { - body?: unknown; - path?: Record; - query?: Record; + body?: unknown | undefined; + path?: Record | undefined; + query?: Record | undefined; url: string; }, >( @@ -214,14 +215,14 @@ export type Client = CoreClient< * to ensure your client always has the correct values. */ export type CreateClientConfig = ( - override?: Config, + override?: Config | undefined, ) => Config & T>; export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; + body?: unknown | undefined; + headers?: unknown | undefined; + path?: unknown | undefined; + query?: unknown | undefined; url: string; } diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/types.ts index baba033c99..06672af546 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/types.ts @@ -131,7 +131,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts index e3fb833f8c..68a001b889 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts @@ -17,11 +17,6 @@ import { setAuthParams, } from './utils'; -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - export const createClient = (config: Config = {}): Client => { let _config = mergeConfigs(createConfig(), config); @@ -86,9 +81,9 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - const requestInit: ReqInit = { + const requestInit: RequestInit = { ...opts, - body: getValidRequestBody(opts), + body: getValidRequestBody(opts) as RequestInit['body'], }; let response = await _fetch(url, requestInit); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/types.ts index 214175ecd8..a2eeab96f9 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/types.ts @@ -81,7 +81,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/types.ts index 0c45a80a3b..7d57a40435 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/types.ts @@ -166,7 +166,7 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { - serializedBody?: string; + serializedBody?: string | undefined; } export type RequestResult< diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/shared/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/shared/types.d.ts index 398b5ff6ff..44178cce5a 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/shared/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/shared/types.d.ts @@ -3,6 +3,7 @@ import type { Refs, SymbolMeta } from '@hey-api/codegen-core'; import type { HeyApiTypeScriptPlugin } from '../types'; export type IrSchemaToAstOptions = { + optional?: boolean; plugin: HeyApiTypeScriptPlugin['Instance']; state: Refs; }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/v1/plugin.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/v1/plugin.ts index 28224e6a9d..b526b5dff8 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/v1/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/v1/plugin.ts @@ -17,12 +17,19 @@ import type { HeyApiTypeScriptPlugin } from '../types'; import { irSchemaWithTypeToAst } from './toAst'; export const irSchemaToAst = ({ + optional, plugin, schema, state, }: IrSchemaToAstOptions & { schema: IR.SchemaObject; }): MaybeTsDsl => { + if (optional) { + return $.type.or( + irSchemaToAst({ plugin, schema, state }), + $.type('undefined'), + ); + } if (schema.symbolRef) { const baseType = $.type(schema.symbolRef); if (schema.omit && schema.omit.length > 0) { diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/v1/toAst/object.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/v1/toAst/object.ts index ea594c535d..5c7b2246d6 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/v1/toAst/object.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/v1/toAst/object.ts @@ -25,6 +25,7 @@ export const objectToAst = ({ for (const name in schema.properties) { const property = schema.properties[name]!; const propertyType = irSchemaToAst({ + optional: !required, plugin, schema: property, state: {